From 3740eacb80caa8ee89c172980e57855db13a9de2 Mon Sep 17 00:00:00 2001 From: Manav Darji Date: Fri, 30 May 2025 20:58:32 +0530 Subject: [PATCH] core: set nil withdrawals during genesis init When initializing bor with a custom genesis, we used to set withdrawals and withdrawals hash to empty array and empty hash respectively. While we don't accept such values in bor cosnensus. Only nil values are allowed. This commit sets nil values for both. --- core/genesis.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/core/genesis.go b/core/genesis.go index adf778cbb0..1f4fab9fd6 100644 --- a/core/genesis.go +++ b/core/genesis.go @@ -518,15 +518,18 @@ func (g *Genesis) toBlockWithRoot(root common.Hash) *types.Block { head.BaseFee = new(big.Int).SetUint64(params.InitialBaseFee) } } - var ( - withdrawals []*types.Withdrawal - ) + + var withdrawals []*types.Withdrawal if conf := g.Config; conf != nil { num := big.NewInt(int64(g.Number)) - if conf.IsShanghai(num) { + + // Polygon/bor: EIP-4895 (withdrawals) not supported. Only set empty + // withdrawal hash if we're not using bor consensus (e.g. dev mode). + if conf.IsShanghai(num) && conf.Bor == nil { head.WithdrawalsHash = &types.EmptyWithdrawalsHash withdrawals = make([]*types.Withdrawal, 0) } + if conf.IsCancun(num) { // EIP-4788: The parentBeaconBlockRoot of the genesis block is always // the zero hash. This is because the genesis block does not have a parent @@ -543,7 +546,8 @@ func (g *Genesis) toBlockWithRoot(root common.Hash) *types.Block { } } - // Polygon/bor: EIP-7685 not supported + // Polygon/bor: EIP-7685 (requests) not supported. Only set empty + // withdrawal hash if we're not using bor consensus (e.g. dev mode). if conf.IsPrague(num) && conf.Bor == nil { head.RequestsHash = &types.EmptyRequestsHash }