Skip to content

Commit

Permalink
feat: add observability to bls aggregation service (#315)
Browse files Browse the repository at this point in the history
* feat: improve bls aggregtion service logging

* refactor: logs

* chore: fix whitespace

---------

Co-authored-by: Tatu <[email protected]>
  • Loading branch information
taturosati and taturosati authored Sep 11, 2024
1 parent 24fa758 commit cd86e21
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions services/bls_aggregation/blsagg.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,10 +256,18 @@ func (a *BlsAggregatorService) singleTaskAggregatorGoroutineFunc(
timeToExpiry time.Duration,
signedTaskRespsC <-chan types.SignedTaskResponseDigest,
) {
a.logger.Debug("AggregatorService goroutine processing new task",
"taskIndex", taskIndex,
"taskCreatedBlock", taskCreatedBlock)

defer a.closeTaskGoroutine(taskIndex)
quorumThresholdPercentagesMap := make(map[types.QuorumNum]types.QuorumThresholdPercentage)
for i, quorumNumber := range quorumNumbers {
quorumThresholdPercentagesMap[quorumNumber] = quorumThresholdPercentages[i]
a.logger.Debug("AggregatorService goroutine quorum threshold percentage",
"taskIndex", taskIndex,
"quorumNumber", quorumNumber,
"quorumThresholdPercentage", quorumThresholdPercentages[i])
}
operatorsAvsStateDict, err := a.avsRegistryService.GetOperatorsAvsStateAtBlock(
context.Background(),
Expand Down Expand Up @@ -302,6 +310,10 @@ func (a *BlsAggregatorService) singleTaskAggregatorGoroutineFunc(
totalStakePerQuorum := make(map[types.QuorumNum]*big.Int)
for quorumNum, quorumAvsState := range quorumsAvsStakeDict {
totalStakePerQuorum[quorumNum] = quorumAvsState.TotalStake
a.logger.Debug("Task goroutine quorum total stake",
"taskIndex", taskIndex,
"quorumNum", quorumNum,
"totalStake", quorumAvsState.TotalStake)
}
quorumApksG1 := []*bls.G1Point{}
for _, quorumNumber := range quorumNumbers {
Expand Down Expand Up @@ -354,6 +366,10 @@ func (a *BlsAggregatorService) singleTaskAggregatorGoroutineFunc(
),
}
} else {
a.logger.Debug("Task goroutine updating existing aggregated operator signatures",
"taskIndex", taskIndex,
"taskResponseDigest", taskResponseDigest)

digestAggregatedOperators.signersAggSigG1.Add(signedTaskResponseDigest.BlsSignature)
digestAggregatedOperators.signersApkG2.Add(operatorsAvsStateDict[signedTaskResponseDigest.OperatorId].OperatorInfo.Pubkeys.G2Pubkey)
digestAggregatedOperators.signersOperatorIdsSet[signedTaskResponseDigest.OperatorId] = true
Expand All @@ -376,6 +392,10 @@ func (a *BlsAggregatorService) singleTaskAggregatorGoroutineFunc(
totalStakePerQuorum,
quorumThresholdPercentagesMap,
) {
a.logger.Debug("Task goroutine stake threshold reached",
"taskIndex", taskIndex,
"taskResponseDigest", taskResponseDigest)

nonSignersOperatorIds := []types.OperatorId{}
for operatorId := range operatorsAvsStateDict {
if _, operatorSigned := digestAggregatedOperators.signersOperatorIdsSet[operatorId]; !operatorSigned {
Expand Down Expand Up @@ -523,6 +543,7 @@ func checkIfStakeThresholdsMet(
totalStakePerQuorum map[types.QuorumNum]*big.Int,
quorumThresholdPercentagesMap map[types.QuorumNum]types.QuorumThresholdPercentage,
) bool {
logger.Debug("Checking if stake thresholds are met.")
for quorumNum, quorumThresholdPercentage := range quorumThresholdPercentagesMap {
signedStakeByQuorum, ok := signedStakePerQuorum[quorumNum]
if !ok {
Expand All @@ -541,11 +562,20 @@ func checkIfStakeThresholdsMet(
return false
}

logger.Debug("Stakes for quorum",
"quorumNum", quorumNum,
"totalStakeByQuorum", totalStakeByQuorum,
"signedStakeByQuorum", signedStakeByQuorum)

// we check that signedStake >= totalStake * quorumThresholdPercentage / 100
// to be exact (and do like the contracts), we actually check that
// signedStake * 100 >= totalStake * quorumThresholdPercentage
signedStake := big.NewInt(0).Mul(signedStakeByQuorum, big.NewInt(100))
thresholdStake := big.NewInt(0).Mul(totalStakeByQuorum, big.NewInt(int64(quorumThresholdPercentage)))

logger.Debug("Checking if signed stake is greater than threshold",
"signedStake", signedStake,
"thresholdStake", thresholdStake)
if signedStake.Cmp(thresholdStake) < 0 {
return false
}
Expand Down

0 comments on commit cd86e21

Please sign in to comment.