Skip to content

Commit

Permalink
make local
Browse files Browse the repository at this point in the history
  • Loading branch information
afkbyte committed May 29, 2024
1 parent 32b29a7 commit 2177792
Showing 1 changed file with 11 additions and 18 deletions.
29 changes: 11 additions & 18 deletions services/bls_aggregation/blsagg.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,15 +197,6 @@ func (a *BlsAggregatorService) ProcessNewSignature(
if !taskInitialized {
return TaskNotFoundErrorFn(taskIndex)
}
// compute the taskResponseDigest using the hash function
taskResponseDigest := a.hashFunction(taskResponse)

// check if the taskResponseDigest is already in the map
_, taskResponseExists := a.taskResponseMap[taskResponseDigest]
if !taskResponseExists {
// Store the TaskResponse in our mapping
a.taskResponseMap[taskResponseDigest] = taskResponse
}

signatureVerificationErrorC := make(chan error)
// send the task to the goroutine processing this task
Expand All @@ -215,7 +206,7 @@ func (a *BlsAggregatorService) ProcessNewSignature(
// we need to send this as part of select because if the goroutine is processing another SignedTaskResponseDigest
// and cannot receive this one, we want the context to be able to cancel the request
case taskC <- types.SignedTaskResponseDigest{
TaskResponseDigest: taskResponseDigest,
TaskResponse: taskResponse,

Check failure on line 209 in services/bls_aggregation/blsagg.go

View workflow job for this annotation

GitHub Actions / Test

unknown field TaskResponse in struct literal of type "github.com/Layr-Labs/eigensdk-go/types".SignedTaskResponseDigest

Check failure on line 209 in services/bls_aggregation/blsagg.go

View workflow job for this annotation

GitHub Actions / build

unknown field TaskResponse in struct literal of type "github.com/Layr-Labs/eigensdk-go/types".SignedTaskResponseDigest
BlsSignature: blsSignature,
OperatorId: operatorId,
SignatureVerificationErrorC: signatureVerificationErrorC,
Expand Down Expand Up @@ -274,16 +265,16 @@ func (a *BlsAggregatorService) singleTaskAggregatorGoroutineFunc(
select {
case signedTaskResponseDigest := <-signedTaskRespsC:
a.logger.Debug("Task goroutine received new signed task response digest", "taskIndex", taskIndex, "signedTaskResponseDigest", signedTaskResponseDigest)
// Retrieve the TaskResponse from the map
taskResponse := a.taskResponseMap[signedTaskResponseDigest.TaskResponseDigest]
// compute the taskResponseDigest using the hash function
taskResponseDigest := a.hashFunction(signedTaskResponseDigest.TaskResponse)

Check failure on line 269 in services/bls_aggregation/blsagg.go

View workflow job for this annotation

GitHub Actions / Test

signedTaskResponseDigest.TaskResponse undefined (type "github.com/Layr-Labs/eigensdk-go/types".SignedTaskResponseDigest has no field or method TaskResponse)

Check failure on line 269 in services/bls_aggregation/blsagg.go

View workflow job for this annotation

GitHub Actions / build

signedTaskResponseDigest.TaskResponse undefined (type "github.com/Layr-Labs/eigensdk-go/types".SignedTaskResponseDigest has no field or method TaskResponse)

err := a.verifySignature(taskIndex, signedTaskResponseDigest, operatorsAvsStateDict)
signedTaskResponseDigest.SignatureVerificationErrorC <- err
if err != nil {
continue
}
// after verifying signature we aggregate its sig and pubkey, and update the signed stake amount
digestAggregatedOperators, ok := aggregatedOperatorsDict[signedTaskResponseDigest.TaskResponseDigest]
digestAggregatedOperators, ok := aggregatedOperatorsDict[taskResponseDigest]
if !ok {
// first operator to sign on this digest
digestAggregatedOperators = aggregatedOperators{
Expand All @@ -308,7 +299,7 @@ func (a *BlsAggregatorService) singleTaskAggregatorGoroutineFunc(
}
// update the aggregatedOperatorsDict. Note that we need to assign the whole struct value at once,
// because of https://github.com/golang/go/issues/3117
aggregatedOperatorsDict[signedTaskResponseDigest.TaskResponseDigest] = digestAggregatedOperators
aggregatedOperatorsDict[taskResponseDigest] = digestAggregatedOperators

if checkIfStakeThresholdsMet(a.logger, digestAggregatedOperators.signersTotalStakePerQuorum, totalStakePerQuorum, quorumThresholdPercentagesMap) {
nonSignersOperatorIds := []types.OperatorId{}
Expand Down Expand Up @@ -342,8 +333,8 @@ func (a *BlsAggregatorService) singleTaskAggregatorGoroutineFunc(
blsAggregationServiceResponse := BlsAggregationServiceResponse{
Err: nil,
TaskIndex: taskIndex,
TaskResponse: taskResponse,
TaskResponseDigest: signedTaskResponseDigest.TaskResponseDigest,
TaskResponse: signedTaskResponseDigest.TaskResponse,

Check failure on line 336 in services/bls_aggregation/blsagg.go

View workflow job for this annotation

GitHub Actions / Test

signedTaskResponseDigest.TaskResponse undefined (type "github.com/Layr-Labs/eigensdk-go/types".SignedTaskResponseDigest has no field or method TaskResponse)

Check failure on line 336 in services/bls_aggregation/blsagg.go

View workflow job for this annotation

GitHub Actions / build

signedTaskResponseDigest.TaskResponse undefined (type "github.com/Layr-Labs/eigensdk-go/types".SignedTaskResponseDigest has no field or method TaskResponse)
TaskResponseDigest: taskResponseDigest,
NonSignersPubkeysG1: nonSignersG1Pubkeys,
QuorumApksG1: quorumApksG1,
SignersApkG2: digestAggregatedOperators.signersApkG2,
Expand Down Expand Up @@ -395,6 +386,8 @@ func (a *BlsAggregatorService) verifySignature(
return OperatorNotPartOfTaskQuorumErrorFn(signedTaskResponseDigest.OperatorId, taskIndex)
}

taskResponseDigest := a.hashFunction(signedTaskResponseDigest.TaskResponse)

Check failure on line 389 in services/bls_aggregation/blsagg.go

View workflow job for this annotation

GitHub Actions / Test

signedTaskResponseDigest.TaskResponse undefined (type "github.com/Layr-Labs/eigensdk-go/types".SignedTaskResponseDigest has no field or method TaskResponse)

Check failure on line 389 in services/bls_aggregation/blsagg.go

View workflow job for this annotation

GitHub Actions / build

signedTaskResponseDigest.TaskResponse undefined (type "github.com/Layr-Labs/eigensdk-go/types".SignedTaskResponseDigest has no field or method TaskResponse)

// verify that the msg actually came from the correct operator
operatorG2Pubkey := operatorsAvsStateDict[signedTaskResponseDigest.OperatorId].OperatorInfo.Pubkeys.G2Pubkey
if operatorG2Pubkey == nil {
Expand All @@ -403,13 +396,13 @@ func (a *BlsAggregatorService) verifySignature(
}
a.logger.Debug("Verifying signed task response digest signature",
"operatorG2Pubkey", operatorG2Pubkey,
"taskResponseDigest", signedTaskResponseDigest.TaskResponseDigest,
"taskResponseDigest", taskResponseDigest,
"blsSignature", signedTaskResponseDigest.BlsSignature,
)

// if the operator signs a digest that is not the digest of the TaskResponse submitted in ProcessNewTask
// then the signature will not be verified
signatureVerified, err := signedTaskResponseDigest.BlsSignature.Verify(operatorG2Pubkey, signedTaskResponseDigest.TaskResponseDigest)
signatureVerified, err := signedTaskResponseDigest.BlsSignature.Verify(operatorG2Pubkey, taskResponseDigest)
if err != nil {
return SignatureVerificationError(err)
}
Expand Down

0 comments on commit 2177792

Please sign in to comment.