@@ -5,11 +5,8 @@ import (
5
5
"encoding/hex"
6
6
"flag"
7
7
"fmt"
8
- "os"
9
- "runtime"
10
8
"sort"
11
9
"sync"
12
- "sync/atomic"
13
10
"time"
14
11
15
12
"github.com/scroll-tech/go-ethereum/common"
@@ -19,22 +16,18 @@ import (
19
16
"github.com/scroll-tech/go-ethereum/trie"
20
17
)
21
18
22
- var accountsDone atomic.Uint64
23
- var trieCheckers chan struct {}
24
-
25
19
type dbs struct {
26
20
zkDb * leveldb.Database
27
21
mptDb * leveldb.Database
28
22
}
29
23
30
24
func main () {
31
25
var (
32
- mptDbPath = flag .String ("mpt-db" , "" , "path to the MPT node DB" )
33
- zkDbPath = flag .String ("zk-db" , "" , "path to the ZK node DB" )
34
- mptRoot = flag .String ("mpt-root" , "" , "root hash of the MPT node" )
35
- zkRoot = flag .String ("zk-root" , "" , "root hash of the ZK node" )
36
- paranoid = flag .Bool ("paranoid" , false , "verifies all node contents against their expected hash" )
37
- parallelismMultipler = flag .Int ("parallelism-multiplier" , 4 , "multiplier for the number of parallel workers" )
26
+ mptDbPath = flag .String ("mpt-db" , "" , "path to the MPT node DB" )
27
+ zkDbPath = flag .String ("zk-db" , "" , "path to the ZK node DB" )
28
+ mptRoot = flag .String ("mpt-root" , "" , "root hash of the MPT node" )
29
+ zkRoot = flag .String ("zk-root" , "" , "root hash of the ZK node" )
30
+ paranoid = flag .Bool ("paranoid" , false , "verifies all node contents against their expected hash" )
38
31
)
39
32
flag .Parse ()
40
33
@@ -45,35 +38,10 @@ func main() {
45
38
46
39
zkRootHash := common .HexToHash (* zkRoot )
47
40
mptRootHash := common .HexToHash (* mptRoot )
48
-
49
- numTrieCheckers := runtime .GOMAXPROCS (0 ) * (* parallelismMultipler )
50
- trieCheckers = make (chan struct {}, numTrieCheckers )
51
- for i := 0 ; i < numTrieCheckers ; i ++ {
52
- trieCheckers <- struct {}{}
53
- }
54
-
55
- done := make (chan struct {})
56
- totalCheckers := len (trieCheckers )
57
- go func () {
58
- for {
59
- select {
60
- case <- done :
61
- return
62
- case <- time .After (time .Minute ):
63
- fmt .Println ("Active checkers:" , totalCheckers - len (trieCheckers ))
64
- }
65
- }
66
- }()
67
- defer close (done )
68
-
69
41
checkTrieEquality (& dbs {
70
42
zkDb : zkDb ,
71
43
mptDb : mptDb ,
72
44
}, zkRootHash , mptRootHash , "" , checkAccountEquality , true , * paranoid )
73
-
74
- for i := 0 ; i < numTrieCheckers ; i ++ {
75
- <- trieCheckers
76
- }
77
45
}
78
46
79
47
func panicOnError (err error , label , msg string ) {
@@ -120,6 +88,7 @@ func checkTrieEquality(dbs *dbs, zkRoot, mptRoot common.Hash, label string, leaf
120
88
for index , zkKv := range zkLeafs {
121
89
mptKv := mptLeafs [index ]
122
90
leafChecker (fmt .Sprintf ("%s key: %s" , label , hex .EncodeToString ([]byte (zkKv .key ))), dbs , zkKv .value , mptKv .value , paranoid )
91
+ fmt .Println ("Accounts done:" , index + 1 , "/" , len (zkLeafs ))
123
92
}
124
93
}
125
94
@@ -146,23 +115,7 @@ func checkAccountEquality(label string, dbs *dbs, zkAccountBytes, mptAccountByte
146
115
} else if zkAccount .Root != (common.Hash {}) {
147
116
zkRoot := common .BytesToHash (zkAccount .Root [:])
148
117
mptRoot := common .BytesToHash (mptAccount .Root [:])
149
- <- trieCheckers
150
- go func () {
151
- defer func () {
152
- if p := recover (); p != nil {
153
- fmt .Println (p )
154
- os .Exit (1 )
155
- }
156
- }()
157
-
158
- checkTrieEquality (dbs , zkRoot , mptRoot , label , checkStorageEquality , false , paranoid )
159
- accountsDone .Add (1 )
160
- fmt .Println ("Accounts done:" , accountsDone .Load ())
161
- trieCheckers <- struct {}{}
162
- }()
163
- } else {
164
- accountsDone .Add (1 )
165
- fmt .Println ("Accounts done:" , accountsDone .Load ())
118
+ checkTrieEquality (dbs , zkRoot , mptRoot , label , checkStorageEquality , false , paranoid )
166
119
}
167
120
}
168
121
@@ -183,9 +136,6 @@ type kv struct {
183
136
func loadMPT (mptTrie * trie.SecureTrie , top bool ) chan []kv {
184
137
startKey := make ([]byte , 32 )
185
138
workers := 1 << 5
186
- if ! top {
187
- workers = 1 << 3
188
- }
189
139
step := byte (256 / workers )
190
140
191
141
mptLeafs := make ([]kv , 0 , 1000 )
0 commit comments