From abc8821e68c89125740e2583d24566ea56ffee27 Mon Sep 17 00:00:00 2001 From: Joshua Gutow Date: Tue, 20 Feb 2024 10:45:35 -0800 Subject: [PATCH] Skip genesis state check for transitioned networks (#245) * Skip genesis state check for transitionned networks * Update core/genesis.go Co-authored-by: Sebastian Stammler --------- Co-authored-by: Sebastian Stammler --- core/genesis.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/core/genesis.go b/core/genesis.go index 33282cffcf..da2b74ccc6 100644 --- a/core/genesis.go +++ b/core/genesis.go @@ -360,8 +360,13 @@ func SetupGenesisBlockWithOverride(db ethdb.Database, triedb *trie.Database, gen // state database is not initialized yet. It can happen that the node // is initialized with an external ancient store. Commit genesis state // in this case. + // If the bedrock block is not 0, that implies that the network was migrated at the bedrock block. + // In this case the genesis state may not be in the state database (e.g. op-geth is performing a snap + // sync without an existing datadir) & even if it were, would not be useful as op-geth is not able to + // execute the pre-bedrock STF. header := rawdb.ReadHeader(db, stored, 0) - if header.Root != types.EmptyRootHash && !triedb.Initialized(header.Root) { + transitionedNetwork := genesis != nil && genesis.Config != nil && genesis.Config.BedrockBlock != nil && genesis.Config.BedrockBlock.Uint64() != 0 + if header.Root != types.EmptyRootHash && !triedb.Initialized(header.Root) && !transitionedNetwork { if genesis == nil { genesis = DefaultGenesisBlock() }