Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

blockchain, netsync: no more headers-first list #249

Merged

Conversation

kcalvinalvin
Copy link
Contributor

Since we now accept headers for new block announcements, it's impossible to distinguish between
new block announcements and headers received from ibd in the same code block.

We change the code to rely on ProcessBlockHeader for block header connection and for figuring out
best chain selection instead of a strict "does this blockheader connect to the previous one".

This avoids errors that happens during ibd where a block header is rejected and a peer is banned because
of new header announcements that fail to connect as the node does not have the entire chain of headers yet.

Just like ProcessBlock, ProcessBlockHeader now takes in behavior flags
which allow it to skip parts of header validation for when the chain is
still behind the checkpoints.
We add a chainview of bestHeaders so that we'll be able to keep track of
headers separately from the bestChain. This is needed as we're getting
headers for new block annoucements instead of invs.
maybeAcceptBlockHeader was missing the chain selection logic that would
be needed for handling block annoucements for ones that don't extend the
current chain tip.

It's now able to determine if a block header extends the chain tip or
not and returns a boolean indicating if the given header is on the
best chain of headers.
ProcessBlockHeader now returns the isMainChain boolean from
maybeAcceptBlockHeader, essentially turning the function into a
concurrency safe wrapper around maybeAcceptBlockHeader.
The added exported methods on BlockChain provide access to the block
header tip like fetching block hashes and heights from the headers
chain.
@kcalvinalvin kcalvinalvin force-pushed the 2025-01-21-no-more-headerlist branch 3 times, most recently from 13d7723 to 886830a Compare February 2, 2025 06:29
the next blocks to download.

Instead of having a duplicate list that is separately kept track of, we
use the info from blockchain to calculate which blocks we need to
download next.
@kcalvinalvin kcalvinalvin force-pushed the 2025-01-21-no-more-headerlist branch from 886830a to 52dcefd Compare February 2, 2025 07:58
@kcalvinalvin kcalvinalvin merged commit dd90e1b into utreexo:main Feb 2, 2025
2 checks passed
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