Skip to content

test: Cover block download from two peers - #108

Draft
pzafonte wants to merge 3 commits into
kernel-node:masterfrom
pzafonte:multi-peer-itest
Draft

pzafonte wants to merge 3 commits into
kernel-node:masterfrom
pzafonte:multi-peer-itest

Conversation

@pzafonte

Copy link
Copy Markdown
Collaborator

Currently, every integration test currently connects to a single peer, so blocks arrive in the order they were asked for and the shared download queue is never split between peers.

This adds three tests that give the node two peers holding the same chain, one for a plain sync, one for a reorg, and one for a peer going away partway through.

This is on top of #107

Blocks are fetched from a single peer, so the sync runs at the speed of
whichever peer was chosen and makes no progress while that peer is slow
or unresponsive.

Raise DEFAULT_MAX_PEERS from 1 to 8 and give the peers a shared
DownloadState holding the blocks left to fetch, the ones in flight, and
the ones already received. populate_download_queue fills it by walking
back from the best header to the active chain. A block is claimed by one
peer, and a peer that disconnects requeues whatever it still owes, so no
block is left unfetched.

Blocks now arrive out of order, so the block_buffer each peer kept in
AwaitingBlock moves into DownloadState and the validation thread drains
it. is_on_active_chain releases a block only once its parent has
connected, so the kernel sees each chain in order up to whatever has
connected so far. Once no peer has work left, the oldest buffered block
is sent regardless, since it belongs to a competing branch that will
never satisfy that check on its own.
Currently block download runs against whichever peers the address book
hands out, but connect names a single address and caps the node at one
peer, so there is no way to ask for several specific peers. On regtest,
where there are no DNS seeds, that makes a single peer the only
reachable setup.

Core takes its connect once per address, so joining repeated occurrences
keeps each one, and the node splits them apart and raises the peer cap
to how many were given. A single address behaves as before.

The addresses are read before the kernel starts, so a malformed one now
names the value that failed and exits rather than unwinding partway
through startup.
Every integration test currently connects to a single peer, so blocks
arrive in the order they were asked for and the shared download queue is
never split between peers.

Add three tests that give the node two peers holding the same chain, one
for a plain sync, one for a reorg, and one for a peer going away partway
through.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant