Skip to content

Commit e8c8df4

Browse files
MariusVanDerWijdenlightclient
authored andcommitted
core: set withdrawals hash in genesis, fix tests, add withdrawalRoot
1 parent 0f30e74 commit e8c8df4

File tree

6 files changed

+11
-4
lines changed

6 files changed

+11
-4
lines changed

core/genesis.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,9 @@ func (g *Genesis) ToBlock() *types.Block {
476476
head.BaseFee = new(big.Int).SetUint64(params.InitialBaseFee)
477477
}
478478
}
479+
if g.Config != nil && g.Config.IsShanghai(big.NewInt(int64(g.Timestamp))) {
480+
head.WithdrawalsHash = &types.EmptyRootHash
481+
}
479482
return types.NewBlock(head, nil, nil, nil, trie.NewStackTrie(nil))
480483
}
481484

eth/catalyst/api_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1001,7 +1001,7 @@ func TestSimultaneousNewBlock(t *testing.T) {
10011001
// includes zero withdrawals and the second includes two.
10021002
func TestWithdrawals(t *testing.T) {
10031003
genesis, blocks := generateMergeChain(10, true)
1004-
genesis.Config.ShanghaiBlock = big.NewInt(11)
1004+
genesis.Config.ShanghaiTime = big.NewInt(11)
10051005
genesis.Config.TerminalTotalDifficulty.Sub(genesis.Config.TerminalTotalDifficulty, blocks[0].Difficulty())
10061006

10071007
n, ethservice := startEthService(t, genesis, blocks)

eth/fetcher/block_fetcher_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ func init() {
6464
ArrowGlacierBlock: big.NewInt(0),
6565
GrayGlacierBlock: big.NewInt(0),
6666
MergeNetsplitBlock: big.NewInt(0),
67-
ShanghaiBlock: big.NewInt(0),
67+
ShanghaiTime: big.NewInt(0),
6868
TerminalTotalDifficulty: big.NewInt(0),
6969
TerminalTotalDifficultyPassed: true,
7070
Ethash: new(params.EthashConfig),

eth/protocols/eth/handler_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ func newTestBackendWithGenerator(blocks int, shanghai bool, generator func(int,
9090
ArrowGlacierBlock: big.NewInt(0),
9191
GrayGlacierBlock: big.NewInt(0),
9292
MergeNetsplitBlock: big.NewInt(0),
93-
ShanghaiBlock: big.NewInt(0),
93+
ShanghaiTime: big.NewInt(0),
9494
TerminalTotalDifficulty: big.NewInt(0),
9595
TerminalTotalDifficultyPassed: true,
9696
Ethash: new(params.EthashConfig),

internal/ethapi/api.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1208,6 +1208,10 @@ func RPCMarshalHeader(head *types.Header) map[string]interface{} {
12081208
result["baseFeePerGas"] = (*hexutil.Big)(head.BaseFee)
12091209
}
12101210

1211+
if head.WithdrawalsHash != nil {
1212+
result["withdrawalsRoot"] = head.WithdrawalsHash
1213+
}
1214+
12111215
return result
12121216
}
12131217

tests/init.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ var Forks = map[string]*params.ChainConfig{
246246
ArrowGlacierBlock: big.NewInt(0),
247247
MergeNetsplitBlock: big.NewInt(0),
248248
TerminalTotalDifficulty: big.NewInt(0),
249-
ShanghaiBlock: big.NewInt(0),
249+
ShanghaiTime: big.NewInt(0),
250250
},
251251
}
252252

0 commit comments

Comments
 (0)