Skip to content

Conversation

@rach-id
Copy link
Member

@rach-id rach-id commented Nov 4, 2025

@rach-id rach-id self-assigned this Nov 4, 2025
@rach-id rach-id requested a review from evan-forbes as a code owner November 4, 2025 08:19
@rach-id rach-id added the C:consensus related to the core consensus label Nov 4, 2025
@rach-id
Copy link
Member Author

rach-id commented Nov 4, 2025

won't merge until I run the script long enough and we're confident

@rach-id rach-id marked this pull request as draft November 4, 2025 08:19
Comment on lines 1625 to 1626
if !cs.rs.StartedPrecommitSleep.Load() {
cs.rs.StartedPrecommitSleep.Store(true)
Copy link
Member

Choose a reason for hiding this comment

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

Please use CompareAndSwap.

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member

@evan-forbes evan-forbes left a comment

Choose a reason for hiding this comment

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

I wouldn't call this a tolerance, but a wait (for the pr title) 🤷

the tolerance I would associate with #2621

Copy link
Contributor

@cmwaters cmwaters left a comment

Choose a reason for hiding this comment

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

I'm a little nervous about the logic but I can't think of any scenario that would be problematic

cs.scheduleTimeout(waitTime, height, round, cstypes.RoundStepPrevoteWait)
if !cs.rs.StartedPrecommitSleep.Load() {
cs.rs.StartedPrecommitSleep.Store(true)
waitTime := cs.precommitDelay()
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we avoid the timer and unlocking relocking, if the waitTime is 0

We could even add the check prior like:

waitTime := ps.precommitDelay()
if !cs.rs.StartedPrecommitSleep.Load() && waitTime > 0 {
...

Copy link
Member Author

Choose a reason for hiding this comment

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

adding the check above would complicate the if statement given the else branch that will return

@rach-id rach-id changed the title chore: introduce a precommit delay tolerance chore: wait in the precommit step without re-scheduling Nov 4, 2025
decideProposal func(height int64, round int32)
doPrevote func(height int64, round int32)
setProposal func(proposal *types.Proposal) error
StartedPrecommitSleep atomic.Bool
Copy link
Member Author

Choose a reason for hiding this comment

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

moved this to the state instead of the round state because we copy the latter in multiple places and it's not worth handling that now.

@rach-id rach-id marked this pull request as ready for review November 4, 2025 19:20
@rach-id rach-id enabled auto-merge (squash) November 4, 2025 19:34
@rach-id rach-id merged commit 4c3e1e2 into main Nov 4, 2025
25 of 26 checks passed
@rach-id rach-id deleted the rachid/fix-timeout-precommit-race branch November 4, 2025 19:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C:consensus related to the core consensus

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Investigate mocha and arabica's halts

5 participants