Skip to content

Commit

Permalink
fix: mempool full retry logic (#225)
Browse files Browse the repository at this point in the history
* fix: mempool full retry logic
  • Loading branch information
debendraoli authored Jul 11, 2024
1 parent fef22fd commit f49a76e
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions relayer/chains/wasm/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ var (
rtyAttNum = uint(5)
rtyAtt = retry.Attempts(rtyAttNum)
rtyDel = retry.Delay(time.Millisecond * 400)
memPoolDel = retry.Delay(time.Second * 30)
specialDel = retry.Delay(time.Second * 30)
rtyErr = retry.LastErrorOnly(true)
numRegex = regexp.MustCompile("[0-9]+")
defaultBroadcastWaitTimeout = 10 * time.Minute
Expand Down Expand Up @@ -835,20 +835,15 @@ func (ap *WasmProvider) SendMessagesToMempool(
}

if msg.Type() == MethodUpdateClient {
delay := retry.Delay(time.Millisecond * time.Duration(ap.PCfg.BlockInterval))
retryAttempt := rtyAtt
if err := retry.Do(func() error {
if err := ap.BroadcastTx(cliCtx, txBytes, []provider.RelayerMessage{msg}, asyncCtx, defaultBroadcastWaitTimeout, asyncCallback, true); err != nil {
ap.log.Error("Failed to update client", zap.Any("Message", msg), zap.Error(err))
if strings.Contains(err.Error(), sdkerrors.ErrWrongSequence.Error()) {
ap.handleAccountSequenceMismatchError(err)
} else if strings.Contains(err.Error(), sdkerrors.ErrMempoolIsFull.Error()) {
ap.log.Info("Mempool is full, retrying later with increased delay")
delay = memPoolDel
retryAttempt = retry.Attempts(0)
}
}
return err
}, retry.Context(ctx), retryAttempt, delay, rtyErr); err != nil {
}, retry.Context(ctx), retry.Attempts(0), specialDel, rtyErr); err != nil {
ap.log.Error("Failed to update client", zap.Any("Message", msg))
return err
}
Expand Down

0 comments on commit f49a76e

Please sign in to comment.