-
Notifications
You must be signed in to change notification settings - Fork 124
fix(l1): always use fullsync if db had data #5196
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -45,7 +45,7 @@ use tokio_util::sync::CancellationToken; | |
| use tracing::{debug, error, info, warn}; | ||
|
|
||
| /// The minimum amount of blocks from the head that we want to full sync during a snap sync | ||
| const MIN_FULL_BLOCKS: usize = 64; | ||
| const MIN_FULL_BLOCKS: u64 = 10_000; | ||
| /// Amount of blocks to execute in a single batch during FullSync | ||
| const EXECUTE_BATCH_SIZE_DEFAULT: usize = 1024; | ||
| /// Amount of seconds between blocks | ||
|
|
@@ -285,17 +285,16 @@ impl Syncer { | |
| current_head = last_block_hash; | ||
| current_head_number = last_block_number; | ||
|
|
||
| // If the sync head is less than 64 blocks away from our current head switch to full-sync | ||
| if sync_head_found { | ||
| let latest_block_number = store.get_latest_block_number().await?; | ||
| if last_block_number.saturating_sub(latest_block_number) < MIN_FULL_BLOCKS as u64 { | ||
| // Too few blocks for a snap sync, switching to full sync | ||
| debug!( | ||
| "Sync head is less than {MIN_FULL_BLOCKS} blocks away, switching to FullSync" | ||
| ); | ||
| self.snap_enabled.store(false, Ordering::Relaxed); | ||
| return self.sync_cycle_full(sync_head, store.clone()).await; | ||
| } | ||
| // If the sync head is not 0 we search to fullsync | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IMO, if the sync head is 0 pero is less than X blocks away, we should also not do snap sync. Snap sync is for 1M blocks distance, not 100.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done in e4dc36d |
||
| let head_found = sync_head_found && store.get_latest_block_number().await? > 0; | ||
| // Or the head is very close to 0 | ||
| let head_close_to_0 = last_block_number < MIN_FULL_BLOCKS; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Edit: this skips snap-syncing when the sync-head's block number is less than 10000 |
||
|
|
||
| if head_found || head_close_to_0 { | ||
| // Too few blocks for a snap sync, switching to full sync | ||
| info!("Sync head is found, switching to FullSync"); | ||
| self.snap_enabled.store(false, Ordering::Relaxed); | ||
| return self.sync_cycle_full(sync_head, store.clone()).await; | ||
| } | ||
|
|
||
| // Discard the first header as we already have it | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have to revert #4985 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Testing in 636a594