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 f547fb7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 16 deletions.
16 changes: 0 additions & 16 deletions eth/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 6 additions & 0 deletions eth/protocols/eth/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,12 @@ 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) {
log.Warn("Propagated block has invalid body, WithdrawalsHash and Withdrawals mismatch")
return nil
}

ann.Block.ReceivedAt = msg.Time()
ann.Block.ReceivedFrom = peer

Expand Down

0 comments on commit f547fb7

Please sign in to comment.