@@ -36,6 +36,7 @@ func main() {
36
36
zkRoot = flag .String ("zk-root" , "" , "root hash of the ZK node" )
37
37
paranoid = flag .Bool ("paranoid" , false , "verifies all node contents against their expected hash" )
38
38
parallelismMultipler = flag .Int ("parallelism-multiplier" , 4 , "multiplier for the number of parallel workers" )
39
+ startFrom = flag .Int ("start-form" , 0 , "start checking from account at the given index" )
39
40
)
40
41
flag .Parse ()
41
42
@@ -67,10 +68,16 @@ func main() {
67
68
}()
68
69
defer close (done )
69
70
71
+ startFromSafe := * startFrom - len (trieCheckers )
72
+ if startFromSafe < 0 {
73
+ startFromSafe = 0
74
+ }
75
+ accountsDone .Add (uint64 (startFromSafe ))
76
+
70
77
checkTrieEquality (& dbs {
71
78
zkDb : zkDb ,
72
79
mptDb : mptDb ,
73
- }, zkRootHash , mptRootHash , "" , checkAccountEquality , true , * paranoid )
80
+ }, zkRootHash , mptRootHash , "" , checkAccountEquality , true , * paranoid , startFromSafe )
74
81
75
82
for i := 0 ; i < numTrieCheckers ; i ++ {
76
83
<- trieCheckers
@@ -86,7 +93,7 @@ func panicOnError(err error, label, msg string) {
86
93
func dup (s []byte ) []byte {
87
94
return append ([]byte {}, s ... )
88
95
}
89
- func checkTrieEquality (dbs * dbs , zkRoot , mptRoot common.Hash , label string , leafChecker func (string , * dbs , []byte , []byte , bool ), top , paranoid bool ) {
96
+ func checkTrieEquality (dbs * dbs , zkRoot , mptRoot common.Hash , label string , leafChecker func (string , * dbs , []byte , []byte , bool ), top , paranoid bool , startFrom int ) {
90
97
done := make (chan struct {})
91
98
start := time .Now ()
92
99
if ! top {
@@ -120,8 +127,9 @@ func checkTrieEquality(dbs *dbs, zkRoot, mptRoot common.Hash, label string, leaf
120
127
totalAccounts = len (mptLeafs )
121
128
}
122
129
123
- for index , zkKv := range zkLeafs {
124
- mptKv := mptLeafs [index ]
130
+ for i := startFrom ; i < len (zkLeafs ); i ++ {
131
+ zkKv := zkLeafs [i ]
132
+ mptKv := mptLeafs [i ]
125
133
leafChecker (fmt .Sprintf ("%s key: %s" , label , hex .EncodeToString ([]byte (zkKv .key ))), dbs , zkKv .value , mptKv .value , paranoid )
126
134
}
127
135
}
@@ -158,7 +166,7 @@ func checkAccountEquality(label string, dbs *dbs, zkAccountBytes, mptAccountByte
158
166
}
159
167
}()
160
168
161
- checkTrieEquality (dbs , zkRoot , mptRoot , label , checkStorageEquality , false , paranoid )
169
+ checkTrieEquality (dbs , zkRoot , mptRoot , label , checkStorageEquality , false , paranoid , 0 )
162
170
accountsDone .Add (1 )
163
171
fmt .Println ("Accounts done:" , accountsDone .Load (), "/" , totalAccounts )
164
172
trieCheckers <- struct {}{}
0 commit comments