Skip to content

Commit

Permalink
Skip genesis state check for transitioned networks (#245)
Browse files Browse the repository at this point in the history
* Skip genesis state check for transitionned networks

* Update core/genesis.go

Co-authored-by: Sebastian Stammler <seb@oplabs.co>

---------

Co-authored-by: Sebastian Stammler <seb@oplabs.co>
  • Loading branch information
trianglesphere and sebastianst authored Feb 20, 2024
1 parent f33198a commit abc8821
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion core/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down

0 comments on commit abc8821

Please sign in to comment.