Skip to content

Commit

Permalink
eth/handler: check blobs before broadcast blocks (#2450)
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanBSC authored May 13, 2024
1 parent 691d195 commit 23f6194
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion eth/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,34 @@ func newHandler(config *handlerConfig) (*handler, error) {
}
return h.chain.InsertChain(blocks)
}
h.blockFetcher = fetcher.NewBlockFetcher(false, nil, h.chain.GetBlockByHash, validator, h.BroadcastBlock,

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)
return
}
}
h.BroadcastBlock(block, propagate)
}

h.blockFetcher = fetcher.NewBlockFetcher(false, nil, h.chain.GetBlockByHash, validator, broadcastBlockWithCheck,
heighter, finalizeHeighter, nil, inserter, h.removePeer)

fetchTx := func(peer string, hashes []common.Hash) error {
Expand Down

0 comments on commit 23f6194

Please sign in to comment.