Skip to content

Commit

Permalink
Header.BaseFee is set to non-zero for london fork disabled (#1805)
Browse files Browse the repository at this point in the history
  • Loading branch information
begmaroman authored Aug 14, 2023
1 parent db29c8a commit c860c52
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
11 changes: 11 additions & 0 deletions blockchain/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
4 changes: 0 additions & 4 deletions chain/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,6 @@ func (g *Genesis) GenesisHeader() *types.Header {
head.Difficulty = GenesisDifficulty
}

if g.BaseFee == 0 {
head.BaseFee = GenesisBaseFee
}

return head
}

Expand Down
4 changes: 1 addition & 3 deletions consensus/dev/dev.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit c860c52

Please sign in to comment.