Skip to content

Commit 907d604

Browse files
authored
Merge pull request #5972 from oasisprotocol/peternose/trivial/reset-nonce
go/consensus/api/submission: Always clear nonce on error
2 parents d548cc2 + 512125a commit 907d604

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

.changelog/5972.trivial.md

Whitespace-only changes.

go/consensus/api/submission.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,14 +176,18 @@ func (m *submissionManager) signAndSubmitTx(ctx context.Context, signer signatur
176176
err = m.backend.SubmitTx(ctx, sigTx)
177177
}
178178
if err != nil {
179+
// If the transaction check fails (which cannot be determined from
180+
// the error), the nonce in the cache should be either decremented
181+
// or cleared to ensure consistency.
182+
m.clearSignerNonce(signerAddr)
183+
179184
switch {
180185
case errors.Is(err, transaction.ErrUpgradePending):
181186
// Pending upgrade, retry submission.
182187
m.logger.Debug("retrying transaction submission due to pending upgrade")
183188
return nil, nil, err
184189
case errors.Is(err, transaction.ErrInvalidNonce):
185190
// Invalid nonce, retry submission.
186-
m.clearSignerNonce(signerAddr)
187191
m.logger.Debug("retrying transaction submission due to invalid nonce",
188192
"account_address", signerAddr,
189193
"nonce", tx.Nonce,

0 commit comments

Comments
 (0)