Skip to content

fix(engine-bridge): release nonce on tx-aggregator execution failure - #229

Open
xeladev4 wants to merge 1 commit into
Vero-protocol:mainfrom
xeladev4:fix/tx-aggregator-nonce-leak
Open

fix(engine-bridge): release nonce on tx-aggregator execution failure#229
xeladev4 wants to merge 1 commit into
Vero-protocol:mainfrom
xeladev4:fix/tx-aggregator-nonce-leak

Conversation

@xeladev4

Copy link
Copy Markdown

Summary

Fixes a critical nonce leak bug in TxAggregator.execute() where reserved sequence numbers were never released when transaction submission failed before reaching the ledger. This caused permanent desynchronization between the in-process nonce cache and the real account sequence, leading to tx_bad_seq errors and eventual service outage.

Changes

  • Modified TxAggregator.execute() to accept optional sourceAccountId and sequence parameters
  • Added nonceManager.release() calls in both error paths:
    • When sendTransaction returns status "ERROR" (sequence never consumed on-chain)
    • When the poll-loop times out (sequence likely not consumed)
  • Updated all existing test cases to pass the new parameters
  • Added two regression tests:
    • "releases nonce on sendTransaction ERROR" - verifies nonce is released on submission failure
    • "releases nonce on poll-loop timeout" - verifies nonce is released on timeout

Testing

  • All existing tests pass (100 tests, 14 test suites)
  • New regression tests fail on the original code (demonstrating the bug) and pass after the fix
  • Lint passes with no new warnings (existing warnings are pre-existing)
  • Ran tests: cd engine-bridge && npm test
  • Ran lint: cd engine-bridge && npm run lint

Security Considerations

This fix prevents a denial-of-service condition where the nonce cache could drift ahead of the real account sequence, causing all subsequent transactions to fail with tx_bad_seq. This is a reliability/security issue for the fund-moving path.

Checklist

  • Tests added / updated
  • Docs updated if behavior changed (no breaking changes, just internal fix)
  • No secrets committed
  • Breaking changes noted in footer (no breaking changes - parameters are optional)

Closes #181

Fixes nonce leak in TxAggregator.execute() when submission fails before
reaching the ledger. Previously, reserved nonces were never released on
sendTransaction ERROR or poll-loop timeout, causing permanent desync
between the in-process cache and the real account sequence.

Changes:
- Add optional sourceAccountId and sequence parameters to execute()
- Call nonceManager.release() on ERROR and timeout paths
- Update all existing tests to pass the new parameters
- Add regression tests for nonce release on both failure paths

Closes Vero-protocol#181
@xeladev4
xeladev4 requested review from N-i-xx and N-thnI as code owners August 30, 2026 06:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] TxAggregator.execute() leaks reserved nonces on failed/timed-out submissions, permanently desyncing the account's sequence cache

1 participant