Skip to content

Commit

Permalink
Merge pull request #5972 from oasisprotocol/peternose/trivial/reset-n…
Browse files Browse the repository at this point in the history
…once

go/consensus/api/submission: Always clear nonce on error
  • Loading branch information
peternose authored Dec 13, 2024
2 parents d548cc2 + 512125a commit 907d604
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 907d604

Please sign in to comment.