-
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] Integrate dag fetcher with RB node handler #9585
Conversation
Current dependencies on/for this PR:
This comment was auto-generated by Graphite. |
consensus/src/dag/rb_handler.rs
Outdated
error!("request to fetch failed: {}", err); | ||
} | ||
bail!(NodeBroadcastHandleError::MissingParents); | ||
} |
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.
Why there are missing parents in this case?
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 merged this check with the below one. This one will miss the case when a node has all invalid parents.
956bfdb
to
d6fab23
Compare
716d377
to
59ba104
Compare
consensus/src/dag/rb_handler.rs
Outdated
let current_round = node.metadata().round(); | ||
|
||
// round 0 is a special case and does not require any parents | ||
if current_round == 0 { | ||
return Ok(()); | ||
bail!(NodeBroadcastHandleError::InvalidRound); |
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.
nit: we should start to carry more debug information into the errors, like exact round, missing parents id, why it's invalid etc
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.
Fixed this now. I will do a separate pass for improving the errors overall and start adding metric counters.
consensus/src/dag/rb_handler.rs
Outdated
NodeBroadcastHandleError::MissingParents | ||
); | ||
if prev_round >= dag_reader.lowest_round() { | ||
if let Err(err) = self.fetch_requester.request_for_node(node) { |
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 should at least unify this condition with the one below, it also doesn't look correct to me, maybe what you meant to check is prev_round > highest_round
?
previously the check is to filter out node that below lowest round, the error was misleading
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.
Good catch. I did not account for check inversion - I was doing ensure! before. But, I removed this condition and just use the one with missing parents check below. Previously I was not checking for signatures if none of the parents existed locally, but I should have.
d6fab23
to
1fbee40
Compare
59ba104
to
32fcb06
Compare
1fbee40
to
a444858
Compare
32fcb06
to
8b0a5d4
Compare
a444858
to
b6f8a6a
Compare
8b0a5d4
to
243f6be
Compare
b6f8a6a
to
609eae5
Compare
243f6be
to
5c9dd14
Compare
609eae5
to
e5b998b
Compare
5c9dd14
to
ea63e78
Compare
e5b998b
to
dd10cc2
Compare
ea63e78
to
cbd8f53
Compare
dd10cc2
to
7a0a66f
Compare
cbd8f53
to
ec7a202
Compare
7567419
to
39527bf
Compare
acbbad8
to
37d61fd
Compare
39527bf
to
bc49d3c
Compare
38e8f4a
to
c596a63
Compare
|
||
let dag_reader = self.dag.read(); | ||
// check if the parent round is missing in the DAG | ||
ensure!( |
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 still need to filter out the lower round right? otherwise we'd fetch all those nodes from gc'ed rounds
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.
That is a good point. I can send you a node from a very old round and force you to fetch if it is below the GC level. We should ignore nodes from rounds below the GC level.
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.
Yes, I needed the DAG store to support this minimum round to fix this.
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.
It's becoming hard to write unit tests without a verifier trait. I will follow-up to introduce that trait and then we can have more unit tests for this case. Added TODO for now.
@@ -92,18 +88,21 @@ impl NodeBroadcastHandler { | |||
.cloned() | |||
.collect(); | |||
if !missing_parents.is_empty() { | |||
// For each missing parent, verify their signatures and voting power | |||
// For each missing parent, verify their signatures and voting power. Otherwise, a malicious node can send | |||
// bad nodes with fake parents and cause this peer to issue unnecessary fetch requests. | |||
ensure!( | |||
missing_parents | |||
.iter() | |||
.all(|parent| { parent.verify(&self.epoch_state.verifier).is_ok() }), |
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.
Should this be in node.verify()?
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 to only verify the missing parents. Ideally, we won't miss any parents in the normal case and don't have to verify at all.
bc49d3c
to
eb5f074
Compare
94171db
to
781eec9
Compare
781eec9
to
72cf56d
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 integrates DAG fetcher to the RB node handler. Whenever the node is missing parents, the fetcher is requested to fetch those missing parents and their ancestors. To make sure the GCed DAG is not refetched, it changes the lowest_round in dag_store to provide the information.
Test Plan
Existing tests.