Skip to content

Conversation

@asmaastarkware
Copy link
Contributor

No description provided.

Copy link
Contributor Author

asmaastarkware commented Nov 23, 2025

@reviewable-StarkWare
Copy link

This change is Reviewable

@asmaastarkware asmaastarkware marked this pull request as ready for review November 23, 2025 09:33
@asmaastarkware asmaastarkware force-pushed the asmaa/sm_now_consumes_events_and_emits_requests branch from 87290c0 to db77f88 Compare November 23, 2025 11:59
@asmaastarkware asmaastarkware force-pushed the asmaa/refactor/sm_tracks_last_self_votes_not_the_shc branch from ea47287 to 2705c59 Compare November 23, 2025 11:59
@asmaastarkware asmaastarkware force-pushed the asmaa/sm_now_consumes_events_and_emits_requests branch from db77f88 to 4bb3c97 Compare November 23, 2025 14:30
@asmaastarkware asmaastarkware force-pushed the asmaa/refactor/sm_tracks_last_self_votes_not_the_shc branch from 2705c59 to 0de6018 Compare November 23, 2025 14:30
@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/sm_now_consumes_events_and_emits_requests branch 2 times, most recently from 47d26a6 to 869a963 Compare November 24, 2025 08:20
@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/sm_now_consumes_events_and_emits_requests branch from 869a963 to f153d27 Compare November 24, 2025 08:32
@asmaastarkware asmaastarkware force-pushed the asmaa/refactor/sm_tracks_last_self_votes_not_the_shc branch 2 times, most recently from d0d314d to 358cb47 Compare November 24, 2025 09:15
@asmaastarkware asmaastarkware force-pushed the asmaa/sm_now_consumes_events_and_emits_requests branch from f153d27 to 03e5d13 Compare November 24, 2025 09:15
@asmaastarkware asmaastarkware force-pushed the asmaa/sm_now_consumes_events_and_emits_requests branch from 03e5d13 to 98c9447 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
@asmaastarkware asmaastarkware force-pushed the asmaa/sm_now_consumes_events_and_emits_requests branch from 98c9447 to 887093f Compare November 24, 2025 13:21
@asmaastarkware asmaastarkware force-pushed the asmaa/refactor/sm_tracks_last_self_votes_not_the_shc branch from 2ff8b27 to 0de1088 Compare November 26, 2025 09:49
@asmaastarkware asmaastarkware force-pushed the asmaa/sm_now_consumes_events_and_emits_requests branch 2 times, most recently from acffcd6 to 4c6e2c4 Compare November 26, 2025 11:30
@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 force-pushed the asmaa/sm_now_consumes_events_and_emits_requests branch 2 times, most recently from 5ec5c37 to 416dd69 Compare November 26, 2025 14:06
Copy link
Contributor Author

@asmaastarkware asmaastarkware left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 2 of 4 files reviewed, 20 unresolved discussions (waiting on @dafnamatsry and @matanl-starkware)


crates/apollo_consensus/src/single_height_consensus.rs line 241 at r1 (raw file):

Previously, matanl-starkware (Matan Lior) wrote…

Please add TODO to reduce the amount of duplicated code between the Prevote and Precommit arms

in this PR I tried not to break the old code (easy to review)
Donr in the upcoming PRs


crates/apollo_consensus/src/single_height_consensus.rs line 272 at r1 (raw file):

Previously, matanl-starkware (Matan Lior) wrote…

Please keep the debug log. It's essential to understand what's happening with Tendermint...

Done.


crates/apollo_consensus/src/single_height_consensus.rs line 410 at r1 (raw file):

Previously, matanl-starkware (Matan Lior) wrote…

let timeout = match vote.vote_type {
}
let task = ShcTask::Rebroadcast {timeout, vote.clone()};

in this PR I tried not to break the old code (easy to review)
but its done in #10341


crates/apollo_consensus/src/single_height_consensus.rs line 445 at r1 (raw file):

Previously, matanl-starkware (Matan Lior) wrote…

This TODO was lost...

Done.


crates/apollo_consensus/src/single_height_consensus.rs line 320 at r2 (raw file):

Previously, dafnamatsry wrote…

IIUC Prevote and Precommit only represent peer votes and are not like the other events that indicates a completed task.
Consider completely removing these event types, and simply call state machine handle_prevote and handle_precommit directly from handle_vote.

added TODO


crates/apollo_consensus/src/single_height_consensus.rs line 474 at r2 (raw file):

