mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-17 10:20:44 +00:00
core, cmd/XDC: fix wrong hash caused by EIP-1559 number when init genesis
This commit is contained in:
parent
8850e1be87
commit
3837d0c2cc
2 changed files with 10 additions and 1 deletions
|
|
@ -184,6 +184,10 @@ func initGenesis(ctx *cli.Context) error {
|
||||||
utils.Fatalf("invalid genesis json: %v", err)
|
utils.Fatalf("invalid genesis json: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if genesis.Config.ChainId != nil {
|
||||||
|
common.CopyConstans(genesis.Config.ChainId.Uint64())
|
||||||
|
}
|
||||||
|
|
||||||
// Open an initialise both full and light databases
|
// Open an initialise both full and light databases
|
||||||
stack, _ := makeFullNode(ctx)
|
stack, _ := makeFullNode(ctx)
|
||||||
defer stack.Close()
|
defer stack.Close()
|
||||||
|
|
@ -198,7 +202,7 @@ func initGenesis(ctx *cli.Context) error {
|
||||||
utils.Fatalf("Failed to write genesis block: %v", err)
|
utils.Fatalf("Failed to write genesis block: %v", err)
|
||||||
}
|
}
|
||||||
chaindb.Close()
|
chaindb.Close()
|
||||||
log.Info("Successfully wrote genesis state", "database", name, "hash", hash)
|
log.Info("Successfully wrote genesis state", "database", name, "hash", hash.String())
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -213,6 +213,10 @@ func (g *Genesis) ToBlock(db ethdb.Database) *types.Block {
|
||||||
if g.Difficulty == nil {
|
if g.Difficulty == nil {
|
||||||
head.Difficulty = params.GenesisDifficulty
|
head.Difficulty = params.GenesisDifficulty
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Notice: Eip1559Block affects the block hash, we must set:
|
||||||
|
// 1. g.Config.Eip1559Block
|
||||||
|
// 2. or common.Eip1559Block
|
||||||
if g.Config != nil && g.Config.IsEIP1559(common.Big0) {
|
if g.Config != nil && g.Config.IsEIP1559(common.Big0) {
|
||||||
if g.BaseFee != nil {
|
if g.BaseFee != nil {
|
||||||
head.BaseFee = g.BaseFee
|
head.BaseFee = g.BaseFee
|
||||||
|
|
@ -220,6 +224,7 @@ func (g *Genesis) ToBlock(db ethdb.Database) *types.Block {
|
||||||
head.BaseFee = new(big.Int).SetUint64(params.InitialBaseFee)
|
head.BaseFee = new(big.Int).SetUint64(params.InitialBaseFee)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
statedb.Commit(false)
|
statedb.Commit(false)
|
||||||
statedb.Database().TrieDB().Commit(root, true)
|
statedb.Database().TrieDB().Commit(root, true)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue