Skip to content

Commit

Permalink
go/consensus/api/submission: Always clear nonce on error
Browse files Browse the repository at this point in the history
  • Loading branch information
peternose committed Dec 13, 2024
1 parent d548cc2 commit 512125a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
Empty file added .changelog/5972.trivial.md
Empty file.
6 changes: 5 additions & 1 deletion go/consensus/api/submission.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,14 +176,18 @@ func (m *submissionManager) signAndSubmitTx(ctx context.Context, signer signatur
err = m.backend.SubmitTx(ctx, sigTx)
}
if err != nil {
// If the transaction check fails (which cannot be determined from
// the error), the nonce in the cache should be either decremented
// or cleared to ensure consistency.
m.clearSignerNonce(signerAddr)

switch {
case errors.Is(err, transaction.ErrUpgradePending):
// Pending upgrade, retry submission.
m.logger.Debug("retrying transaction submission due to pending upgrade")
return nil, nil, err
case errors.Is(err, transaction.ErrInvalidNonce):
// Invalid nonce, retry submission.
m.clearSignerNonce(signerAddr)
m.logger.Debug("retrying transaction submission due to invalid nonce",
"account_address", signerAddr,
"nonce", tx.Nonce,
Expand Down

0 comments on commit 512125a

Please sign in to comment.