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

Fix committee test race #12338

Merged
merged 8 commits into from
Apr 27, 2023
Merged

Fix committee test race #12338

merged 8 commits into from
Apr 27, 2023

Conversation

kasey
Copy link
Contributor

@kasey kasey commented Apr 26, 2023

What type of PR is this?

Bug fix

What does this PR do? Why is it needed?

Helps eliminate a class of unit tests races caused by asyncronous updating of the sync committee cache. This is accomplished by more carefully managing access to the cache value, canceling the async update if the underlying cache has been re-initialized, which only happens in the test code path.

@kasey kasey requested a review from a team as a code owner April 26, 2023 19:56
@@ -162,6 +181,9 @@ func (s *SyncCommitteeCache) UpdatePositionsInCommittee(syncCommitteeBoundaryRoo

s.lock.Lock()
defer s.lock.Unlock()
if clearCount != s.cleared.Load() {
return errors.New("cache rotated during async committee update operation")
Copy link
Member

Choose a reason for hiding this comment

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

Any thoughts on logging the error and returning nil vs. returning the error?
Question is whether this error should fail block processing

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's a bummer that we even need to consider this, but I agree that I don't want to create an issue in block processing, because strict ordering of cache updates so far seems to only be an issue in tests. But I don't like how the current design requires so much care to avoid races, so I'm inclined to go ahead and log for now, then return to improving this design when we audit cache implementations.

terencechain
terencechain previously approved these changes Apr 26, 2023
nisdas
nisdas previously approved these changes Apr 27, 2023
@prylabs-bulldozer prylabs-bulldozer bot merged commit f962d13 into develop Apr 27, 2023
@delete-merged-branch delete-merged-branch bot deleted the fix-committee-test-race branch April 27, 2023 00:50
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.

3 participants