From 3b59e6e1af5396df27d23d2f546e40870248da7f Mon Sep 17 00:00:00 2001 From: buddh0 Date: Wed, 4 Sep 2024 16:39:15 +0800 Subject: [PATCH] eth/protocols: add WithdrawalsHash check when handleNewBlock --- eth/handler.go | 16 ---------------- eth/protocols/eth/handlers.go | 5 +++++ 2 files changed, 5 insertions(+), 16 deletions(-) diff --git a/eth/handler.go b/eth/handler.go index f65515166d..37486dd307 100644 --- a/eth/handler.go +++ b/eth/handler.go @@ -320,22 +320,6 @@ func newHandler(config *handlerConfig) (*handler, error) { } broadcastBlockWithCheck := func(block *types.Block, propagate bool) { - // All the block fetcher activities should be disabled - // after the transition. Print the warning log. - if h.merger.PoSFinalized() { - log.Warn("Unexpected validation activity", "hash", block.Hash(), "number", block.Number()) - return - } - // Reject all the PoS style headers in the first place. No matter - // the chain has finished the transition or not, the PoS headers - // should only come from the trusted consensus layer instead of - // p2p network. - if beacon, ok := h.chain.Engine().(*beacon.Beacon); ok { - if beacon.IsPoSHeader(block.Header()) { - log.Warn("unexpected post-merge header") - return - } - } if propagate { if err := core.IsDataAvailable(h.chain, block); err != nil { log.Error("Propagating block with invalid sidecars", "number", block.Number(), "hash", block.Hash(), "err", err) diff --git a/eth/protocols/eth/handlers.go b/eth/protocols/eth/handlers.go index 583dd2f67c..d44cfdeebc 100644 --- a/eth/protocols/eth/handlers.go +++ b/eth/protocols/eth/handlers.go @@ -321,6 +321,11 @@ func handleNewBlock(backend Backend, msg Decoder, peer *Peer) error { log.Warn("Propagated block has invalid body", "have", hash, "exp", ann.Block.TxHash()) return nil // TODO(karalabe): return error eventually, but wait a few releases } + if !(ann.Block.Header().WithdrawalsHash == nil && ann.Block.Withdrawals() == nil) && + !(ann.Block.Header().EmptyWithdrawalsHash() && len(ann.Block.Withdrawals()) == 0) { + return nil + } + ann.Block.ReceivedAt = msg.Time() ann.Block.ReceivedFrom = peer