Skip to content

Commit

Permalink
fix retry logic
Browse files Browse the repository at this point in the history
  • Loading branch information
iansuvak committed Dec 13, 2024
1 parent f9f7f3d commit 32d1197
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions signature-aggregator/aggregator/aggregator.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,9 @@ var (
corethCodec = corethMsg.Codec

// Errors
errNotEnoughSignatures = errors.New("failed to collect a threshold of signatures")
errNotEnoughConnectedStake = errors.New("failed to connect to a threshold of stake")
errNotEnoughSignatures = errors.New("failed to collect a threshold of signatures")
errNotEnoughConnectedStake = errors.New("failed to connect to a threshold of stake")
errFailedToSendToSufficientStake = errors.New("failed to send to a threshold of stake")
)

type SignatureAggregator struct {
Expand Down Expand Up @@ -225,8 +226,10 @@ func (s *SignatureAggregator) CreateSignedMessage(
return nil, fmt.Errorf("%s: %w", msg, err)
}

ATTEMPT:
// Query the validators with retries. On each retry, query one node per unique BLS pubkey
for attempt := 1; attempt <= maxQueryAttempts; attempt++ {

Check failure on line 231 in signature-aggregator/aggregator/aggregator.go

View workflow job for this annotation

GitHub Actions / golangci

unnecessary leading newline (whitespace)

responsesExpected := len(connectedValidators.ValidatorSet) - len(signatureMap)
s.logger.Debug(
"Aggregator collecting signatures from peers.",
Expand Down Expand Up @@ -296,12 +299,16 @@ func (s *SignatureAggregator) CreateSignedMessage(
connectedValidators.TotalValidatorWeight,
inverseQuorumNum,
) {
s.logger.Warn("Failed to send to a threshold of stake",
s.logger.Error("Failed to send to a threshold of stake",
zap.Uint64("connectedWeight", connectedValidators.ConnectedWeight),
zap.Uint64("totalValidatorWeight", connectedValidators.TotalValidatorWeight),
zap.Uint64("quorumPercentage", quorumPercentage),
)
return nil, errNotEnoughConnectedStake
if attempt != maxQueryAttempts {
time.Sleep(time.Duration(signatureRequestRetryWaitPeriodMs/maxQueryAttempts) * time.Millisecond)
continue ATTEMPT
}
return nil, errFailedToSendToSufficientStake
}
}
}
Expand Down

0 comments on commit 32d1197

Please sign in to comment.