-
Notifications
You must be signed in to change notification settings - Fork 65
apollo_consensus: SM tracks last self votes not the SHC #10338
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: SM tracks last self votes not the SHC #10338
Conversation
ea47287 to
2705c59
Compare
10cf82e to
1630329
Compare
2705c59 to
0de6018
Compare
1630329 to
14d84a6
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 2 of 2 files at r1.
Reviewable status: all files reviewed (commit messages unreviewed), 1 unresolved discussion (waiting on @dafnamatsry)
crates/apollo_consensus/src/state_machine.rs line 199 at r1 (raw file):
None => self.last_self_precommit = Some(vote.clone()), Some(last) if round > last.round => self.last_self_precommit = Some(vote.clone()), _ => {}
Code duplication.
Consider refactor.
Code quote (i):
None => self.last_self_precommit = Some(vote.clone()),
Some(last) if round > last.round => self.last_self_precommit = Some(vote.clone()),
_ => {}Code snippet (ii):
let slot = match vote_type {
VoteType::Prevote => &mut self.last_self_prevote,
VoteType::Precommit => &mut self.last_self_precommit,
};
if match slot {
None => true,
Some(last) => round > last.round,
} {
*slot = Some(vote.clone());
}0de6018 to
a50bb75
Compare
14d84a6 to
10f3a92
Compare
a50bb75 to
030b969
Compare
10f3a92 to
0348f1e
Compare
030b969 to
d0d314d
Compare
92e5452 to
ebbe724
Compare
d0d314d to
358cb47
Compare
ebbe724 to
c6ec6fe
Compare
358cb47 to
83d5968
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 2 of 2 files at r2, all commit messages.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on @dafnamatsry)
crates/apollo_consensus/src/state_machine.rs line 182 at r2 (raw file):
round: Round, proposal_commitment: Option<ProposalCommitment>, ) -> Vote {
Consider returning a reference to last_self_vote and remove the clone on line 200
Code quote:
Votec6ec6fe to
c1e36f6
Compare
cc6dbdb to
bc2d9be
Compare
c1e36f6 to
31bd3d1
Compare
bc2d9be to
cf78c42
Compare
31bd3d1 to
8089a74
Compare
dafnamatsry
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.
@dafnamatsry reviewed 3 of 3 files at r4, all commit messages.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @asmaastarkware)
crates/apollo_consensus/src/state_machine.rs line 189 at r4 (raw file):
&mut self, vote_type: VoteType, round: Round,
If the state machine should only vote for its current round (according to Tendermint), maybe remove this argument and use self.round.
Code quote:
round: Round,crates/apollo_consensus/src/state_machine.rs line 192 at r4 (raw file):
proposal_commitment: Option<ProposalCommitment>, ) -> Vote { let vt = vote_type.clone();
You can add #[derive(Copy)] above VoteType and remove the clone().
This makes the value copy instead of move, which is fine since the enum is small and simple.
Code quote:
let vt = vote_type.clone();crates/apollo_consensus/src/state_machine.rs line 208 at r4 (raw file):
None => true, Some(last) => round > last.round, } {
Use is_none_or instead:
if last_self_vote.is_none_or(|r| r < round) {..}
Code quote:
if match last_self_vote {
None => true,
Some(last) => round > last.round,
} {crates/apollo_consensus/src/single_height_consensus.rs line 535 at r4 (raw file):
{vote:?}", ))); }
Don't we want to move this assertion to the state machine?
Code quote:
Some(_) => {
// According to the Tendermint paper, the state machine should only vote for its
// current round. It should monotonically increase its round. It should only vote
// once per step.
return Err(ConsensusError::InternalInconsistency(format!(
"State machine must progress in time: last_vote: {last_vote:?} new_vote: \
{vote:?}",
)));
}
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 all commit messages.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @asmaastarkware)
8089a74 to
eba6d0f
Compare
2ff8b27 to
0de1088
Compare
eba6d0f to
d71d92d
Compare
d71d92d to
0c5c7c2
Compare
0de1088 to
a32cd90
Compare
dafnamatsry
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.
@dafnamatsry reviewed 2 of 2 files at r5, all commit messages.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on @asmaastarkware)

No description provided.