-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
[dag] preliminary state sync implementation #9724
Conversation
85dd42d
to
918b442
Compare
Current dependencies on/for this PR:
This comment was auto-generated by Graphite. |
984b7a8
to
178b9f5
Compare
918b442
to
ac67202
Compare
178b9f5
to
2bcdbd4
Compare
ac67202
to
d4409ca
Compare
2bcdbd4
to
bc4d9ee
Compare
abf8a81
to
7071576
Compare
7071576
to
023b879
Compare
consensus/src/dag/types.rs
Outdated
@@ -418,6 +419,33 @@ impl TDAGMessage for CertifiedNode { | |||
} | |||
} | |||
|
|||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)] | |||
pub struct CertifiedNodeWithLedgerInfo { |
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.
the convention we have today is just to call it CertifiedNodeMessage
consensus/src/dag/dag_network.rs
Outdated
|
||
async fn send_epoch_change(&self, proof: EpochChangeProof); | ||
|
||
async fn send_commit_proof(&self, ledger_info: LedgerInfoWithSignatures); |
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.
I don't want to couple this two with network sender, this is more like self notifier. maybe another adapter trait?
consensus/src/dag/dag_state_sync.rs
Outdated
// Note: ledger info round <= highest ordered round | ||
if dag_reader.highest_committed_round().unwrap_or_default() | ||
< ledger_info.commit_info().round() | ||
&& dag_reader.exists_by_round_digest( |
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 need this existence check? if the round is between commit and order, it should always exist if we don't violate safety?
let commit_li = node.ledger_info(); | ||
|
||
// TODO: there is a case where DAG fetches missing nodes in window and a crash happens and when we restart, | ||
// we end up with a gap between the DAG and we need to be smart enough to clean up the DAG before the gap. |
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.
ideally we pass the ledger info in constructor and do the cleanup
consensus/src/dag/dag_state_sync.rs
Outdated
// Create a new DAG store and Fetch blocks | ||
let target_round = node.round(); | ||
let start_round = commit_li.commit_info().round().saturating_sub(DAG_WINDOW); | ||
let sync_dag_store = Arc::new(RwLock::new(Dag::new( |
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.
we probably need a different constructor for this, this'll re-construct the current dag from storage
consensus/src/dag/dag_state_sync.rs
Outdated
{ | ||
let mut dag_writer = sync_dag_store.write(); | ||
dag_writer.prune(); | ||
if let Some(node_status) = dag_writer.get_node_ref_mut_by_round_digest( |
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.
this is not enough, we need recursively marking all previous committed anchors in the window and all causal history
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.
discussed with @sasha8 on this, I think the best way is probably to read the events from block metadata that contains previous anchor information
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.
Also, it is not enough to mark only the anchor, we should mark all the causal history.
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.
Also, we are not persisting it. Won't this be a problem in recovery? Should we persist before calling state sync?
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.
We don't persist in normal path as well. I think db will give us the latest ledger info from which we can always get this info back even after recovery.
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.
But how will we know what nodes were already committed after recovery?
consensus/src/dag/dag_state_sync.rs
Outdated
} | ||
} | ||
|
||
if commit_li.ledger_info().ends_epoch() { |
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.
I think we can move this up and skip the syncing
consensus/src/dag/dag_state_sync.rs
Outdated
use itertools::Itertools; | ||
use std::sync::Arc; | ||
|
||
pub const DAG_WINDOW: u64 = 10; |
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.
we need to move this probably to order rule, since it affects whether a node is included in a commit
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.
I was thinking this should be onchain config.
consensus/src/dag/dag_state_sync.rs
Outdated
{ | ||
let mut dag_writer = sync_dag_store.write(); | ||
dag_writer.prune(); | ||
if let Some(node_status) = dag_writer.get_node_ref_mut_by_round_digest( |
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.
discussed with @sasha8 on this, I think the best way is probably to read the events from block metadata that contains previous anchor information
7e41139
to
3932158
Compare
3932158
to
fab0ad8
Compare
fab0ad8
to
6dd6796
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
✅ Forge suite
|
✅ Forge suite
|
✅ Forge suite
|
Description
This PR provides the preliminary implementation of state sync for the DAG. The integration part will be in another PR.
Test Plan
Unit test in following PR