Skip to content

Commit 59951b3

Browse files
committed
add start from
1 parent c933b5c commit 59951b3

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

cmd/migration-checker/main.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ func main() {
3636
zkRoot = flag.String("zk-root", "", "root hash of the ZK node")
3737
paranoid = flag.Bool("paranoid", false, "verifies all node contents against their expected hash")
3838
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")
3940
)
4041
flag.Parse()
4142

@@ -70,7 +71,7 @@ func main() {
7071
checkTrieEquality(&dbs{
7172
zkDb: zkDb,
7273
mptDb: mptDb,
73-
}, zkRootHash, mptRootHash, "", checkAccountEquality, true, *paranoid)
74+
}, zkRootHash, mptRootHash, "", checkAccountEquality, true, *paranoid, *startFrom)
7475

7576
for i := 0; i < numTrieCheckers; i++ {
7677
<-trieCheckers
@@ -86,7 +87,7 @@ func panicOnError(err error, label, msg string) {
8687
func dup(s []byte) []byte {
8788
return append([]byte{}, s...)
8889
}
89-
func checkTrieEquality(dbs *dbs, zkRoot, mptRoot common.Hash, label string, leafChecker func(string, *dbs, []byte, []byte, bool), top, paranoid bool) {
90+
func checkTrieEquality(dbs *dbs, zkRoot, mptRoot common.Hash, label string, leafChecker func(string, *dbs, []byte, []byte, bool), top, paranoid bool, startFrom int) {
9091
done := make(chan struct{})
9192
start := time.Now()
9293
if !top {
@@ -120,8 +121,9 @@ func checkTrieEquality(dbs *dbs, zkRoot, mptRoot common.Hash, label string, leaf
120121
totalAccounts = len(mptLeafs)
121122
}
122123

123-
for index, zkKv := range zkLeafs {
124-
mptKv := mptLeafs[index]
124+
for i := startFrom; i < len(zkLeafs); i++ {
125+
zkKv := zkLeafs[i]
126+
mptKv := mptLeafs[i]
125127
leafChecker(fmt.Sprintf("%s key: %s", label, hex.EncodeToString([]byte(zkKv.key))), dbs, zkKv.value, mptKv.value, paranoid)
126128
}
127129
}
@@ -158,7 +160,7 @@ func checkAccountEquality(label string, dbs *dbs, zkAccountBytes, mptAccountByte
158160
}
159161
}()
160162

161-
checkTrieEquality(dbs, zkRoot, mptRoot, label, checkStorageEquality, false, paranoid)
163+
checkTrieEquality(dbs, zkRoot, mptRoot, label, checkStorageEquality, false, paranoid, 0)
162164
accountsDone.Add(1)
163165
fmt.Println("Accounts done:", accountsDone.Load(), "/", totalAccounts)
164166
trieCheckers <- struct{}{}

0 commit comments

Comments
 (0)