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 on blsagg #271

Merged
merged 2 commits into from
Jun 23, 2024

Conversation

chzyer
Copy link
Contributor

@chzyer chzyer commented Jun 19, 2024

Fixes # .

What Changed?

Fixed the race condition when accessing the signedTaskRespsCs map.

Reviewer Checklist

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

@chzyer chzyer force-pushed the fix/blsagg_race_condition branch from 8412f23 to 6ec28a8 Compare June 19, 2024 03:49
@samlaf
Copy link
Collaborator

samlaf commented Jun 19, 2024

Hey! Thanks for this :)
I was super excited when I first saw this because I thought this was fixing #79 , but seems like its not heh. Still have to investigate that one to figure out where the race is coming from.

Anyhow thanks for fixing this one. Would you mind changing the code to

a.taskChansMutex.Lock()
defer a.taskChansMutex.Unlock()
if _, taskExists := a.signedTaskRespsCs[taskIndex]; taskExists {
return TaskAlreadyInitializedErrorFn(taskIndex)
}
signedTaskRespsC := make(chan types.SignedTaskResponseDigest)
a.signedTaskRespsCs[taskIndex] = signedTaskRespsC

Personally find the defer easier to understand than your split if/else with an unlock in between.

@chzyer chzyer force-pushed the fix/blsagg_race_condition branch from 2d89859 to e32eea6 Compare June 21, 2024 01:43
@chzyer
Copy link
Contributor Author

chzyer commented Jun 21, 2024

Thanks @samlaf! That makes sense to me. I’ve already sent a new commit.

@chzyer
Copy link
Contributor Author

chzyer commented Jun 21, 2024

Hey @samlaf. I also have a fix for the #79 that you mentioned.
When you have a moment, please take a look #279.

Thanks!

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 a ton for this!

@samlaf samlaf merged commit 12194ba into Layr-Labs:dev Jun 23, 2024
3 checks passed
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