Skip to content

Commit

Permalink
eth/protocols: add WithdrawalsHash check when handleNewBlock
Browse files Browse the repository at this point in the history
  • Loading branch information
buddh0 committed Sep 18, 2024
1 parent 8a50ea9 commit 8f61113
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 8f61113

Please sign in to comment.