-
Notifications
You must be signed in to change notification settings - Fork 0
Open
@tac0turtle
Description
Summary
Implement local nonce (sequence number) tracking and correction for blob transaction submission.
Context
Parent: #4
Cosmos chains use account sequence numbers as nonces. Correct nonce management is critical — wrong sequence = rejected tx.
celestia-node's approach (query once at startup, increment locally, regex-parse error strings on mismatch) works but is fragile. We should rebuild this simpler and more robust.
Design
Core behavior
- Startup: Query on-chain account sequence via
auth.QueryAccountgRPC - On broadcast: Use local sequence, increment optimistically
- On success: Keep incremented value
- On
ErrWrongSequence: Re-query on-chain sequence (don't regex-parse error strings), re-sign, retry (max 3 attempts) - On other failure: Do not increment, return error to caller
Thread safety
- Mutex around sequence read/increment/broadcast for single-account use
- Per-account mutex when multi-account is enabled (Multi-account support for transaction submission #5 )
Interface
type NonceManager interface { // NextSequence returns the next sequence number for the given address. // Blocks if another tx is in-flight for this address. NextSequence(ctx context.Context, address string) (uint64, error) // Commit confirms the sequence was used successfully. Commit(address string) // Rollback indicates the sequence was not used (tx failed). Rollback(address string) // Reset re-queries the on-chain sequence for the given address. Reset(ctx context.Context, address string) error }
Error handling
- Check ABCI error codes directly where possible, not error string patterns
- Wrap errors with context: address, expected sequence, actual sequence, attempt number
Non-goals
- Parallel nonce assignment for the same account (handled by Multi-account support for transaction submission #5 multi-account instead)
- Speculative nonce gaps (always sequential)
Metadata
Metadata
Assignees
Labels
No labels