Skip to content

feat(smr): do not schedule the same timeout twice#1508

Merged
romac merged 14 commits intocirclefin:mainfrom
cason:duplicated-timeouts-smr
Mar 6, 2026
Merged

feat(smr): do not schedule the same timeout twice#1508
romac merged 14 commits intocirclefin:mainfrom
cason:duplicated-timeouts-smr

Conversation

@cason
Copy link
Copy Markdown
Contributor

@cason cason commented Feb 27, 2026

Closes: #1500

Alternative to #1501.

Creates a scheduled_timeouts boolean array in the state machine State, which is reset to false at every round. Before scheduling a timeout for a given TimeoutKind, checks if the corresponding slot of the array is taken. If not, mark is as taken an return the timeout as output. Otherwise, don't produce a duplicate Timeout event.

In other to prevent tests from breaking, scheduled_timeouts is not considered for PartialEq comparisons.

@github-actions

This comment was marked as outdated.

@github-actions github-actions Bot added the need-triage This issue needs to be triaged label Feb 27, 2026
@github-actions github-actions Bot closed this Feb 27, 2026
Comment thread code/crates/core-state-machine/src/lib.rs
@romac romac removed the need-triage This issue needs to be triaged label Feb 27, 2026
@romac romac reopened this Feb 27, 2026
@github-actions

This comment was marked as off-topic.

@github-actions github-actions Bot added the need-triage This issue needs to be triaged label Feb 27, 2026
@github-actions github-actions Bot closed this Feb 27, 2026
@romac romac reopened this Feb 27, 2026
@romac romac removed the need-triage This issue needs to be triaged label Feb 27, 2026
Comment thread code/crates/core-state-machine/src/state.rs Outdated

/// Helper to map a `TimeoutKind` to its specific bitmask.
/// Returns `None` for timeouts that are not tracked per-round.
const fn mask(timeout: TimeoutKind) -> Option<u8> {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

An alternative solution is to use Step as index, see: cason#5

@romac romac added this pull request to the merge queue Mar 6, 2026
Merged via the queue into circlefin:main with commit 39a3ad0 Mar 6, 2026
12 checks passed
Copy link
Copy Markdown
Contributor

@nenadmilosevic95 nenadmilosevic95 left a comment

Choose a reason for hiding this comment

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

LGTM! Great work!

);
debug_trace!(state, Line::L18);

debug_assert!(state.check_timeout(TimeoutKind::Propose));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This line will be stripped entirely in release builds since it's inside a debug_assert!?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yes

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I guess it is fine because it is a propose timeout, although it will be nicer if it is consistent with prevote and precommit. But not critical anyway

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(driver): Prevent scheduling identical timeouts

3 participants