diff --git a/consensus/parlia/parlia.go b/consensus/parlia/parlia.go index acf0f3b7b..9b07fd9bb 100644 --- a/consensus/parlia/parlia.go +++ b/consensus/parlia/parlia.go @@ -600,8 +600,8 @@ func (p *Parlia) verifyHeader(chain consensus.ChainHeaderReader, header *types.H case header.ParentBeaconRoot != nil: return fmt.Errorf("invalid parentBeaconRoot, have %#x, expected nil", header.ParentBeaconRoot) // types.EmptyWithdrawalsHash represents a empty value when EIP-4895 enabled, - // here, EIP-4895 still be disabled, value expected to be `common.Hash{}` is only to feet the demand of rlp encode/decode - case header.WithdrawalsHash == nil || *header.WithdrawalsHash != common.Hash{}: + // here, EIP-4895 still be disabled, value expected to be `types.EmptyWithdrawalsHash` is only to feet the demand of rlp encode/decode + case header.WithdrawalsHash == nil || *header.WithdrawalsHash != types.EmptyWithdrawalsHash: return errors.New("header has wrong WithdrawalsHash") } if err := eip4844.VerifyEIP4844Header(parent, header); err != nil { diff --git a/core/chain_makers.go b/core/chain_makers.go index 544b8d33f..e3cf61dc6 100644 --- a/core/chain_makers.go +++ b/core/chain_makers.go @@ -481,7 +481,7 @@ func (cm *chainMaker) makeHeader(parent *types.Block, state *state.StateDB, engi header.ExcessBlobGas = &excessBlobGas header.BlobGasUsed = new(uint64) if cm.config.Parlia != nil { - header.WithdrawalsHash = new(common.Hash) + header.WithdrawalsHash = &types.EmptyWithdrawalsHash } if cm.config.Parlia == nil { header.ParentBeaconRoot = new(common.Hash) diff --git a/core/genesis.go b/core/genesis.go index 09f9c6757..6aa76d108 100644 --- a/core/genesis.go +++ b/core/genesis.go @@ -446,7 +446,7 @@ func (g *Genesis) ToBlock() *types.Block { } if conf.IsCancun(num, g.Timestamp) { if conf.Parlia != nil { - head.WithdrawalsHash = new(common.Hash) + head.WithdrawalsHash = &types.EmptyWithdrawalsHash } // EIP-4788: The parentBeaconBlockRoot of the genesis block is always diff --git a/core/types/block.go b/core/types/block.go index d088a5e4c..e947792c1 100644 --- a/core/types/block.go +++ b/core/types/block.go @@ -183,7 +183,7 @@ func (h *Header) SanityCheck() error { // that is: no transactions, no uncles and no withdrawals. func (h *Header) EmptyBody() bool { if h.WithdrawalsHash != nil { - return h.TxHash == EmptyTxsHash && (*h.WithdrawalsHash == EmptyWithdrawalsHash || *h.WithdrawalsHash == common.Hash{}) + return h.TxHash == EmptyTxsHash && *h.WithdrawalsHash == EmptyWithdrawalsHash } return h.TxHash == EmptyTxsHash && h.UncleHash == EmptyUncleHash } @@ -195,8 +195,7 @@ func (h *Header) EmptyReceipts() bool { // EmptyWithdrawalsHash returns true if there are no WithdrawalsHash for this header/block. func (h *Header) EmptyWithdrawalsHash() bool { - // TODO(GalaIO): if check EmptyWithdrawalsHash in here? - return h.WithdrawalsHash == nil || *h.WithdrawalsHash == common.Hash{} + return h.WithdrawalsHash == nil || *h.WithdrawalsHash == EmptyWithdrawalsHash } // Body is a simple (mutable, non-safe) data container for storing and moving diff --git a/eth/catalyst/api.go b/eth/catalyst/api.go index 480eb03a5..1cd8c51b2 100644 --- a/eth/catalyst/api.go +++ b/eth/catalyst/api.go @@ -874,7 +874,7 @@ func getBody(block *types.Block) *engine.ExecutionPayloadBodyV1 { } // Post-shanghai withdrawals MUST be set to empty slice instead of nil - if withdrawals == nil && !block.Header().EmptyWithdrawalsHash() { + if withdrawals == nil && block.Header().WithdrawalsHash != nil { withdrawals = make([]*types.Withdrawal, 0) } diff --git a/graphql/graphql.go b/graphql/graphql.go index 0fccfa74f..cf4d7a34c 100644 --- a/graphql/graphql.go +++ b/graphql/graphql.go @@ -1041,7 +1041,7 @@ func (b *Block) WithdrawalsRoot(ctx context.Context) (*common.Hash, error) { return nil, err } // Pre-shanghai blocks - if header.EmptyWithdrawalsHash() { + if header.WithdrawalsHash == nil { return nil, nil } return header.WithdrawalsHash, nil diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go index a1b132b9c..fc46f6591 100644 --- a/internal/ethapi/api.go +++ b/internal/ethapi/api.go @@ -1517,7 +1517,7 @@ func RPCMarshalHeader(head *types.Header) map[string]interface{} { if head.BaseFee != nil { result["baseFeePerGas"] = (*hexutil.Big)(head.BaseFee) } - if !head.EmptyWithdrawalsHash() { + if head.WithdrawalsHash != nil { result["withdrawalsRoot"] = head.WithdrawalsHash } if head.BlobGasUsed != nil { @@ -1561,7 +1561,7 @@ func RPCMarshalBlock(block *types.Block, inclTx bool, fullTx bool, config *param uncleHashes[i] = uncle.Hash() } fields["uncles"] = uncleHashes - if !block.Header().EmptyWithdrawalsHash() { + if block.Header().WithdrawalsHash != nil { fields["withdrawals"] = block.Withdrawals() } return fields diff --git a/miner/worker.go b/miner/worker.go index f92d8c80b..cdd47e2bc 100644 --- a/miner/worker.go +++ b/miner/worker.go @@ -1014,7 +1014,7 @@ func (w *worker) prepareWork(genParams *generateParams) (*environment, error) { header.BlobGasUsed = new(uint64) header.ExcessBlobGas = &excessBlobGas if w.chainConfig.Parlia != nil { - header.WithdrawalsHash = new(common.Hash) + header.WithdrawalsHash = &types.EmptyWithdrawalsHash } if w.chainConfig.Parlia == nil { header.ParentBeaconRoot = genParams.beaconRoot