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 bls aggregation for multiple quorums #394

Open
wants to merge 20 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions services/bls_aggregation/blsagg.go
Original file line number Diff line number Diff line change
Expand Up @@ -444,12 +444,22 @@ func (a *BlsAggregatorService) singleTaskAggregatorGoroutineFunc(
// after verifying signature we aggregate its sig and pubkey, and update the signed stake amount
if !ok {
// first operator to sign on this digest
signersApkG2 := bls.NewZeroG2Point()
signersAggSigG1 := bls.NewZeroSignature()
// for each quorum the operator has stake in, the signature is aggregated
// see
// https://github.com/Layr-Labs/eigenlayer-middleware/blob/7d49b5181b09198ed275783453aa082bb3766990/src/BLSSignatureChecker.sol#L161-L168
for range operatorsAvsStateDict[signedTaskResponseDigest.OperatorId].StakePerQuorum {
signersApkG2 = signersApkG2.Add(
operatorsAvsStateDict[signedTaskResponseDigest.OperatorId].OperatorInfo.Pubkeys.G2Pubkey,
)
signersAggSigG1 = signersAggSigG1.Add(signedTaskResponseDigest.BlsSignature)
}
digestAggregatedOperators = aggregatedOperators{
// we've already verified that the operator is part of the task's quorum, so we don't need checks
// here
signersApkG2: bls.NewZeroG2Point().
Add(operatorsAvsStateDict[signedTaskResponseDigest.OperatorId].OperatorInfo.Pubkeys.G2Pubkey),
signersAggSigG1: signedTaskResponseDigest.BlsSignature,
signersApkG2: signersApkG2,
signersAggSigG1: signersAggSigG1,
signersOperatorIdsSet: map[types.OperatorId]bool{signedTaskResponseDigest.OperatorId: true},
signersTotalStakePerQuorum: cloneStakePerQuorumMap(
operatorsAvsStateDict[signedTaskResponseDigest.OperatorId].StakePerQuorum,
Expand All @@ -460,10 +470,11 @@ func (a *BlsAggregatorService) singleTaskAggregatorGoroutineFunc(
"taskIndex", taskIndex,
"taskResponseDigest", taskResponseDigest)

digestAggregatedOperators.signersAggSigG1.Add(signedTaskResponseDigest.BlsSignature)
digestAggregatedOperators.signersApkG2.Add(operatorsAvsStateDict[signedTaskResponseDigest.OperatorId].OperatorInfo.Pubkeys.G2Pubkey)
digestAggregatedOperators.signersOperatorIdsSet[signedTaskResponseDigest.OperatorId] = true
// for each quorum the operator has stake in, the signature is aggregated
for quorumNum, stake := range operatorsAvsStateDict[signedTaskResponseDigest.OperatorId].StakePerQuorum {
digestAggregatedOperators.signersAggSigG1.Add(signedTaskResponseDigest.BlsSignature)
digestAggregatedOperators.signersApkG2.Add(operatorsAvsStateDict[signedTaskResponseDigest.OperatorId].OperatorInfo.Pubkeys.G2Pubkey)
if _, ok := digestAggregatedOperators.signersTotalStakePerQuorum[quorumNum]; !ok {
// if we haven't seen this quorum before, initialize its signed stake to 0
// possible if previous operators who sent us signatures were not part of this quorum
Expand Down
Loading
Loading