diff --git a/blockchain/blockchain.go b/blockchain/blockchain.go index 5133bd8278..5f60ea2298 100644 --- a/blockchain/blockchain.go +++ b/blockchain/blockchain.go @@ -1356,7 +1356,18 @@ func (b *Blockchain) Close() error { // CalculateBaseFee calculates the basefee of the header. func (b *Blockchain) CalculateBaseFee(parent *types.Header) uint64 { + // Return zero base fee is a london hardfork is not enabled if !b.config.Params.Forks.IsActive(chain.London, parent.Number) { + return 0 + } + + // Check if this is the first London hardfork block. + // Should return chain.GenesisBaseFee ins this case. + if parent.BaseFee == 0 { + if b.config.Genesis.BaseFee > 0 { + return b.config.Genesis.BaseFee + } + return chain.GenesisBaseFee } diff --git a/chain/chain.go b/chain/chain.go index be52ef1490..d02c7eb9bc 100644 --- a/chain/chain.go +++ b/chain/chain.go @@ -96,10 +96,6 @@ func (g *Genesis) GenesisHeader() *types.Header { head.Difficulty = GenesisDifficulty } - if g.BaseFee == 0 { - head.BaseFee = GenesisBaseFee - } - return head } diff --git a/consensus/dev/dev.go b/consensus/dev/dev.go index f6942963f8..a07eab9af4 100644 --- a/consensus/dev/dev.go +++ b/consensus/dev/dev.go @@ -167,10 +167,8 @@ func (d *Dev) writeNewBlock(parent *types.Header) error { return err } - baseFee := d.blockchain.CalculateBaseFee(parent) - header.GasLimit = gasLimit - header.BaseFee = baseFee + header.BaseFee = d.blockchain.CalculateBaseFee(parent) miner, err := d.GetBlockCreator(header) if err != nil {