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

fix: fix the status marking problem of header sync #2857

Merged
merged 1 commit into from
Jul 23, 2021

Conversation

driftluo
Copy link
Collaborator

@driftluo driftluo commented Jul 22, 2021

There has always been a problem with the header sync protocol. When only the sync protocol is enabled, there may be a relatively large delay in obtaining the latest block. This is caused by incorrect state marking. This PR introduces a new state. Try to fix this problem.

The action of header sync is not completed at one time. It needs to be updated in real-time during the entire connection process. It cannot be considered that this node is always at the highest just because it is synchronized to the highest one time. That is to say, the completed state of sync should be dynamically converted to need sync again.

The TipSynced status indicates that this node has synchronized the headers and will try to synchronize again after 28s. At the same time, such a node can be used as the request object of Getblocks

Suspend and TipSynced are not exactly the same. Suspend thinks that the node may have some problems, such as being in the ibd state and suspending the sync request to it. Such a node cannot be used as the request object of the sync block, and it does not need to be based on the frequency of the block time to detection status

@driftluo driftluo requested a review from a team July 22, 2021 03:49
@driftluo driftluo force-pushed the fix-header-sync branch 2 times, most recently from 229a670 to 630a69b Compare July 22, 2021 04:13
sync/src/types/mod.rs Outdated Show resolved Hide resolved
sync/src/types/mod.rs Outdated Show resolved Hide resolved
sync/src/types/mod.rs Outdated Show resolved Hide resolved
@driftluo driftluo added the s:waiting-on-reviewers Status: Waiting for Review label Jul 23, 2021
@yangby-cryptape yangby-cryptape removed the s:waiting-on-reviewers Status: Waiting for Review label Jul 23, 2021
@driftluo
Copy link
Collaborator Author

bors r=quake,yangby-cryptape

@bors
Copy link
Contributor

bors bot commented Jul 23, 2021

Build succeeded:

@bors bors bot merged commit 2311e45 into nervosnetwork:develop Jul 23, 2021
@driftluo driftluo deleted the fix-header-sync branch July 30, 2021 12:20
bors bot added a commit that referenced this pull request Aug 2, 2021
2894: fix: there may be competition between header sync and eviction r=yangby-cryptape,quake a=driftluo

relation:#2857

The last PR left a problem. There may be a race condition between the two actions. Before reducing `n_sync_started`, we need to determine whether it is in the `Started` state. 

This PR will backport to 0.43 



Co-authored-by: driftluo <[email protected]>
@doitian doitian mentioned this pull request Aug 10, 2021
3 tasks
@doitian doitian mentioned this pull request Sep 3, 2021
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