Repository navigation
net: Hand blocks to the kernel as they arrive - #119
Merged
Merged
Conversation
Nothing in the suite forces a block to arrive before its parent. A scripted peer answers each getdata in reverse. It does its own handshake because the p2p crate sends verack only after receiving one.
Any block handed to the kernel reset the check, even one that left the tip stuck. Core's TipMayBeStale also measures from the last tip change.
Blocks waited in memory until their parent connected, with no limit. The kernel stores a block whose parent is missing and switches branches on its own. When the one-block channel is full, the peer thread stops reading its socket, as Core does for a peer past 5 MB. After a restart, stored blocks that haven't connected are fetched again because the kernel API can't say which it has.
pzafonte
force-pushed
the
process-on-arrival
branch
from
November 9, 2026 14:30
44b2961 to
ae612a3
Compare
rustaceanrob
approved these changes
Nov 11, 2026
rustaceanrob
left a comment
Contributor
There was a problem hiding this comment.
Looks good. Did IBD before and after this change with no observable difference in behavior. We do have some stuttering behavior where the logs look like they look up and then proceed in bursts. Perhaps we could add some more network level logging when we receive blocks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This fixes something that confused me initially. I had mixed up the node handing blocks over in order with the kernel needing them that way.
Blocks wait in memory until their parent connects, with no limit. If one peer holds the block the tip needs, everything the other peers download after it sits in RAM.
process_blocksetsforce_processing, which stores a block whose parent is missing and connects it when it can. This hands each block over as it arrives, through a one-block channel, and drops the buffer. When the channel is full the peer thread stops reading, like Core does for a peer past 5 MB.With waiting blocks on disk, a download window can be Core's 1024 blocks instead of whatever fits in memory, and the window and stall handling can follow Core's behavior directly.
Because blocks arriving ahead of a missing one would keep resetting the stale check, it resets only when the tip moves. The new test forces a block to arrive before its parent. It passes before and after the change.
Blocks already handed over aren't requested again, except after a restart, because the kernel API can't say which blocks it has.