Previously, dafnamatsry wrote…

What is this for?

will be used next


crates/apollo_consensus/src/single_height_consensus.rs line 477 at r2 (raw file):

Previously, dafnamatsry wrote…

And this?

will be used next


crates/apollo_consensus/src/state_machine.rs line 37 at r1 (raw file):

Previously, matanl-starkware (Matan Lior) wrote…

What does this parameter mean?

valid_round


crates/apollo_consensus/src/state_machine.rs line 38 at r1 (raw file):

Previously, matanl-starkware (Matan Lior) wrote…

Now Events are only to the state machine IIUC

Done.


crates/apollo_consensus/src/state_machine.rs line 56 at r1 (raw file):

Previously, matanl-starkware (Matan Lior) wrote…

We usually don't use struct-style definition for enums.
Why did you decide to do it here?
Anyhow, I prefer not mixing (some struct-style, some tuple-style)

Done.


crates/apollo_consensus/src/state_machine.rs line 58 at r1 (raw file):

Previously, matanl-starkware (Matan Lior) wrote…

How come it's dead code?

It will be used when the SHC asks the manager to start validation—currently, the SHC does this itself


crates/apollo_consensus/src/state_machine.rs line 211 at r1 (raw file):

Previously, matanl-starkware (Matan Lior) wrote…

if self.is_observer {
return output;
}

rest of flow here...

Done.


crates/apollo_consensus/src/state_machine.rs line 238 at r1 (raw file):

Previously, matanl-starkware (Matan Lior) wrote…

Eventually, you'll return a single request from this function.
I think it's OK to add a comment explaining why you chose to do so (instead of simply return Option)

Done.


crates/apollo_consensus/src/state_machine.rs line 313 at r1 (raw file):

Previously, matanl-starkware (Matan Lior) wrote…

What about the if self.is_observer check that was under previous arms?

Done.


crates/apollo_consensus/src/state_machine.rs line 490 at r1 (raw file):

Previously, matanl-starkware (Matan Lior) wrote…

I thought that for case of Repropose you already saved the Init somewhere

