Skip to main content

Module wallet_lock

Module wallet_lock 

Source
Expand description

F9: exclusive file-lock guarding wallet-signing operations against concurrent taskfast post invocations sharing the same keystore.

§What this prevents

Tempo (like any EVM network) uses a monotonic per-address nonce. If two processes both call eth_getTransactionCount(addr, "latest") at the same moment, both get the same value, both sign a tx with that nonce, and the RPC drops whichever arrives second. The scenario is realistic for a multi-worker agent farm pointed at one wallet.

§Scope

Advisory, best-effort. We hold an OS-level exclusive lock on a file adjacent to the keystore from just before eth_getTransactionCount until after the raw tx has been submitted. A crash between those points releases the lock cleanly (the kernel drops it on fd close), so there’s no stale-lock problem. The lock does not serialize wallets across different hosts — operators with multi-host setups must still keep per-host nonce coordination in mind.

Structs§

WalletGuard
RAII handle releasing the lock on drop. Held for the entire sign+broadcast critical section.

Functions§

acquire
Acquire an exclusive file-lock keyed off the keystore path.