miner: modify header before checking time-based fields (#29242)

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
pull/29293/head
buddho 6 months ago committed by GitHub
parent eda9c7e36f
commit 4c1b57856f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 11
      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.

Loading…
Cancel
Save