Skip to content

feat: add asynchronous nonce manager for multi-account soroban transa… - #78

Merged
elizabetheonoja-art merged 3 commits into
Utility-Protocol:mainfrom
dev-king-001:main
Jun 24, 2026
Merged

feat: add asynchronous nonce manager for multi-account soroban transa…#78
elizabetheonoja-art merged 3 commits into
Utility-Protocol:mainfrom
dev-king-001:main

Conversation

@dev-king-001

Copy link
Copy Markdown
Contributor

Title

feat: Add Asynchronous Nonce Manager for Multi-Account Soroban Transactions

Description

What was done

  • Implemented an asynchronous singleton NonceManager (src/services/nonceManager.ts) to pre-fetch and handle a pool of 20 nonces per account.
  • Implemented an internal pub/sub Redux-like store (src/store/slices/nonceSlice.ts) tracking the nonce state, avoiding the need for heavy new Redux dependencies.
  • Wrapped the Soroban RPC transaction submissions inside submitWithNonce (src/services/soroban.ts) to handle blockchain failures.
  • Added a new React hook useNonceManager() to safely acquire and lease nonces to components with a 120-second lease timeout.
  • Hooked the NonceManager flush and initialize steps into the useWallet / WalletProvider lifecycle so that changing accounts safely flushes the active nonce queue to prevent invalid sequence collisions.

Why it was done
Soroban transactions from the dashboard require sequential nonce management per source account. With multiple UI components submitting transactions concurrently, they risk nonce collisions or sequence gaps. This Asynchronous Nonce Manager with pool pre-fetching completely mitigates these race conditions and sequence misalignments by leasing nonces out sequentially and providing automatic queue flushing and sequence re-fetching upon any tx_bad_seq failures.

How it was verified

  • Verified through robust integration testing in src/tests/nonceManager.test.ts.
  • Tested 5 concurrent lease acquisitions and confirmed sequential assignment with correct pool decrements.
  • Mocked out-of-band on-chain sequence advances and successfully tested the tx_bad_seq catch, flush, re-fetch, and automatic transaction reconstruction / retry loop without component disruption.

Closes #58

@elizabetheonoja-art elizabetheonoja-art left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@elizabetheonoja-art
elizabetheonoja-art merged commit 8382d4f into Utility-Protocol:main Jun 24, 2026
4 checks passed
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.

Asynchronous Nonce Manager for Multi-Account Soroban Transaction Sequencing with Pool Pre-Fetching

3 participants