-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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] Coupling block sync to DAG state #3386
Draft
mdelle1
wants to merge
5
commits into
AleoNet:staging
Choose a base branch
from
ProvableHQ:fix/dag-syncing-2
base: staging
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
ff23fd6
Adds channel for committing leader certificates in bft
mdelle1 15a566b
Adds channel for recently committed certificates in bft
mdelle1 c19aff3
Adds to bft start handlers
mdelle1 bae2f49
Couples replicating DAG state to advancing with sync blocks
mdelle1 37a260c
Merge branch 'mainnet-staging' into fix/dag-syncing-2
raychu86 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -484,13 +484,46 @@ impl<N: Network> Sync<N> { | |
continue; | ||
} | ||
|
||
if let Authority::Quorum(subdag) = block.authority() { | ||
// Retrieve the leader certificate of the subdag. | ||
let leader_certificate = subdag.leader_certificate(); | ||
let leader_round = leader_certificate.round(); | ||
let leader_author = leader_certificate.author(); | ||
let leader_id = leader_certificate.id(); | ||
|
||
// If a BFT sender was provided, commit the leader certificate. | ||
if let Some(bft_sender) = self.bft_sender.get() { | ||
// Send the leader certificate to the BFT. | ||
if let Err(e) = bft_sender.send_commit_bft(leader_certificate.clone()).await { | ||
bail!("Sync - {e}"); | ||
}; | ||
|
||
// Ensure that leader certificate was recently committed in the DAG. | ||
match bft_sender.send_sync_is_recently_committed(leader_round, leader_id).await { | ||
Ok(is_recently_committed) => { | ||
if !is_recently_committed { | ||
bail!( | ||
"Sync - Failed to advance blocks - leader certificate with author {leader_author} from round {leader_round} was not recently committed.", | ||
); | ||
} | ||
debug!( | ||
"Sync - Leader certificate with author {leader_author} from round {leader_round} was recently committed.", | ||
); | ||
Comment on lines
+503
to
+511
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. Maybe a nit but the boolean can be moved into the match statement you get a compile warning if missing a branch and this has better readability IMO. i.e: Ok(true) => {
debug!("...");
}
Ok(false) => {
bail!("...");
}
// rest of cases |
||
} | ||
Err(e) => { | ||
bail!("Sync - Failed to check if leader certificate was recently committed - {e}"); | ||
} | ||
}; | ||
} | ||
} | ||
|
||
// Advance the ledger state. | ||
let self_ = self.clone(); | ||
tokio::task::spawn_blocking(move || { | ||
// Check the next block. | ||
self_.ledger.check_next_block(&block)?; | ||
// Attempt to advance to the next block. | ||
self_.ledger.advance_to_next_block(&block)?; | ||
|
||
// Sync the height with the block. | ||
self_.storage.sync_height_with_block(block.height()); | ||
// Sync the round with the block. | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
seems like a lot of hassle just to perform this one check (in its own task with a dedicated channel), especially with both the
BFT
andDag
being clonable 🤔... it does make it async, but do we expect therecent_committed_ids
collection to grow large enough to make it blocking?