We don't save the init, we save the round and the proposal_id
(it's a new round)


crates/apollo_consensus/src/state_machine.rs line 39 at r2 (raw file):

Previously, matanl-starkware (Matan Lior) wrote…

Still sends or only receives now?

Done.


crates/apollo_consensus/src/state_machine.rs line 50 at r2 (raw file):

Previously, dafnamatsry wrote…

These are only for incoming votes no? If so, fix the documentation.

Done.


crates/apollo_consensus/src/state_machine.rs line 56 at r2 (raw file):

Previously, dafnamatsry wrote…

These are now mean the timeout is completed right?
Maybe call them TimeoutExpired or TimeoutCompleted? and also fix the documentaion.

yes.. if it's not clear that the timeout expired, I will rename it in another PR


crates/apollo_consensus/src/state_machine.rs line 231 at r2 (raw file):

Previously, matanl-starkware (Matan Lior) wrote…

log vote_type as well

Done.


crates/apollo_consensus/src/state_machine.rs line 505 at r2 (raw file):

Previously, dafnamatsry wrote…

I think the ProposalInit can be constructed by whom will be performing the repropose (the manager?).
The SMRquest can include the necessary information (proposal_id, round and valid_round)

Currently, the SHC is the one who reproposes..
It needs to get the data (H, R, Id) from the SM, that's why I prefer to prepare it here

@asmaastarkware asmaastarkware changed the base branch from asmaa/refactor/sm_tracks_last_self_votes_not_the_shc to graphite-base/10339 November 27, 2025 10:39
@asmaastarkware asmaastarkware force-pushed the asmaa/sm_now_consumes_events_and_emits_requests branch from 416dd69 to 3d2c110 Compare November 27, 2025 10:39
@asmaastarkware asmaastarkware changed the base branch from graphite-base/10339 to main-v0.14.1 November 27, 2025 10:39
@asmaastarkware asmaastarkware force-pushed the asmaa/sm_now_consumes_events_and_emits_requests branch from 3d2c110 to 528df95 Compare November 27, 2025 10:42
Copy link
Contributor Author

@asmaastarkware asmaastarkware left a 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 4 files reviewed, 20 unresolved discussions (waiting on @dafnamatsry and @matanl-starkware)


crates/apollo_consensus/src/single_height_consensus.rs line 474 at r2 (raw file):

Previously, asmaastarkware (asmaa-starkware) wrote…

will be used next

deleted as discussed in huddle


crates/apollo_consensus/src/state_machine.rs line 58 at r2 (raw file):

Previously, dafnamatsry wrote…

What does this event mean? It sounds more like a task.

In this PR, I left the name as "task" because the SHC is still handling all the logic.
In #10341, once the manager became responsible for broadcasting and the doing the hard work, it was renamed to VoteBroadcasted

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 3 of 3 files at r4, all commit messages.
Reviewable status: all files reviewed, 8 unresolved discussions (waiting on @asmaastarkware and @dafnamatsry)


crates/apollo_consensus/src/state_machine.rs line 313 at r1 (raw file):

Previously, asmaastarkware (asmaa-starkware) wrote…

Done.

Do you need to check under the ScheduleTimeout* that we are not observer?
Previously:
if self.is_observer {
continue;
}


crates/apollo_consensus/src/state_machine.rs line 72 at r4 (raw file):

    BroadcastVote(Vote),
    /// Request to schedule a TimeoutPropose.
    ScheduleTimeoutPropose(Round),

Consider merging all Timeout requests into a single enum:
ScheduleTimeout(Step, Round)

Code quote:

ScheduleTimeoutPropose

Copy link
Contributor Author

@asmaastarkware asmaastarkware left a 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, 8 unresolved discussions (waiting on @dafnamatsry and @matanl-starkware)


crates/apollo_consensus/src/state_machine.rs line 313 at r1 (raw file):

Previously, matanl-starkware (Matan Lior) wrote…

Do you need to check under the ScheduleTimeout* that we are not observer?
Previously:
if self.is_observer {
continue;
}

was it?
observer should act normally, without voting/proposing

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.

Reviewable status: all files reviewed, 8 unresolved discussions (waiting on @asmaastarkware and @dafnamatsry)


crates/apollo_consensus/src/state_machine.rs line 313 at r1 (raw file):

Previously, asmaastarkware (asmaa-starkware) wrote…

was it?
observer should act normally, without voting/proposing

IDK
In original code, we had these arms:
StateMachineEvent::Proposal(_, , )
| StateMachineEvent::Prevote(
)
| StateMachineEvent::Precommit(
) => {
if self.is_observer {
continue;
}

Is it all handled the same way now?

Copy link
Contributor Author

@asmaastarkware asmaastarkware left a 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, 8 unresolved discussions (waiting on @dafnamatsry and @matanl-starkware)


crates/apollo_consensus/src/state_machine.rs line 313 at r1 (raw file):

Previously, matanl-starkware (Matan Lior) wrote…

IDK
In original code, we had these arms:
StateMachineEvent::Proposal(_, , )
| StateMachineEvent::Prevote(
)
| StateMachineEvent::Precommit(
) => {
if self.is_observer {
continue;
}

Is it all handled the same way now?

Yes, make_self_vote and advance_to_round prevent voting/proposing when the node is observer

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.

Reviewable status: all files reviewed, 7 unresolved discussions (waiting on @dafnamatsry)


crates/apollo_consensus/src/state_machine.rs line 525 at r4 (raw file):

    }

    fn advance_to_step(&mut self, step: Step) -> VecDeque<SMRequest> {

Please define as a type (in future PR)

Code quote:

VecDeque<SMRequest>

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 1 of 3 files at r2, 3 of 3 files at r4, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @asmaastarkware)


crates/apollo_consensus/src/state_machine_test.rs line 449 at r4 (raw file):

    );
    assert_eq!(wrapper.next_request().unwrap(), SMRequest::ScheduleTimeoutPrevote(ROUND));
    // Nil Prevote quorum, so we broadcast a nil Precommit.

Why didn't we have the vote broadcasting before?


crates/apollo_consensus/src/state_machine.rs line 51 at r4 (raw file):

    /// Precommit message, sent from the SHC to the state machine.
    Precommit(Vote),
    /// TimeoutPropose event, sent from the state machine to the SHC.

And also below

Suggestion:

 from the SHC to the state machine

@asmaastarkware asmaastarkware added this pull request to the merge queue Dec 2, 2025
Merged via the queue into main-v0.14.1 with commit 9e96403 Dec 2, 2025
21 checks passed
@asmaastarkware asmaastarkware deleted the asmaa/sm_now_consumes_events_and_emits_requests branch December 2, 2025 09:23
@github-actions github-actions bot locked and limited conversation to collaborators Dec 6, 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