Skip to content
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

waiting for same block signature - timeout and max attempts #184

Merged
merged 4 commits into from
Jul 25, 2023

Conversation

agouin
Copy link
Member

@agouin agouin commented Jul 24, 2023

sync.Cond Wait() does not allow a timeout to be specified. It will wait forever until a goroutine Broadcast()s to wake it up.

https://gist.github.com/zviadm/c234426882bfc8acba88f3503edaaa36#file-cond2-go

This cond implementation uses a channel that can be closed, and a new channel to replace it each time, allowing a timeout to be used.

@agouin agouin marked this pull request as ready for review July 24, 2023 17:52
@agouin agouin force-pushed the andrew/cond_timeout_and_max_attempts branch from a19221a to a2855a2 Compare July 24, 2023 18:13
Copy link
Member

@mark-rushakoff mark-rushakoff left a comment

Choose a reason for hiding this comment

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

Looks like there is a test case missing, but otherwise the changes look correct to me.

@@ -188,6 +192,11 @@ func (pv *ThresholdValidator) SaveLastSignedStateInitiated(chainID string, block
"latest_step", latest.Step,
)
}

return nil, existingTimestamp, fmt.Errorf(
Copy link
Member

Choose a reason for hiding this comment

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

It doesn't look like there is a test covering this error case, and it seems important to ensure we properly handle the timeout case.

@agouin agouin merged commit 1346f86 into main Jul 25, 2023
@agouin agouin deleted the andrew/cond_timeout_and_max_attempts branch July 25, 2023 16:47
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.

2 participants