Skip to content

Commit

Permalink
eth/protocols: add Withdrawals check before broadcastBloc
Browse files Browse the repository at this point in the history
  • Loading branch information
buddh0 committed Sep 18, 2024
1 parent d141ff0 commit 89de59b
Showing 1 changed file with 4 additions and 15 deletions.
19 changes: 4 additions & 15 deletions eth/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 89de59b

Please sign in to comment.