From 6f52380f7216fb0463c2ab56b146040ec3ca3441 Mon Sep 17 00:00:00 2001 From: Santos Rosati Date: Mon, 5 Aug 2024 12:02:27 -0300 Subject: [PATCH 1/3] feat: improve bls aggregtion service logging --- services/bls_aggregation/blsagg.go | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/services/bls_aggregation/blsagg.go b/services/bls_aggregation/blsagg.go index bdab6691..64563adf 100644 --- a/services/bls_aggregation/blsagg.go +++ b/services/bls_aggregation/blsagg.go @@ -228,10 +228,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(), quorumNumbers, taskCreatedBlock) if err != nil { @@ -254,6 +262,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 { @@ -295,6 +307,10 @@ func (a *BlsAggregatorService) singleTaskAggregatorGoroutineFunc( signersTotalStakePerQuorum: cloneStakePerQuorumMap(operatorsAvsStateDict[signedTaskResponseDigest.OperatorId].StakePerQuorum), } } else { + a.logger.Debug("Task goroutine updating existing aggregated operators", + "taskIndex", taskIndex, + "taskResponseDigest", taskResponseDigest) + digestAggregatedOperators.signersAggSigG1.Add(signedTaskResponseDigest.BlsSignature) digestAggregatedOperators.signersApkG2.Add(operatorsAvsStateDict[signedTaskResponseDigest.OperatorId].OperatorInfo.Pubkeys.G2Pubkey) digestAggregatedOperators.signersOperatorIdsSet[signedTaskResponseDigest.OperatorId] = true @@ -312,6 +328,10 @@ func (a *BlsAggregatorService) singleTaskAggregatorGoroutineFunc( aggregatedOperatorsDict[taskResponseDigest] = digestAggregatedOperators if checkIfStakeThresholdsMet(a.logger, digestAggregatedOperators.signersTotalStakePerQuorum, totalStakePerQuorum, quorumThresholdPercentagesMap) { + a.logger.Debug("Task goroutine found enough stake to aggregate", + "taskIndex", taskIndex, + "taskResponseDigest", taskResponseDigest) + nonSignersOperatorIds := []types.OperatorId{} for operatorId := range operatorsAvsStateDict { if _, operatorSigned := digestAggregatedOperators.signersOperatorIdsSet[operatorId]; !operatorSigned { @@ -436,6 +456,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 { @@ -454,11 +475,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 } From 29f4d3457921b42b34c82d02edeea9ade312cdbc Mon Sep 17 00:00:00 2001 From: Santos Rosati Date: Mon, 5 Aug 2024 12:47:52 -0300 Subject: [PATCH 2/3] refactor: logs --- services/bls_aggregation/blsagg.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/services/bls_aggregation/blsagg.go b/services/bls_aggregation/blsagg.go index 64563adf..60b02e8c 100644 --- a/services/bls_aggregation/blsagg.go +++ b/services/bls_aggregation/blsagg.go @@ -307,7 +307,7 @@ func (a *BlsAggregatorService) singleTaskAggregatorGoroutineFunc( signersTotalStakePerQuorum: cloneStakePerQuorumMap(operatorsAvsStateDict[signedTaskResponseDigest.OperatorId].StakePerQuorum), } } else { - a.logger.Debug("Task goroutine updating existing aggregated operators", + a.logger.Debug("Task goroutine updating existing aggregated operator signatures", "taskIndex", taskIndex, "taskResponseDigest", taskResponseDigest) @@ -328,7 +328,7 @@ func (a *BlsAggregatorService) singleTaskAggregatorGoroutineFunc( aggregatedOperatorsDict[taskResponseDigest] = digestAggregatedOperators if checkIfStakeThresholdsMet(a.logger, digestAggregatedOperators.signersTotalStakePerQuorum, totalStakePerQuorum, quorumThresholdPercentagesMap) { - a.logger.Debug("Task goroutine found enough stake to aggregate", + a.logger.Debug("Task goroutine stake threshold reached", "taskIndex", taskIndex, "taskResponseDigest", taskResponseDigest) From 7a4a8092ce5c10fae7c47c7a5dc4132f88b9a789 Mon Sep 17 00:00:00 2001 From: Santos Rosati Date: Wed, 7 Aug 2024 17:53:37 -0300 Subject: [PATCH 3/3] chore: fix whitespace --- services/bls_aggregation/blsagg.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/services/bls_aggregation/blsagg.go b/services/bls_aggregation/blsagg.go index 8c83afae..d3c630d6 100644 --- a/services/bls_aggregation/blsagg.go +++ b/services/bls_aggregation/blsagg.go @@ -392,10 +392,10 @@ func (a *BlsAggregatorService) singleTaskAggregatorGoroutineFunc( totalStakePerQuorum, quorumThresholdPercentagesMap, ) { - a.logger.Debug("Task goroutine stake threshold reached", + 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 {