Skip to content

Commit

Permalink
fix: race condition on blsagg
Browse files Browse the repository at this point in the history
  • Loading branch information
chzyer committed Jun 19, 2024
1 parent d74457d commit 8412f23
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions services/bls_aggregation/blsagg.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,13 +172,18 @@ func (a *BlsAggregatorService) InitializeNewTask(
timeToExpiry time.Duration,
) error {
a.logger.Debug("AggregatorService initializing new task", "taskIndex", taskIndex, "taskCreatedBlock", taskCreatedBlock, "quorumNumbers", quorumNumbers, "quorumThresholdPercentages", quorumThresholdPercentages, "timeToExpiry", timeToExpiry)
if _, taskExists := a.signedTaskRespsCs[taskIndex]; taskExists {
return TaskAlreadyInitializedErrorFn(taskIndex)
}
signedTaskRespsC := make(chan types.SignedTaskResponseDigest)

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

go a.singleTaskAggregatorGoroutineFunc(taskIndex, taskCreatedBlock, quorumNumbers, quorumThresholdPercentages, timeToExpiry, signedTaskRespsC)
return nil
}
Expand Down

0 comments on commit 8412f23

Please sign in to comment.