diff --git a/miner/worker.go b/miner/worker.go index 7e038b0f301b..a72af3a3a454 100644 --- a/miner/worker.go +++ b/miner/worker.go @@ -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 @@ -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.