Stop concurrent NEAR workers from reusing an access-key nonce
Two signing workers can read the same on-chain nonce while both are preparing transactions. The access key is the unit that must own the sequence.
Identify the contended sequence
Replace the public key and signer with those that failed. Keep the network, account and public key together in the local queue key. Distinct access keys on one account have their own counters.
{
"jsonrpc": "2.0",
"id": 1,
"method": "query",
"params": {
"request_type": "view_access_key",
"finality": "final",
"account_id": "worker.testnet",
"public_key": "ed25519:PUBLIC_KEY"
}
}
Serialize submission and recover after a timeout
If the observed nonce is 500, two workers independently choosing 501 will collide. A single sender can allocate 501 and wait for its acceptance before using 502. Merely reserving numbers under a lock still permits 502 to land before 501, making the earlier nonce stale.
Persist the signed transaction hash with the reservation. After an ambiguous network timeout, query its outcome and refresh the access-key state before deciding whether the business operation needs another signature.