Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Fixed sync skipping some block announcements #8459

Merged
merged 2 commits into from
Mar 31, 2021
Merged

Fixed sync skipping some block announcements #8459

merged 2 commits into from
Mar 31, 2021

Conversation

arkpar
Copy link
Member

@arkpar arkpar commented Mar 25, 2021

In rare cases a block announcement would be ignored if a peers that sends has an outstanding block request. This PR fixes this by adding all announcement to fork targets.

@arkpar arkpar requested a review from bkchr March 25, 2021 17:18
@github-actions github-actions bot added the A0-please_review Pull request needs code review. label Mar 25, 2021
@arkpar arkpar added A1-needs_burnin Pull request needs to be tested on a live validator node before merge. DevOps is notified via matrix B0-silent Changes should not be mentioned in any release notes C1-low PR touches the given topic and has a low impact on builders. labels Mar 25, 2021
@arkpar arkpar requested review from tomaka and rphmeier March 25, 2021 17:33
client/network/test/src/sync.rs Outdated Show resolved Hide resolved
@@ -507,7 +507,7 @@ impl<B: BlockT> ChainSync<B> {

/// Number of active sync requests.
pub fn num_sync_requests(&self) -> usize {
self.fork_targets.len()
self.fork_targets.values().filter(|f| f.number <= self.best_queued_number).count()
Copy link
Member

Choose a reason for hiding this comment

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

Why do we need to filter here?

Copy link
Member Author

Choose a reason for hiding this comment

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

This function is used in tests to detect when there's no activity (block_unti_idle). Since now fork_targets might contain some future blocks, that are not requested until we reach that block number it will stall tests. Basically only forks that can be requested are considered as active.

Copy link
Member

Choose a reason for hiding this comment

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

Ahh okay, ty. Maybe we should add some comment to the function to explain this :D

hash,
announce.summary(),
);
self.fork_targets
Copy link
Member

Choose a reason for hiding this comment

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

So, the problem was that we only synced forks if the block number was below our best number?

Copy link
Member Author

Choose a reason for hiding this comment

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

If the block was below best, sync assumed it will be downloaded by simply advancing from peers common number. fork_targets was intended for old forks that are behind our current best block, but it is clear now this mechanism should be used for parallel current forks as well.

arkpar added a commit to paritytech/polkadot that referenced this pull request Mar 25, 2021
arkpar added a commit to paritytech/polkadot that referenced this pull request Mar 25, 2021
@arkpar
Copy link
Member Author

arkpar commented Mar 27, 2021

No issues revealed in burn-in

client/network/src/protocol/sync.rs Outdated Show resolved Hide resolved
client/network/src/protocol/sync.rs Outdated Show resolved Hide resolved
client/network/src/protocol/sync.rs Outdated Show resolved Hide resolved
Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com>
@arkpar arkpar merged commit 753187e into master Mar 31, 2021
@arkpar arkpar deleted the a-sync-fix branch March 31, 2021 21:02
bkchr pushed a commit that referenced this pull request Apr 3, 2021
* Fixed sync missing some block announcements

* Apply suggestions from code review

Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com>

Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com>
hirschenberger pushed a commit to hirschenberger/substrate that referenced this pull request Apr 14, 2021
* Fixed sync missing some block announcements

* Apply suggestions from code review

Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com>

Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com>
jordy25519 pushed a commit to cennznet/substrate that referenced this pull request Sep 17, 2021
* Fixed sync missing some block announcements

* Apply suggestions from code review

Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com>

Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A0-please_review Pull request needs code review. A1-needs_burnin Pull request needs to be tested on a live validator node before merge. DevOps is notified via matrix B0-silent Changes should not be mentioned in any release notes C1-low PR touches the given topic and has a low impact on builders.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants