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

netsync, main: use utreexo proof message to validate blocks #244

Merged

Conversation

kcalvinalvin
Copy link
Contributor

The utreexo proofs are no longer included in the block message. Instead, they're
separated out into their own message so the SyncManager needs to handle requesting
and handling both the block and the utreexo proof message.

In the changes made here, we keep track of the numLeaves from the utreexoHeaders and
we hold onto them as they're needed when constructing the GetUtreexoProof message.
Then we request the GetUtreexoProof message and request them while fetching the blocks
and add them to the blocks while processing the block messages.

We are now able keep track of the requestedUtreexoProofs per peer.
…nager

Because we need to have both the block and the utreexo proof in order to
validate a block as a CSN, we must be able to hold onto the proof or the
block until the other also arrives from the peer.

Having the queue maps allow us to do that.

The numLeaves allows us to keep track of leaves in memory from the
utreexo headers that we received. We need this to construct the get
utreexo proof message.
fetchHeaderBlocks

We now ask for utreexo proofs and keep track of numLeaves which are
needed for creating the GetUtreexoProofMsg.
Since the block will not have the utreexo proof attached to it, we need
to add the utreexo proof to the block message before we pass it off for
processing.
handleUtreexoProofMsg takes in the utreexo proof and just caches it
until the processor for the block picks it up and uses it during block
validation.

If the block already exists, then we send the block to the blockHandler
for it to be processed.
We send the utreexo proof to the SyncManager for processing now.
@kcalvinalvin kcalvinalvin merged commit 4b1efbd into utreexo:main Jan 21, 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