Skip to content

Implement NonceManager with atomic sequence reservation #1

Description

@N-thnI

Description

Add the core nonce/sequence manager that replaces three diverging implementations.

Problem Statement

Sequence management is currently implemented three times: vero-core-engine/engine-bridge/src/nonce-manager.ts, vero-relayer-service/src/relayer/nonceManager.js, and ad-hoc handling in the dashboard. That divergence has already produced separately-filed bugs — vero-core-engine#164 (check-then-act race in reserve()), #183 (refresh() bypasses the per-account lock), and vero-relayer-service#198 (a cached sequence served from inside the lock, causing tx_bad_seq at default concurrency). Consolidating means this class of bug gets fixed once instead of three times.

Proposed Changes

  • Create src/nonce/index.ts exporting a NonceManager class
  • reserve(account) returns the next sequence and marks it consumed in a single atomic step — no observable window between read and write
  • Track reservations per account, keyed by public key
  • Never serve a cached sequence value from inside a reservation; see the sibling locking issue
  • Export from src/index.ts

Technical Implementation Scaffolding

  • Target Repository: vero-sdk
  • Target Path: src/nonce/index.ts
  • Branch Naming: feat/issue--nonce-manager-core
  • Authority Context: Security-sensitive — transaction sequencing

Acceptance Criteria

  • Two concurrent reserve() calls for the same account never return the same sequence
  • Reservations for different accounts do not block each other
  • Unit tests cover the concurrent case explicitly
  • npm test, npm run typecheck, npm run lint, and npm run build all pass

Definition of Done

  • Reviewed by lead maintainer
  • Pull request merged via verified status check

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardThird CampaignCampaign: Third Campaign

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions