From 055b603bd779b7d3f097a8d72a1cb54b004520ad Mon Sep 17 00:00:00 2001 From: Intizar Tashov Date: Wed, 28 Aug 2024 11:27:18 +0900 Subject: [PATCH] handle context deadline exceeded in direct tx (#2243) --- node/pkg/chain/helper/helper.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/node/pkg/chain/helper/helper.go b/node/pkg/chain/helper/helper.go index c81039ddb..757f2bd60 100644 --- a/node/pkg/chain/helper/helper.go +++ b/node/pkg/chain/helper/helper.go @@ -272,7 +272,9 @@ func (t *ChainHelper) SubmitDelegatedFallbackDirect(ctx context.Context, contrac if err != nil { if utils.ShouldRetryWithSwitchedJsonRPC(err) { clientIndex = (clientIndex + 1) % len(t.clients) - } else if errors.Is(err, errorSentinel.ErrChainTransactionFail) || utils.IsNonceError(err) || err == context.DeadlineExceeded { + } else if errors.Is(err, errorSentinel.ErrChainTransactionFail) { + return err // if transaction fails, the data will probably be too old to retry + } else if utils.IsNonceError(err) || err == context.DeadlineExceeded { nonce, err = noncemanager.GetAndIncrementNonce(t.wallet) if err != nil { return err @@ -297,7 +299,9 @@ func (t *ChainHelper) SubmitDelegatedFallbackDirect(ctx context.Context, contrac if err != nil { if utils.ShouldRetryWithSwitchedJsonRPC(err) { clientIndex = (clientIndex + 1) % len(t.clients) - } else if errors.Is(err, errorSentinel.ErrChainTransactionFail) || utils.IsNonceError(err) { + } else if errors.Is(err, errorSentinel.ErrChainTransactionFail) { + return err // if transaction fails, the data will probably be too old to retry + } else if utils.IsNonceError(err) || err == context.DeadlineExceeded { nonce, err = noncemanager.GetAndIncrementNonce(t.wallet) if err != nil { return err