mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-23 13:16:42 +00:00
ethapi: Fix merge transition
This commit is contained in:
parent
df0bd8960c
commit
de11e85160
1 changed files with 16 additions and 3 deletions
|
|
@ -458,6 +458,13 @@ func (sim *simulator) sanitizeChain(blocks []simBlock) ([]simBlock, error) {
|
||||||
return res, nil
|
return res, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func isPostMerge(config *params.ChainConfig, blockNum uint64, timestamp uint64) bool {
|
||||||
|
mergedAtGenesis := config.TerminalTotalDifficulty != nil && config.TerminalTotalDifficulty.Sign() == 0
|
||||||
|
return mergedAtGenesis ||
|
||||||
|
config.MergeNetsplitBlock != nil && blockNum >= config.MergeNetsplitBlock.Uint64() ||
|
||||||
|
config.ShanghaiTime != nil && timestamp >= *config.ShanghaiTime
|
||||||
|
}
|
||||||
|
|
||||||
// makeHeaders makes header object with preliminary fields based on a simulated block.
|
// makeHeaders makes header object with preliminary fields based on a simulated block.
|
||||||
// Some fields have to be filled post-execution.
|
// Some fields have to be filled post-execution.
|
||||||
// It assumes blocks are in order and numbers have been validated.
|
// It assumes blocks are in order and numbers have been validated.
|
||||||
|
|
@ -474,22 +481,28 @@ func (sim *simulator) makeHeaders(blocks []simBlock) ([]*types.Header, error) {
|
||||||
overrides := block.BlockOverrides
|
overrides := block.BlockOverrides
|
||||||
|
|
||||||
var withdrawalsHash *common.Hash
|
var withdrawalsHash *common.Hash
|
||||||
if sim.chainConfig.IsShanghai(overrides.Number.ToInt(), (uint64)(*overrides.Time)) {
|
number := overrides.Number.ToInt()
|
||||||
|
timestamp := (uint64)(*overrides.Time)
|
||||||
|
if sim.chainConfig.IsShanghai(number, timestamp) {
|
||||||
withdrawalsHash = &types.EmptyWithdrawalsHash
|
withdrawalsHash = &types.EmptyWithdrawalsHash
|
||||||
}
|
}
|
||||||
var parentBeaconRoot *common.Hash
|
var parentBeaconRoot *common.Hash
|
||||||
if sim.chainConfig.IsCancun(overrides.Number.ToInt(), (uint64)(*overrides.Time)) {
|
if sim.chainConfig.IsCancun(number, timestamp) {
|
||||||
parentBeaconRoot = &common.Hash{}
|
parentBeaconRoot = &common.Hash{}
|
||||||
if overrides.BeaconRoot != nil {
|
if overrides.BeaconRoot != nil {
|
||||||
parentBeaconRoot = overrides.BeaconRoot
|
parentBeaconRoot = overrides.BeaconRoot
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
difficulty := header.Difficulty
|
||||||
|
if isPostMerge(sim.chainConfig, number.Uint64(), timestamp) {
|
||||||
|
difficulty = big.NewInt(0)
|
||||||
|
}
|
||||||
header = overrides.MakeHeader(&types.Header{
|
header = overrides.MakeHeader(&types.Header{
|
||||||
UncleHash: types.EmptyUncleHash,
|
UncleHash: types.EmptyUncleHash,
|
||||||
ReceiptHash: types.EmptyReceiptsHash,
|
ReceiptHash: types.EmptyReceiptsHash,
|
||||||
TxHash: types.EmptyTxsHash,
|
TxHash: types.EmptyTxsHash,
|
||||||
Coinbase: header.Coinbase,
|
Coinbase: header.Coinbase,
|
||||||
Difficulty: header.Difficulty,
|
Difficulty: difficulty,
|
||||||
GasLimit: header.GasLimit,
|
GasLimit: header.GasLimit,
|
||||||
WithdrawalsHash: withdrawalsHash,
|
WithdrawalsHash: withdrawalsHash,
|
||||||
ParentBeaconRoot: parentBeaconRoot,
|
ParentBeaconRoot: parentBeaconRoot,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue