Skip to content

Conversation

@asmaastarkware
Copy link
Contributor

No description provided.

@reviewable-StarkWare
Copy link

This change is Reviewable

Copy link
Contributor Author

asmaastarkware commented Nov 23, 2025

Copy link
Collaborator

@matanl-starkware matanl-starkware left a 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());
}

@asmaastarkware asmaastarkware force-pushed the asmaa/refactor/sm_tracks_last_self_votes_not_the_shc branch from 0de6018 to a50bb75 Compare November 24, 2025 07:47
@asmaastarkware asmaastarkware force-pushed the asmaa/refactor/move_proposal_storage_to_sm_dedupe_in_shc branch from 14d84a6 to 10f3a92 Compare November 24, 2025 07:47
@asmaastarkware asmaastarkware force-pushed the asmaa/refactor/sm_tracks_last_self_votes_not_the_shc branch from a50bb75 to 030b969 Compare November 24, 2025 08:20
@asmaastarkware asmaastarkware force-pushed the asmaa/refactor/move_proposal_storage_to_sm_dedupe_in_shc branch from 10f3a92 to 0348f1e Compare November 24, 2025 08:20
@asmaastarkware asmaastarkware force-pushed the asmaa/refactor/sm_tracks_last_self_votes_not_the_shc branch from 030b969 to d0d314d Compare November 24, 2025 08:32
@asmaastarkware asmaastarkware force-pushed the asmaa/refactor/move_proposal_storage_to_sm_dedupe_in_shc branch 2 times, most recently from 92e5452 to ebbe724 Compare November 24, 2025 09:15
@asmaastarkware asmaastarkware force-pushed the asmaa/refactor/sm_tracks_last_self_votes_not_the_shc branch from d0d314d to 358cb47 Compare November 24, 2025 09:15
@asmaastarkware asmaastarkware force-pushed the asmaa/refactor/move_proposal_storage_to_sm_dedupe_in_shc branch from ebbe724 to c6ec6fe Compare November 24, 2025 13:18
@asmaastarkware asmaastarkware force-pushed the asmaa/refactor/sm_tracks_last_self_votes_not_the_shc branch from 358cb47 to 83d5968 Compare November 24, 2025 13:18
Copy link
Collaborator

@matanl-starkware matanl-starkware left a 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: :shipit: 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:

 Vote

@asmaastarkware asmaastarkware force-pushed the asmaa/refactor/move_proposal_storage_to_sm_dedupe_in_shc branch from c6ec6fe to c1e36f6 Compare November 24, 2025 14:16
@asmaastarkware asmaastarkware force-pushed the asmaa/refactor/sm_tracks_last_self_votes_not_the_shc branch 2 times, most recently from cc6dbdb to bc2d9be Compare November 25, 2025 08:24
@asmaastarkware asmaastarkware force-pushed the asmaa/refactor/move_proposal_storage_to_sm_dedupe_in_shc branch from c1e36f6 to 31bd3d1 Compare November 25, 2025 08:24
@asmaastarkware asmaastarkware force-pushed the asmaa/refactor/sm_tracks_last_self_votes_not_the_shc branch from bc2d9be to cf78c42 Compare November 25, 2025 09:00
@asmaastarkware asmaastarkware force-pushed the asmaa/refactor/move_proposal_storage_to_sm_dedupe_in_shc branch from 31bd3d1 to 8089a74 Compare November 25, 2025 09:00
Copy link
Collaborator

@dafnamatsry dafnamatsry left a 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:?}",
                )));
            }

Copy link
Collaborator

@matanl-starkware matanl-starkware left a 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)

@asmaastarkware asmaastarkware force-pushed the asmaa/refactor/move_proposal_storage_to_sm_dedupe_in_shc branch from 8089a74 to eba6d0f Compare November 26, 2025 08:56
@asmaastarkware asmaastarkware force-pushed the asmaa/refactor/sm_tracks_last_self_votes_not_the_shc branch 2 times, most recently from 2ff8b27 to 0de1088 Compare November 26, 2025 09:49
@asmaastarkware asmaastarkware force-pushed the asmaa/refactor/move_proposal_storage_to_sm_dedupe_in_shc branch from eba6d0f to d71d92d Compare November 26, 2025 09:49
@asmaastarkware asmaastarkware changed the base branch from asmaa/refactor/move_proposal_storage_to_sm_dedupe_in_shc to graphite-base/10338 November 26, 2025 11:29
@asmaastarkware asmaastarkware force-pushed the asmaa/refactor/sm_tracks_last_self_votes_not_the_shc branch from 0de1088 to a32cd90 Compare November 26, 2025 11:30
@asmaastarkware asmaastarkware changed the base branch from graphite-base/10338 to main-v0.14.1 November 26, 2025 11:30
Copy link
Collaborator

@dafnamatsry dafnamatsry left a 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: :shipit: complete! all files reviewed, all discussions resolved (waiting on @asmaastarkware)

@asmaastarkware asmaastarkware added this pull request to the merge queue Nov 27, 2025
Merged via the queue into main-v0.14.1 with commit 7e72528 Nov 27, 2025
22 of 34 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Nov 29, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants