From ebae2fe2814e63d4d251f2cb2893f835b03ec6f3 Mon Sep 17 00:00:00 2001 From: Igor Mandrigin Date: Wed, 27 Nov 2019 14:52:22 +0100 Subject: [PATCH] Add `--noverify` flag to /cmd/state to skip roots check. (#205) --- cmd/state/commands/stateless.go | 16 +++++++++++++++- cmd/state/stateless/stateless.go | 10 +++++++--- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/cmd/state/commands/stateless.go b/cmd/state/commands/stateless.go index 2ff804b01..c53d60e79 100644 --- a/cmd/state/commands/stateless.go +++ b/cmd/state/commands/stateless.go @@ -13,6 +13,7 @@ var ( snapshotInterval uint64 snapshotFrom uint64 witnessInterval uint64 + noverify bool ) func init() { @@ -26,6 +27,7 @@ func init() { statelessCmd.Flags().Uint64Var(&snapshotInterval, "snapshotInterval", 0, "how often to take snapshots (0 - never, 1 - every block, 1000 - every 1000th block, etc)") statelessCmd.Flags().Uint64Var(&snapshotFrom, "snapshotFrom", 0, "from which block to start snapshots") statelessCmd.Flags().Uint64Var(&witnessInterval, "witnessInterval", 1, "after which block to extract witness (put a large number like 10000000 to disable)") + statelessCmd.Flags().BoolVar(&noverify, "noVerify", false, "skip snapshot verification on loading") rootCmd.AddCommand(statelessCmd) @@ -40,7 +42,19 @@ var statelessCmd = &cobra.Command{ return ethdb.NewBoltDatabase(path) } - stateless.Stateless(block, chaindata, statefile, triesize, preroot, snapshotInterval, snapshotFrom, witnessInterval, statsfile, createDb) + stateless.Stateless( + block, + chaindata, + statefile, + triesize, + preroot, + snapshotInterval, + snapshotFrom, + witnessInterval, + statsfile, + !noverify, + createDb, + ) return nil }, diff --git a/cmd/state/stateless/stateless.go b/cmd/state/stateless/stateless.go index a70ca4177..787eae4eb 100644 --- a/cmd/state/stateless/stateless.go +++ b/cmd/state/stateless/stateless.go @@ -79,6 +79,7 @@ func Stateless( ignoreOlderThan uint64, witnessThreshold uint64, statsfile string, + verifySnapshot bool, createDb CreateDbFunc) { state.MaxTrieCacheGen = triesize @@ -116,13 +117,16 @@ func Stateless( check(err) preRoot = genesisBlock.Header().Root } else { - //load_snapshot(db, fmt.Sprintf("/Volumes/tb4/turbo-geth-copy/state_%d", blockNum-1)) - //loadCodes(db, ethDb) block := bcb.GetBlockByNumber(blockNum - 1) fmt.Printf("Block number: %d\n", blockNum-1) fmt.Printf("Block root hash: %x\n", block.Root()) preRoot = block.Root() - checkRoots(stateDb, preRoot, blockNum-1) + + if verifySnapshot { + fmt.Println("Verifying snapshot..") + checkRoots(stateDb, preRoot, blockNum-1) + fmt.Println("Verifying snapshot... OK") + } } batch := stateDb.NewBatch() defer func() {