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(l1): full-sync with both consensus and execution node #2081

Draft
wants to merge 4 commits into
base: fix/full-sync
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions crates/networking/p2p/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ impl SyncManager {
store.add_block_headers(block_hashes.clone(), block_headers)?;

if self.sync_mode == SyncMode::Full {
self.download_and_run_blocks(&mut block_hashes, store.clone())
self.download_and_run_blocks(&mut block_hashes, store.clone(), sync_head)
Copy link
Collaborator

Choose a reason for hiding this comment

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

maybe, instead of passing sync_head , you should filter block_hashes so that every block after sync_head is filtered out. Does this make sense?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes! Actually, my approach for some reason wasn't working. This is simpler and it is working in the server. I will update the PR later

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated!

.await?;
}

Expand Down Expand Up @@ -330,8 +330,10 @@ impl SyncManager {
&mut self,
block_hashes: &mut [BlockHash],
store: Store,
sync_head: H256,
) -> Result<(), SyncError> {
let mut last_valid_hash = H256::default();
let mut sync_head_reached = false;

let mut current_chunk_idx = 0;
let chunks: Vec<Vec<BlockHash>> = block_hashes
Expand Down Expand Up @@ -374,13 +376,18 @@ impl SyncManager {
self.invalid_ancestors.insert(hash, last_valid_hash);
return Err(error.into());
}
store.set_canonical_block(number, hash)?;
store.update_latest_block_number(number)?;
last_valid_hash = hash;
debug!(
"Executed and stored block number {} with hash {}",
number, hash
);
if !sync_head_reached {
store.set_canonical_block(number, hash)?;
store.update_latest_block_number(number)?;
last_valid_hash = hash;
}
if hash == sync_head {
sync_head_reached = true;
}
}
debug!("Executed & stored {} blocks", block_bodies_len);

Expand Down
Loading