mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-24 13:46:43 +00:00
revert more changes to simplify this PR
Signed-off-by: Guillaume Ballet <3272758+gballet@users.noreply.github.com>
This commit is contained in:
parent
0f37c99d34
commit
24f848dac8
2 changed files with 30 additions and 1 deletions
|
|
@ -341,7 +341,13 @@ func NewBlockChain(db ethdb.Database, genesis *Genesis, engine consensus.Engine,
|
||||||
if cfg == nil {
|
if cfg == nil {
|
||||||
cfg = DefaultConfig()
|
cfg = DefaultConfig()
|
||||||
}
|
}
|
||||||
triedb := triedb.NewDatabase(db, cfg.triedbConfig(genesis.IsVerkle()))
|
|
||||||
|
// Open trie database with provided config
|
||||||
|
enableVerkle, err := EnableVerkleAtGenesis(db, genesis)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
triedb := triedb.NewDatabase(db, cfg.triedbConfig(enableVerkle))
|
||||||
|
|
||||||
// Write the supplied genesis to the database if it has not been initialized
|
// Write the supplied genesis to the database if it has not been initialized
|
||||||
// yet. The corresponding chain config will be returned, either from the
|
// yet. The corresponding chain config will be returned, either from the
|
||||||
|
|
|
||||||
|
|
@ -572,6 +572,29 @@ func (g *Genesis) MustCommit(db ethdb.Database, triedb *triedb.Database) *types.
|
||||||
return block
|
return block
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// EnableVerkleAtGenesis indicates whether the verkle fork should be activated
|
||||||
|
// 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
|
||||||
|
// already passed.
|
||||||
|
//
|
||||||
|
// In production networks (mainnet and public testnets), verkle activation always
|
||||||
|
// occurs after the genesis block, making this function irrelevant in those cases.
|
||||||
|
func EnableVerkleAtGenesis(db ethdb.Database, genesis *Genesis) (bool, error) {
|
||||||
|
if genesis != nil {
|
||||||
|
if genesis.Config == nil {
|
||||||
|
return false, errGenesisNoConfig
|
||||||
|
}
|
||||||
|
return genesis.Config.EnableVerkleAtGenesis, nil
|
||||||
|
}
|
||||||
|
if ghash := rawdb.ReadCanonicalHash(db, 0); ghash != (common.Hash{}) {
|
||||||
|
chainCfg := rawdb.ReadChainConfig(db, ghash)
|
||||||
|
if chainCfg != nil {
|
||||||
|
return chainCfg.EnableVerkleAtGenesis, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false, nil
|
||||||
|
}
|
||||||
|
|
||||||
// DefaultGenesisBlock returns the Ethereum main net genesis block.
|
// DefaultGenesisBlock returns the Ethereum main net genesis block.
|
||||||
func DefaultGenesisBlock() *Genesis {
|
func DefaultGenesisBlock() *Genesis {
|
||||||
return &Genesis{
|
return &Genesis{
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue