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: Track peer for requested blocks. #3444

Merged
merged 2 commits into from
Sep 12, 2024

Conversation

davecgh
Copy link
Member

@davecgh davecgh commented Sep 10, 2024

This is rebased on #3443.

This modifies the map that tracks requests for blocks to keep track of which peer the block was requested from. This is currently not used since blocks are only downloaded from a single sync peer, but it helps pave the way to handling downloading blocks from multiple peers in parallel.


This is work towards #1145.

@davecgh davecgh added this to the 2.1.0 milestone Sep 10, 2024
@davecgh davecgh mentioned this pull request Sep 10, 2024
33 tasks
This reworks the net sync manager block announcement handling to keep
track of the best known block announced by each peer as determined by
having the most cumulative proof of work.

The primary motivation is to provide a relatively efficient mechanism to
discover which blocks are available to download from each peer to
eventually support downloading multiple blocks in parallel.

It also doubles to increase robustness of best height reporting of each
peer once the initial headers sync process is complete since the values
are only updated when the header has more cumulative proof of work
versus simply having a larger height since, although exceedingly rare in
practice, it is possible for a chain with fewer blocks to have more
cumulative work.
This modifies the map that tracks requests for blocks to keep track of
which peer the block was requested from.  This is currently not used
since blocks are only downloaded from a single sync peer, but it helps
pave the way to handling downloading blocks from multiple peers in
parallel.
@davecgh davecgh force-pushed the netsync_track_requested_from_peer branch from c860387 to d2e603b Compare September 11, 2024 03:28
continue
}

// Stop requesting when the request would exceed the max size of the
// map used to track requests.
if len(m.requestedBlocks)+1 > maxRequestedBlocks {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just highlighting that this is a change in behavior. Previously limitAdd would enforce limits onto m.requestedBlocks and peer.requestedBlocks separately, but with the new code peer.requestedBlocks is not being limited.

Copy link
Member Author

@davecgh davecgh Sep 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed. I probably should've called this out in the description, but I changed it because the two maps really need to stay in sync. Otherwise, peers can be hit with misbehavior if expected entries are not in one map or the other.

It's currently not an issue because it's impossible to hit the limiting cases of limitAdd since there is a single sync peer and there are never more outstanding requests than maxInFlightBlocks = 16.

@jholdstock
Copy link
Member

jholdstock commented Sep 11, 2024

Seperately from this PR, limitAdd doesnt look like it works properly because it doesnt check for existing elements before deleting.

e.g. ["A", "B", "C"].limitAdd("A", 3) could choose to remove "B" then re-add "A", meaning "B" is lost unnecessarily.

Opened #3445 to look at this further.

@davecgh
Copy link
Member Author

davecgh commented Sep 11, 2024

Seperately from this PR, limitAdd doesnt look like it works properly because it doesnt check for existing elements before deleting.

Discussed in the other PR.

@davecgh davecgh merged commit d2e603b into decred:master Sep 12, 2024
2 checks passed
@davecgh davecgh deleted the netsync_track_requested_from_peer branch September 12, 2024 22:49
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.

3 participants