-
Notifications
You must be signed in to change notification settings - Fork 65
apollo_consensus: use BlockNumber for Vote.height #10507
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
apollo_consensus: use BlockNumber for Vote.height #10507
Conversation
matanl-starkware
left a comment
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.
@matanl-starkware reviewed 9 of 9 files at r1, all commit messages.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @asmaastarkware and @dafnamatsry)
crates/apollo_consensus/src/manager_test.rs line 146 at r1 (raw file):
) .await; send(&mut sender, prevote(Some(Felt::TWO), BlockNumber(2), 0, *PROPOSER_ID)).await;
Consider adding a utility function for easier conversion:
Code quote (i):
BlockNumber(2)Code snippet (ii):
impl<T> From<T> for BlockNumber
where
T: Into<u64>,
{
fn from(value: T) -> Self {
BlockNumber(value.into())
}
}crates/apollo_consensus/src/manager_test.rs line 146 at r1 (raw file):
) .await; send(&mut sender, prevote(Some(Felt::TWO), BlockNumber(2), 0, *PROPOSER_ID)).await;
Consider using a shorter syntax using intermediate vars
Code quote (i):
BlockNumber(2)Code snippet (ii):
let b1 = BlockNumber(1);
let b2 = BlockNumber(2);crates/apollo_consensus/src/manager_test.rs line 272 at r1 (raw file):
send_proposal( &mut proposal_receiver_sender, vec![TestProposalPart::Init(proposal_init(1, 0, *PROPOSER_ID))],
Fix this function to accept Height as well
Code quote:
proposal_initcrates/apollo_protobuf/src/consensus.rs line 51 at r1 (raw file):
pub vote_type: VoteType, pub height: BlockNumber, pub round: u32,
And this is for the next PR...
Code quote:
u32,crates/apollo_consensus/src/manager.rs line 833 at r1 (raw file):
) -> bool { let limits = &self.consensus_config.dynamic_config.future_msg_limit; let height_diff = msg_height.0.saturating_sub(current_height.0);
Add derive_more::Deref to BlockNumber derives, and make the ".0" syntax obsolete.
Suggestion:
msg_height.saturating_sub
asmaastarkware
left a comment
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 @dafnamatsry and @matanl-starkware)
crates/apollo_consensus/src/manager_test.rs line 272 at r1 (raw file):
Previously, matanl-starkware (Matan Lior) wrote…
Fix this function to accept Height as well
(The function already accepts Height)
This is a good example of why I’d prefer to keep BlockNumber as-is and avoid implementing From<T> for BlockNumber
3100e6a to
ea0e09b
Compare
ea0e09b to
d93f9d6
Compare
0045f6c to
a674f6d
Compare
8e22da8 to
7beff96
Compare
a674f6d to
a559b67
Compare
matanl-starkware
left a comment
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.
@matanl-starkware reviewed 7 of 8 files at r2, 1 of 1 files at r3, all commit messages.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on @dafnamatsry)
-- commits line 2 at r3:
I don't think this change effectively impacts the protobuf module.
Consider leaving only "apollo_consensus" here.
Code quote:
,apollo_protobuf
matanl-starkware
left a comment
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:
complete! all files reviewed, all discussions resolved (waiting on @dafnamatsry)
crates/starknet_api/src/block.rs line 280 at r3 (raw file):
Copy, derive_more::Display, derive_more::Deref,
Once you have this in place, there are many more places that can be cleaned. For next PR.
Such as:
STORAGE_HEIGHT.set_lossy(storage_height.0);
LAST_PROPOSED_BLOCK_HEIGHT.set_lossy(block_number.0);
let mut up_to = min(state_marker, BlockNumber(from.0 + u64::from(max_stream_size)));
Code quote:
derive_more::Deref,a559b67 to
bf6cc66
Compare
7beff96 to
51ad072
Compare
bf6cc66 to
9b240b3
Compare
0dfe0db to
dad8c7d
Compare
b0543e1 to
eb935ba
Compare
dad8c7d to
0223f0c
Compare
eb935ba to
d52e421
Compare
0223f0c to
31f17aa
Compare
31f17aa to
09eec94
Compare
asmaastarkware
left a comment
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.
@asmaastarkware reviewed 1 of 1 files at r4, 2 of 2 files at r5, all commit messages.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on @dafnamatsry)
09eec94 to
fde8c30
Compare
fde8c30 to
de5d172
Compare

No description provided.