From 89de59b8ff95790c865ab91ca6ea356e8d51ac74 Mon Sep 17 00:00:00 2001 From: buddh0 Date: Wed, 4 Sep 2024 16:39:15 +0800 Subject: [PATCH] eth/protocols: add Withdrawals check before broadcastBloc --- eth/handler.go | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/eth/handler.go b/eth/handler.go index f65515166d..f26162024b 100644 --- a/eth/handler.go +++ b/eth/handler.go @@ -320,23 +320,12 @@ 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") + if propagate { + if !(block.Header().WithdrawalsHash == nil && block.Withdrawals() == nil) && + !(block.Header().EmptyWithdrawalsHash() && block.Withdrawals() != nil && len(block.Withdrawals()) == 0) { + log.Error("Propagated block has invalid withdrawals") 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) return