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(sync): address a couple suboptimalities #3099

Merged
merged 3 commits into from
Aug 7, 2020

Conversation

bowenwang1996
Copy link
Collaborator

A couple substandard issues that caused nodes to get stuck during sync:

  • In reset_data_pre_state_sync, we garbage collect all data up to sync block, but this makes no sense. Let's say we are just joining the network and the head is at genesis and the head of the network is more than 2 million blocks ahead. At this point, we don't actually have any data other than the headers that are just synced during header sync. However, in reset_data_pre_state_sync, we will go through all those 2 million heights, trying to garbage collect the data we just synced.
  • In check_state_needed, we always try to find the hashes of the blocks that we need to sync first, even if we do not need them and should sync state instead. This means that if we are at genesis and the network is 2 million blocks ahead of us, we will always walk through those 2 million blocks after head sync only to realize we don't need them and should just do state sync instead.

Test plan

Apply this patch on a betanet node that got stuck in syncing before and make sure that it syncs now.

@gitpod-io
Copy link

gitpod-io bot commented Aug 7, 2020

@bowenwang1996 bowenwang1996 requested a review from Kouprin August 7, 2020 04:04
@codecov
Copy link

codecov bot commented Aug 7, 2020

Codecov Report

Merging #3099 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #3099   +/-   ##
=======================================
  Coverage   87.65%   87.65%           
=======================================
  Files         212      212           
  Lines       41869    41869           
=======================================
  Hits        36702    36702           
  Misses       5167     5167           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c846cd1...116caed. Read the comment docs.

@bowenwang1996 bowenwang1996 merged commit 9ca3117 into master Aug 7, 2020
@bowenwang1996 bowenwang1996 deleted the fix-reset-data-pre-state-sync branch August 7, 2020 16:19
bowenwang1996 added a commit that referenced this pull request Aug 13, 2020
gc_sync_after_sync_* tests fail for the following reasons:
1) fork_tail is not properly maintained. A node resets fork tail after state sync but we allowed it to go back on epoch change.
2) in #3099 I didn't account for the fact that we can have chunk in storage whose height is higher than the current head.

Fixes #3133.

Test plan
----------
Run each of the gc_sync_after_sync_* tests 30 tests and observe that there is 0 failure.
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