mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-18 09:53:48 +00:00
core: copy genesis before modifying
This commit is contained in:
parent
85abb73a7e
commit
5803554aae
2 changed files with 16 additions and 2 deletions
|
|
@ -280,9 +280,10 @@ func SetupGenesisBlock(db ethdb.Database, triedb *triedb.Database, genesis *Gene
|
||||||
return SetupGenesisBlockWithOverride(db, triedb, genesis, nil)
|
return SetupGenesisBlockWithOverride(db, triedb, genesis, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
func SetupGenesisBlockWithOverride(db ethdb.Database, triedb *triedb.Database, genesis *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) {
|
||||||
// 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
|
||||||
}
|
}
|
||||||
|
|
@ -550,6 +551,19 @@ 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
|
||||||
|
|
|
||||||
|
|
@ -210,7 +210,7 @@ func newTestBlockchain(blocks []*types.Block) *core.BlockChain {
|
||||||
testBlockchains[head] = new(testBlockchain)
|
testBlockchains[head] = new(testBlockchain)
|
||||||
}
|
}
|
||||||
tbc := testBlockchains[head]
|
tbc := testBlockchains[head]
|
||||||
defer testBlockchainsLock.Unlock()
|
testBlockchainsLock.Unlock()
|
||||||
|
|
||||||
// Ensure that the database is generated
|
// Ensure that the database is generated
|
||||||
tbc.gen.Do(func() {
|
tbc.gen.Do(func() {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue