Skip to content

Commit

Permalink
miner: modify header before checking time-based fields (ethereum#29242)
Browse files Browse the repository at this point in the history
The Prepare-method of consensus engine might modify the time-field in a header, so it should be called prior to checks that rely on it
  • Loading branch information
buddh0 authored and GrapeBaBa committed Mar 20, 2024
1 parent 88b5429 commit 2604872
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions miner/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,12 @@ func (miner *Miner) prepareWork(genParams *generateParams) (*environment, error)
header.GasLimit = core.CalcGasLimit(parentGasLimit, miner.config.GasCeil)
}
}
// Run the consensus preparation with the default or customized consensus engine.
// Note that the `header.Time` may be changed.
if err := miner.engine.Prepare(miner.chain, header); err != nil {
log.Error("Failed to prepare header for sealing", "err", err)
return nil, err
}
// Apply EIP-4844, EIP-4788.
if miner.chainConfig.IsCancun(header.Number, header.Time) {
var excessBlobGas uint64
Expand All @@ -180,11 +186,6 @@ func (miner *Miner) prepareWork(genParams *generateParams) (*environment, error)
header.ExcessBlobGas = &excessBlobGas
header.ParentBeaconRoot = genParams.beaconRoot
}
// Run the consensus preparation with the default or customized consensus engine.
if err := miner.engine.Prepare(miner.chain, header); err != nil {
log.Error("Failed to prepare header for sealing", "err", err)
return nil, err
}
// Could potentially happen if starting to mine in an odd state.
// Note genParams.coinbase can be different with header.Coinbase
// since clique algorithm can modify the coinbase field in header.
Expand Down

0 comments on commit 2604872

Please sign in to comment.