Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

go/consensus/api/submission: Always clear nonce on error #5972

Merged
merged 1 commit into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading