feat(l1): parallel body download from multiple peers#6490
Conversation
Split block body requests into chunks of MAX_BLOCK_BODIES_TO_REQUEST and dispatch each chunk to a different peer in parallel using tokio::spawn, following the same channel-based pattern used by the existing parallel header download. Failed chunks are automatically re-queued and retried with other peers, and partial responses are handled by re-queuing the remainder. This replaces the sequential loop that sent 128-block requests to one peer at a time, significantly improving body download throughput when multiple peers are available.
🤖 Codex Code Review
I did not spot any EVM/gas/consensus-rule changes in this PR beyond the sync transport path. I did not run tests locally. Automated review by OpenAI Codex · gpt-5.4 · custom prompt |
🤖 Claude Code ReviewNow I have a complete picture. Here is my review: PR Review: feat(p2p): parallel body download from multiple peersOverviewThis PR replaces the sequential body download loop in Critical Bug: Partial-result ordering is brokenFile: When a peer returns fewer bodies than requested, the remainder is pushed to a new slot appended to the end of let new_idx = results.len(); // always at the tail
results.push(None);
tasks_queue.push_back((new_idx, remaining_headers));The final reassembly iterates for slot in results {
all_bodies.extend(bodies);
}So the remainder of chunk
The Fix: track a No retry limit — potential infinite loopFile: The sequential
|
Lines of code reportTotal lines added: Detailed view |
…wnload # Conflicts: # crates/networking/p2p/peer_handler.rs
Summary
request_block_bodies_parallel()toPeerHandlerthat splits headers into 128-block chunks and dispatches each to a different peer viatokio::spawndownload_bodies_from_peer()helper for single-peer body fetch within spawned taskssync_cycle_fullwith the parallel versionCloses #6481
Test plan
FULL_SYNC_BLOCK_LIMIT=50000and verify bodies download correctly