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

spv: Fetch cfilters from multiple remote peers #2308

Merged
merged 2 commits into from
Nov 29, 2023

Conversation

matheusd
Copy link
Member

This modifies the cfilter fetching stage of the initial sync process to request cfilters from multiple peers instead of a single one.

This spreads the load across multiple peers, making the initial sync process (on average) slightly faster due to lower remote peer resource usage.

This modifies the initial cfilter fetching stage to use multiple peers
and to keep trying to fetch the cfilters even when the peer from which
headers were received disconnects.
This commits adds a watchdog timer to the initial cfilter fetching,
triggered when a batch takes too long to be successfully fetched.

In some situations, specially close to the tip, the sidechain forest may
be populated with one (or more) headers for which no cfilter is
available in the network.  In this situation, the syncer could end up in
a state where it does not advance due to waiting for cfilters that will
never be sent by any peers.

To alleviate this issue, a watchdog timer is started for every batch of
cfilters. If that timer is triggered, then the entire sidechain forest
is pruned, ensuring the next batch of headers that will be fetched will
be using fresh block locators and that the best chain selected for
fetching cfilters will be for these fresh headers.

The timer interval is set for 2 minutes, which given the stall timer of
30 seconds per peer means at least 4 peers will be searched for the
cfilters, before giving up and resetting the forest.
@jrick
Copy link
Member

jrick commented Nov 29, 2023

the watchdog commit looks like a prime candidate for context.WithoutTimeoutCause, where we define our special error, and check for that, instead of checking that the watchdog context errored but the outer context did not.

unfortunately, that would require go 1.21 as a minimum, so we can't use that yet.

@jrick jrick merged commit 66a3e69 into decred:master Nov 29, 2023
2 checks passed
@matheusd matheusd deleted the cfilters-from-multiple branch November 29, 2023 16:12
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.

2 participants