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: race condition when querying registered operators data #343

Merged
merged 5 commits into from
Sep 24, 2024

Conversation

ricomateo
Copy link
Contributor

@ricomateo ricomateo commented Sep 18, 2024

What Changed?

This PR adds a small fix for a race condition found when querying registered operators data.

The functions QueryExistingRegisteredOperatorPubKeys and QueryExistingRegisteredOperatorSockets both run in parallel and they read and mutate the same variable startBlock. This causes a race condition because startBlock is a *big.Int.

The solution is to clone the startBlock into a new variable for each function.

A better solution would be to change QueryExistingRegisteredOperatorPubKeys and QueryExistingRegisteredOperatorSockets function signatures to receive startBlock as primitive int64 variable instead of *big.Int and do the conversion to *big.Int inside of the functions.

Reviewer Checklist

  • Code is well-documented
  • Code adheres to Go naming conventions
  • Code deprecates any old functionality before removing it

@MegaRedHand MegaRedHand added the bug Something isn't working label Sep 19, 2024
Copy link
Collaborator

@samlaf samlaf left a comment

Choose a reason for hiding this comment

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

Thanks for this fix :) Let's just add a comment to explain why we are doing this.

chainio/clients/avsregistry/reader.go Show resolved Hide resolved
@samlaf samlaf force-pushed the fix-operators-info-race-condition branch from 4493684 to 477ec37 Compare September 24, 2024 17:52
Copy link
Collaborator

@samlaf samlaf left a comment

Choose a reason for hiding this comment

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

LGTM thanks! operator unit test is failing, we know why. Will push a fix soon and then you'll just have to rebase on top before merging this PR.

@samlaf samlaf force-pushed the fix-operators-info-race-condition branch from 477ec37 to ee8933b Compare September 24, 2024 20:10
@samlaf samlaf merged commit 6f241c3 into dev Sep 24, 2024
4 checks passed
@samlaf samlaf deleted the fix-operators-info-race-condition branch September 24, 2024 20:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants