-
Notifications
You must be signed in to change notification settings - Fork 31
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
refactor(consensus): minor refactor of the manager #208
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. Join @matan-starkware and the rest of your teammates on Graphite |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #208 +/- ##
==========================================
- Coverage 76.89% 76.84% -0.05%
==========================================
Files 316 316
Lines 34504 34550 +46
Branches 34504 34550 +46
==========================================
+ Hits 26532 26551 +19
- Misses 5687 5708 +21
- Partials 2285 2291 +6 ☔ View full report in Codecov by Sentry. |
cf37628
to
f55d15e
Compare
7901f10
to
abab918
Compare
f55d15e
to
b178c8e
Compare
abab918
to
ebe634e
Compare
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.
Reviewed 3 of 3 files at r1, all commit messages.
Reviewable status: complete! all files reviewed, all discussions resolved (waiting on @ShahakShama)
b178c8e
to
f06ec08
Compare
ebe634e
to
884a740
Compare
f06ec08
to
00833b3
Compare
884a740
to
eb71c2a
Compare
00833b3
to
3e510b3
Compare
eb71c2a
to
3db8a0c
Compare
3e510b3
to
2787166
Compare
3db8a0c
to
91452bf
Compare
2787166
to
f3c4fd1
Compare
91452bf
to
aef0f05
Compare
f3c4fd1
to
b143026
Compare
aef0f05
to
b58b015
Compare
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.
Reviewed 1 of 1 files at r2, all commit messages.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @matan-starkware)
crates/sequencing/papyrus_consensus/src/manager.rs
line 81 at r2 (raw file):
// TODO(matan): We need to figure out an actual cacheing strategy under 2 constraints: // 1. Malicious - must be capped so a malicious peer can't DoS us.
DoS -> DDoS
crates/sequencing/papyrus_consensus/src/manager.rs
line 115 at r2 (raw file):
fn get_current_height_messages(&mut self, height: BlockNumber) -> Vec<ConsensusMessage> { let mut current_height_messages = Vec::new(); for msg in std::mem::take(&mut self.cached_messages) {
Try to remove just the problematic messages, instead of recreating the entire vector.
Plus, consider using a different data structure (maybe HashSet, or HashMap between height and a vector of ConsensusMessages and then finding all of them is much easier)
crates/sequencing/papyrus_consensus/src/manager.rs
line 117 at r2 (raw file):
for msg in std::mem::take(&mut self.cached_messages) { match height.0.cmp(&msg.height()) { std::cmp::Ordering::Less => self.cached_messages.push(msg),
IDK why, but logically it makes more sense to put msg.height() in the left of the comparison. I guess it's because it changs this arm into Greater, which means you're saying "This message is higher than the current height", which makes more sense since the current height is constant during this entire function and what's changing is msg
crates/sequencing/papyrus_consensus/src/types.rs
line 167 at r2 (raw file):
Canceled(#[from] oneshot::Canceled), #[error(transparent)] ProtobufConversionError(#[from] ProtobufConversionError),
This should be handled by reporting the relevant peer and then continuing on (maybe voting nil on the proposal if the sending peer is the proposer). For now put a TODO to handle this error internally
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.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @ShahakShama)
crates/sequencing/papyrus_consensus/src/manager.rs
line 81 at r2 (raw file):
Previously, ShahakShama wrote…
DoS -> DDoS
Why? A single malicious node could potentially send me so many messages that I OOM. There is no need for this to be a distributed attack.
crates/sequencing/papyrus_consensus/src/manager.rs
line 115 at r2 (raw file):
Previously, ShahakShama wrote…
Try to remove just the problematic messages, instead of recreating the entire vector.
Plus, consider using a different data structure (maybe HashSet, or HashMap between height and a vector of ConsensusMessages and then finding all of them is much easier)
I intentionally went for a simple solution here (with Dan't support). I am not trying to optimize this since we know that this is not the final solution. This is just a solution for the sake of our early simulations. I'd rather just wait till we implement the real solution which is still under debate.
crates/sequencing/papyrus_consensus/src/manager.rs
line 117 at r2 (raw file):
Previously, ShahakShama wrote…
IDK why, but logically it makes more sense to put msg.height() in the left of the comparison. I guess it's because it changs this arm into Greater, which means you're saying "This message is higher than the current height", which makes more sense since the current height is constant during this entire function and what's changing is msg
Done.
crates/sequencing/papyrus_consensus/src/types.rs
line 167 at r2 (raw file):
Previously, ShahakShama wrote…
This should be handled by reporting the relevant peer and then continuing on (maybe voting nil on the proposal if the sending peer is the proposer). For now put a TODO to handle this error internally
Reviewable isn't highlighting, but I presume you are talking about InvalidProposal
? If so you are basically describing the current milestone that Asmaa just wrote (code is already under review with me). I'll just leave this alone then, ok?
b143026
to
0ce80cd
Compare
b58b015
to
5c9631d
Compare
afcfd46
to
dd1cdfa
Compare
422a210
to
043a3d9
Compare
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.
Reviewed 3 of 5 files at r3, 3 of 3 files at r4, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @matan-starkware)
crates/sequencing/papyrus_consensus/src/manager.rs
line 115 at r2 (raw file):
Previously, matan-starkware wrote…
I intentionally went for a simple solution here (with Dan't support). I am not trying to optimize this since we know that this is not the final solution. This is just a solution for the sake of our early simulations. I'd rather just wait till we implement the real solution which is still under debate.
But my suggestion is as simple as your suggestion.
Unblocking for now, but I think it's worth doing this change or at least putting a TODO
crates/sequencing/papyrus_consensus/src/types.rs
line 167 at r2 (raw file):
Previously, matan-starkware wrote…
Reviewable isn't highlighting, but I presume you are talking about
InvalidProposal
? If so you are basically describing the current milestone that Asmaa just wrote (code is already under review with me). I'll just leave this alone then, ok?
No, I'm talking about ProtobufConversionError, but I guess the same applies for InvalidProposal
You can leave this alone if you want
dd1cdfa
to
0321499
Compare
7a1ee5e
to
7e69e4d
Compare
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.
Reviewable status: 1 of 5 files reviewed, 1 unresolved discussion (waiting on @ShahakShama)
crates/sequencing/papyrus_consensus/src/manager.rs
line 115 at r2 (raw file):
Previously, ShahakShama wrote…
But my suggestion is as simple as your suggestion.
Unblocking for now, but I think it's worth doing this change or at least putting a TODO
Took your map suggestion
crates/sequencing/papyrus_consensus/src/types.rs
line 167 at r2 (raw file):
Previously, ShahakShama wrote…
No, I'm talking about ProtobufConversionError, but I guess the same applies for InvalidProposal
You can leave this alone if you want
I can't do anything with a protobuf conversion error (besides ReportSender to network). IDK if this is a proposal or a prevote, idk what height this is for, idk who sent it. Consensus proper must ignore.
I'll update the manager though to use report sender and add a TODO since at some point we will want the SHC to also start reporting errors.
7e69e4d
to
1bcc292
Compare
09c5e8f
to
5736f92
Compare
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.
Reviewed 1 of 4 files at r5, 1 of 1 files at r6, all commit messages.
Reviewable status: 3 of 5 files reviewed, 1 unresolved discussion (waiting on @matan-starkware and @ShahakShama)
crates/sequencing/papyrus_consensus/src/manager.rs
line 82 at r6 (raw file):
self.cached_messages .entry(message.height()) .or_insert(Vec::new())
.or_default()
Code quote:
.or_insert(Vec::new())
1. Separate fn for handling cached messages per height 2. Return errors instead of panic when receiving messages
5736f92
to
c4043fa
Compare
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.
Reviewable status: 3 of 5 files reviewed, 1 unresolved discussion (waiting on @asmaastarkware and @ShahakShama)
crates/sequencing/papyrus_consensus/src/manager.rs
line 82 at r6 (raw file):
Previously, asmaastarkware (asmaa-starkware) wrote…
.or_default()
Done.
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.
Reviewed 2 of 4 files at r5, 1 of 1 files at r7, all commit messages.
Reviewable status: complete! all files reviewed, all discussions resolved (waiting on @ShahakShama)
Merge activity
|
This change is