Skip to content

Commit ad522cd

Browse files
author
Julian Ventura
committed
Requested changes
1 parent 6cd8fa9 commit ad522cd

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

aggregator/internal/pkg/server.go

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,14 @@ func (agg *Aggregator) ServeOperators() error {
3838
// Waits for the arrival of task associated with signedTaskResponse and returns true on success or false on failure
3939
// If the task is not present in the internal map, it will try to fetch it from logs and retry.
4040
// The number of retries is specified by `waitForEventRetries`, and the waiting time between each by `waitForEventSleepSeconds`
41-
func (agg *Aggregator) waitForTask(signedTaskResponse *types.SignedTaskResponse) bool {
41+
func (agg *Aggregator) waitForTaskAndFetchIfLost(signedTaskResponse *types.SignedTaskResponse) bool {
4242
for i := 0; i < waitForEventRetries; i++ {
4343
// Lock
4444
agg.taskMutex.Lock()
45-
agg.AggregatorConfig.BaseConfig.Logger.Info("- Locked Resources: Starting processing of Response")
45+
agg.AggregatorConfig.BaseConfig.Logger.Info("- Locked Resources: Check if task is present")
4646
_, ok := agg.batchesIdxByIdentifierHash[signedTaskResponse.BatchIdentifierHash]
4747
// Unlock
48-
agg.logger.Info("- Unlocked Resources: Task not found in the internal map")
48+
agg.logger.Info("- Unlocked Resources: Check if task is present")
4949
agg.taskMutex.Unlock()
5050
if ok {
5151
return true
@@ -92,23 +92,23 @@ func (agg *Aggregator) ProcessOperatorSignedTaskResponseV2(signedTaskResponse *t
9292
"BatchIdentifierHash", "0x"+hex.EncodeToString(signedTaskResponse.BatchIdentifierHash[:]),
9393
"operatorId", hex.EncodeToString(signedTaskResponse.OperatorId[:]))
9494

95-
if !agg.waitForTask(signedTaskResponse) {
95+
if !agg.waitForTaskAndFetchIfLost(signedTaskResponse) {
9696
agg.logger.Warn("Task not found in the internal map, operator signature will be lost. Batch may not reach quorum")
9797
*reply = 1
9898
return nil
9999
}
100100

101101
agg.taskMutex.Lock()
102-
agg.AggregatorConfig.BaseConfig.Logger.Info("- Locked Resources: Starting processing of Response")
102+
agg.AggregatorConfig.BaseConfig.Logger.Info("- Locked Resources: Get task taskIndex")
103103
taskIndex, ok := agg.batchesIdxByIdentifierHash[signedTaskResponse.BatchIdentifierHash]
104+
// Unlock
105+
agg.AggregatorConfig.BaseConfig.Logger.Info("- Unlocked Resources: Get task taskIndex")
106+
agg.taskMutex.Unlock()
104107
if !ok {
105108
agg.logger.Errorf("Unexpected error fetching for task with merkle root 0x%x", signedTaskResponse.BatchMerkleRoot)
106109
*reply = 1
107110
return nil
108111
}
109-
// Unlock
110-
agg.logger.Info("- Unlocked Resources: Task not found in the internal map")
111-
agg.taskMutex.Unlock()
112112

113113
agg.telemetry.LogOperatorResponse(signedTaskResponse.BatchMerkleRoot, signedTaskResponse.OperatorId)
114114

@@ -149,8 +149,6 @@ func (agg *Aggregator) ProcessOperatorSignedTaskResponseV2(signedTaskResponse *t
149149
*reply = 0
150150
}
151151

152-
agg.AggregatorConfig.BaseConfig.Logger.Info("- Unlocked Resources: Task response processing finished")
153-
154152
return nil
155153
}
156154

0 commit comments

Comments
 (0)