Skip to content

Atomic nonce manager for concurrent senders #75

Description

@koko1123

Motivation

Bots firing transactions from multiple threads race on eth_getTransactionCount. The standard fix -- a local atomic nonce cache with gap recovery -- is reimplemented by every consumer (perpcity-zig-sdk built exactly this on top of eth.zig; it belongs upstream).

Scope

New src/nonce_manager.zig:

  • NonceManager.init(provider, address) -- seeds from getTransactionCount(pending)
  • next() -- atomic fetch-and-increment, no RPC on the hot path
  • onFailure(nonce) -- return a nonce to the pool / trigger resync; resync() for explicit recovery after dropped txs
  • Optional integration: Wallet accepts a *NonceManager instead of per-send RPC lookup

Pointers

std.atomic.Value(u64); keep RPC out of next(); document the gap-on-failure semantics carefully (nonces are only reusable until a higher one confirms).

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is neededmevMEV/searcher tooling

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions