good morning!!!!
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
bor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
open
bor
Commits
3ad4335a
Unverified
Commit
3ad4335a
authored
Dec 2, 2019
by
Martin Holst Swende
Committed by
Péter Szilágyi
Feb 25, 2020
Browse files
Options
Downloads
Patches
Plain Diff
core/state/snapshot: node behavioural difference on bloom content
parent
fd39f722
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
core/state/snapshot/difflayer.go
+16
-3
16 additions, 3 deletions
core/state/snapshot/difflayer.go
core/state/snapshot/difflayer_test.go
+6
-3
6 additions, 3 deletions
core/state/snapshot/difflayer_test.go
with
22 additions
and
6 deletions
core/state/snapshot/difflayer.go
+
16
−
3
View file @
3ad4335a
...
@@ -20,6 +20,7 @@ import (
...
@@ -20,6 +20,7 @@ import (
"encoding/binary"
"encoding/binary"
"fmt"
"fmt"
"math"
"math"
"math/rand"
"sort"
"sort"
"sync"
"sync"
"time"
"time"
...
@@ -63,8 +64,20 @@ var (
...
@@ -63,8 +64,20 @@ var (
// bloom filter to keep its size to a minimum (given it's size and maximum
// bloom filter to keep its size to a minimum (given it's size and maximum
// entry count).
// entry count).
bloomFuncs
=
math
.
Round
((
bloomSize
/
float64
(
aggregatorItemLimit
))
*
math
.
Log
(
2
))
bloomFuncs
=
math
.
Round
((
bloomSize
/
float64
(
aggregatorItemLimit
))
*
math
.
Log
(
2
))
// bloomHashesOffset is a runtime constant which determines which part of the
// the account/storage hash the hasher functions looks at, to determine the
// bloom key for an account/slot. This is randomized at init(), so that the
// global population of nodes do not all display the exact same behaviour with
// regards to bloom content
bloomHasherOffset
=
0
)
)
func
init
()
{
// Init bloomHasherOffset in the range [0:24] (requires 8 bytes)
bloomHasherOffset
=
rand
.
Intn
(
25
)
}
// diffLayer represents a collection of modifications made to a state snapshot
// diffLayer represents a collection of modifications made to a state snapshot
// after running a block on top. It contains one sorted list for the account trie
// after running a block on top. It contains one sorted list for the account trie
// and one-one list for each storage tries.
// and one-one list for each storage tries.
...
@@ -100,7 +113,7 @@ func (h accountBloomHasher) Reset() { panic("not impl
...
@@ -100,7 +113,7 @@ func (h accountBloomHasher) Reset() { panic("not impl
func
(
h
accountBloomHasher
)
BlockSize
()
int
{
panic
(
"not implemented"
)
}
func
(
h
accountBloomHasher
)
BlockSize
()
int
{
panic
(
"not implemented"
)
}
func
(
h
accountBloomHasher
)
Size
()
int
{
return
8
}
func
(
h
accountBloomHasher
)
Size
()
int
{
return
8
}
func
(
h
accountBloomHasher
)
Sum64
()
uint64
{
func
(
h
accountBloomHasher
)
Sum64
()
uint64
{
return
binary
.
BigEndian
.
Uint64
(
h
[
:
8
])
return
binary
.
BigEndian
.
Uint64
(
h
[
bloomHasherOffset
:
bloomHasherOffset
+
8
])
}
}
// storageBloomHasher is a wrapper around a [2]common.Hash to satisfy the interface
// storageBloomHasher is a wrapper around a [2]common.Hash to satisfy the interface
...
@@ -114,7 +127,8 @@ func (h storageBloomHasher) Reset() { panic("not impl
...
@@ -114,7 +127,8 @@ func (h storageBloomHasher) Reset() { panic("not impl
func
(
h
storageBloomHasher
)
BlockSize
()
int
{
panic
(
"not implemented"
)
}
func
(
h
storageBloomHasher
)
BlockSize
()
int
{
panic
(
"not implemented"
)
}
func
(
h
storageBloomHasher
)
Size
()
int
{
return
8
}
func
(
h
storageBloomHasher
)
Size
()
int
{
return
8
}
func
(
h
storageBloomHasher
)
Sum64
()
uint64
{
func
(
h
storageBloomHasher
)
Sum64
()
uint64
{
return
binary
.
BigEndian
.
Uint64
(
h
[
0
][
:
8
])
^
binary
.
BigEndian
.
Uint64
(
h
[
1
][
:
8
])
return
binary
.
BigEndian
.
Uint64
(
h
[
0
][
bloomHasherOffset
:
bloomHasherOffset
+
8
])
^
binary
.
BigEndian
.
Uint64
(
h
[
1
][
bloomHasherOffset
:
bloomHasherOffset
+
8
])
}
}
// newDiffLayer creates a new diff on top of an existing snapshot, whether that's a low
// newDiffLayer creates a new diff on top of an existing snapshot, whether that's a low
...
@@ -205,7 +219,6 @@ func (dl *diffLayer) rebloom(origin *diskLayer) {
...
@@ -205,7 +219,6 @@ func (dl *diffLayer) rebloom(origin *diskLayer) {
k
:=
float64
(
dl
.
diffed
.
K
())
k
:=
float64
(
dl
.
diffed
.
K
())
n
:=
float64
(
dl
.
diffed
.
N
())
n
:=
float64
(
dl
.
diffed
.
N
())
m
:=
float64
(
dl
.
diffed
.
M
())
m
:=
float64
(
dl
.
diffed
.
M
())
snapshotBloomErrorGauge
.
Update
(
math
.
Pow
(
1.0
-
math
.
Exp
((
-
k
)
*
(
n
+
0.5
)
/
(
m
-
1
)),
k
))
snapshotBloomErrorGauge
.
Update
(
math
.
Pow
(
1.0
-
math
.
Exp
((
-
k
)
*
(
n
+
0.5
)
/
(
m
-
1
)),
k
))
}
}
...
...
This diff is collapsed.
Click to expand it.
core/state/snapshot/difflayer_test.go
+
6
−
3
View file @
3ad4335a
...
@@ -24,6 +24,7 @@ import (
...
@@ -24,6 +24,7 @@ import (
"github.com/VictoriaMetrics/fastcache"
"github.com/VictoriaMetrics/fastcache"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/ethdb/memorydb"
"github.com/ethereum/go-ethereum/ethdb/memorydb"
"github.com/ethereum/go-ethereum/rlp"
"github.com/ethereum/go-ethereum/rlp"
)
)
...
@@ -216,7 +217,7 @@ func BenchmarkSearch(b *testing.B) {
...
@@ -216,7 +217,7 @@ func BenchmarkSearch(b *testing.B) {
layer
=
fill
(
layer
)
layer
=
fill
(
layer
)
}
}
key
:=
c
ommon
.
Hash
{}
key
:=
c
rypto
.
Keccak256Hash
([]
byte
{
0x13
,
0x38
})
b
.
ResetTimer
()
b
.
ResetTimer
()
for
i
:=
0
;
i
<
b
.
N
;
i
++
{
for
i
:=
0
;
i
<
b
.
N
;
i
++
{
layer
.
AccountRLP
(
key
)
layer
.
AccountRLP
(
key
)
...
@@ -229,10 +230,12 @@ func BenchmarkSearch(b *testing.B) {
...
@@ -229,10 +230,12 @@ func BenchmarkSearch(b *testing.B) {
// BenchmarkSearchSlot-6 100000 14554 ns/op
// BenchmarkSearchSlot-6 100000 14554 ns/op
// BenchmarkSearchSlot-6 100000 22254 ns/op (when checking parent root using mutex)
// BenchmarkSearchSlot-6 100000 22254 ns/op (when checking parent root using mutex)
// BenchmarkSearchSlot-6 100000 14551 ns/op (when checking parent number using atomic)
// BenchmarkSearchSlot-6 100000 14551 ns/op (when checking parent number using atomic)
// With bloom filter:
// BenchmarkSearchSlot-6 3467835 351 ns/op
func
BenchmarkSearchSlot
(
b
*
testing
.
B
)
{
func
BenchmarkSearchSlot
(
b
*
testing
.
B
)
{
// First, we set up 128 diff layers, with 1K items each
// First, we set up 128 diff layers, with 1K items each
accountKey
:=
c
ommon
.
Hash
{}
accountKey
:=
c
rypto
.
Keccak256Hash
([]
byte
{
0x13
,
0x37
})
storageKey
:=
c
ommon
.
HexToHash
(
"0x13
37
"
)
storageKey
:=
c
rypto
.
Keccak256Hash
([]
byte
{
0x13
,
0x
37
}
)
accountRLP
:=
randomAccount
()
accountRLP
:=
randomAccount
()
fill
:=
func
(
parent
snapshot
)
*
diffLayer
{
fill
:=
func
(
parent
snapshot
)
*
diffLayer
{
accounts
:=
make
(
map
[
common
.
Hash
][]
byte
)
accounts
:=
make
(
map
[
common
.
Hash
][]
byte
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment