Skip to content

Commit

Permalink
feat: warning on agglayer rate limit (#122)
Browse files Browse the repository at this point in the history
* feat: retry on agglayer rate limit exceeded
  • Loading branch information
ToniRamirezM authored Oct 14, 2024
1 parent 3abdb5a commit 8e2015f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
7 changes: 7 additions & 0 deletions aggregator/agglayer/agglayer_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ import (
"github.com/ethereum/go-ethereum/common"
)

const errCodeAgglayerRateLimitExceeded int = -10007

var ErrAgglayerRateLimitExceeded = fmt.Errorf("agglayer rate limit exceeded")

// AgglayerClientInterface is the interface that defines the methods that the AggLayerClient will implement
type AgglayerClientInterface interface {
SendTx(signedTx SignedTx) (common.Hash, error)
Expand All @@ -39,6 +43,9 @@ func (c *AggLayerClient) SendTx(signedTx SignedTx) (common.Hash, error) {
}

if response.Error != nil {
if response.Error.Code == errCodeAgglayerRateLimitExceeded {
return common.Hash{}, ErrAgglayerRateLimitExceeded
}
return common.Hash{}, fmt.Errorf("%v %v", response.Error.Code, response.Error.Message)
}

Expand Down
7 changes: 5 additions & 2 deletions aggregator/aggregator.go
Original file line number Diff line number Diff line change
Expand Up @@ -945,9 +945,12 @@ func (a *Aggregator) settleWithAggLayer(
a.logger.Debug("final proof signedTx: ", signedTx.Tx.ZKP.Proof.Hex())
txHash, err := a.aggLayerClient.SendTx(*signedTx)
if err != nil {
a.logger.Errorf("failed to send tx to the agglayer: %v", err)
if errors.Is(err, agglayer.ErrAgglayerRateLimitExceeded) {
a.logger.Errorf("%s. Config param VerifyProofInterval should match the agglayer configured rate limit.", err)
} else {
a.logger.Errorf("failed to send tx to the agglayer: %v", err)
}
a.handleFailureToAddVerifyBatchToBeMonitored(ctx, proof)

return false
}

Expand Down

0 comments on commit 8e2015f

Please sign in to comment.