From 3106cb143b75022266fa6d8f2fa5012295409673 Mon Sep 17 00:00:00 2001 From: Arpit Temani Date: Thu, 9 Nov 2023 18:09:39 +0530 Subject: [PATCH] Revert "change withdrawals hash" This reverts commit cd5a7d33913979fc18c129e8047416b7deab3c40. --- core/state_processor_test.go | 2 +- core/types/block.go | 7 ++++--- core/types/hashes.go | 2 +- core/vm/jump_table.go | 3 +-- eth/catalyst/api.go | 2 +- eth/downloader/queue.go | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/core/state_processor_test.go b/core/state_processor_test.go index bf57aa705d..fed9e18b0f 100644 --- a/core/state_processor_test.go +++ b/core/state_processor_test.go @@ -383,7 +383,7 @@ func GenerateBadBlock(parent *types.Block, engine consensus.Engine, txs types.Tr header.BaseFee = eip1559.CalcBaseFee(config, parent.Header()) } if config.IsShanghai(header.Number) { - header.WithdrawalsHash = nil + header.WithdrawalsHash = &types.EmptyWithdrawalsHash } var receipts []*types.Receipt diff --git a/core/types/block.go b/core/types/block.go index 3b143a2450..b3b8eea59d 100644 --- a/core/types/block.go +++ b/core/types/block.go @@ -176,7 +176,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 == nil + return h.TxHash == EmptyTxsHash && *h.WithdrawalsHash == EmptyWithdrawalsHash } return h.TxHash == EmptyTxsHash && h.UncleHash == EmptyUncleHash } @@ -323,7 +323,7 @@ func NewBlockWithWithdrawals(header *Header, txs []*Transaction, uncles []*Heade if withdrawals == nil { b.header.WithdrawalsHash = nil } else if len(withdrawals) == 0 { - b.header.WithdrawalsHash = nil + b.header.WithdrawalsHash = &EmptyWithdrawalsHash } else { h := DeriveSha(Withdrawals(withdrawals), hasher) b.header.WithdrawalsHash = &h @@ -353,7 +353,8 @@ func CopyHeader(h *Header) *Header { } if h.WithdrawalsHash != nil { - cpy.WithdrawalsHash = nil + cpy.WithdrawalsHash = new(common.Hash) + *cpy.WithdrawalsHash = *h.WithdrawalsHash } if h.ExcessBlobGas != nil { cpy.ExcessBlobGas = new(uint64) diff --git a/core/types/hashes.go b/core/types/hashes.go index 1c4f8e9ddc..3a787aa136 100644 --- a/core/types/hashes.go +++ b/core/types/hashes.go @@ -39,7 +39,7 @@ var ( EmptyReceiptsHash = common.HexToHash("56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421") // EmptyWithdrawalsHash is the known hash of the empty withdrawal set. - // EmptyWithdrawalsHash = common.HexToHash("56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421") + EmptyWithdrawalsHash = common.HexToHash("56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421") ) // TrieRootHash returns the hash itself if it's non-empty or the predefined diff --git a/core/vm/jump_table.go b/core/vm/jump_table.go index 72aa9fa858..f05c3a8a95 100644 --- a/core/vm/jump_table.go +++ b/core/vm/jump_table.go @@ -83,8 +83,7 @@ func validate(jt JumpTable) JumpTable { func newCancunInstructionSet() JumpTable { instructionSet := newShanghaiInstructionSet() - // Not included in bor's cancun fork - // enable4844(&instructionSet) // EIP-4844 (DATAHASH opcode) + enable4844(&instructionSet) // EIP-4844 (DATAHASH opcode) enable1153(&instructionSet) // EIP-1153 "Transient Storage" enable5656(&instructionSet) // EIP-5656 (MCOPY opcode) enable6780(&instructionSet) // EIP-6780 SELFDESTRUCT only in same transaction diff --git a/eth/catalyst/api.go b/eth/catalyst/api.go index b704fe7baa..0c122dca4b 100644 --- a/eth/catalyst/api.go +++ b/eth/catalyst/api.go @@ -793,7 +793,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().WithdrawalsHash != nil { - withdrawals = nil + withdrawals = make([]*types.Withdrawal, 0) } return &engine.ExecutionPayloadBodyV1{ diff --git a/eth/downloader/queue.go b/eth/downloader/queue.go index 2cc1099936..2dd9a0a694 100644 --- a/eth/downloader/queue.go +++ b/eth/downloader/queue.go @@ -78,7 +78,7 @@ func newFetchResult(header *types.Header, fastSync bool) *fetchResult { if !header.EmptyBody() { item.pending.Store(item.pending.Load() | (1 << bodyType)) } else if header.WithdrawalsHash != nil { - item.Withdrawals = nil + item.Withdrawals = make(types.Withdrawals, 0) } if fastSync && !header.EmptyReceipts() {