core: only do a local copy of the genesis block

This commit is contained in:
Marius van der Wijden 2025-01-31 16:45:09 +01:00
parent bae8a52e8f
commit 3fa1ed8420

View file

@ -281,9 +281,14 @@ func SetupGenesisBlock(db ethdb.Database, triedb *triedb.Database, genesis *Gene
} }
func SetupGenesisBlockWithOverride(db ethdb.Database, triedb *triedb.Database, origGenesis *Genesis, overrides *ChainOverrides) (*params.ChainConfig, common.Hash, *params.ConfigCompatError, error) { func SetupGenesisBlockWithOverride(db ethdb.Database, triedb *triedb.Database, origGenesis *Genesis, overrides *ChainOverrides) (*params.ChainConfig, common.Hash, *params.ConfigCompatError, error) {
// Copy the genesis, so we can operate on a copy.
var genesis *Genesis
if origGenesis != nil {
genesis = new(Genesis)
*genesis = *origGenesis
}
// Sanitize the supplied genesis, ensuring it has the associated chain // Sanitize the supplied genesis, ensuring it has the associated chain
// config attached. // config attached.
genesis := origGenesis.copy()
if genesis != nil && genesis.Config == nil { if genesis != nil && genesis.Config == nil {
return nil, common.Hash{}, nil, errGenesisNoConfig return nil, common.Hash{}, nil, errGenesisNoConfig
} }
@ -551,19 +556,6 @@ func (g *Genesis) MustCommit(db ethdb.Database, triedb *triedb.Database) *types.
return block return block
} }
// copy copies the genesis.
func (g *Genesis) copy() *Genesis {
if g != nil {
cpy := *g
if g.Config != nil {
conf := *g.Config
cpy.Config = &conf
}
return &cpy
}
return nil
}
// EnableVerkleAtGenesis indicates whether the verkle fork should be activated // EnableVerkleAtGenesis indicates whether the verkle fork should be activated
// at genesis. This is a temporary solution only for verkle devnet testing, where // at genesis. This is a temporary solution only for verkle devnet testing, where
// verkle fork is activated at genesis, and the configured activation date has // verkle fork is activated at genesis, and the configured activation date has