check_nonce_mismatch
Documentation for eth_defi.confirmation.check_nonce_mismatch function.
- check_nonce_mismatch(web3, txs, retries=3, retry_delay=datetime.timedelta(seconds=1))
Check for nonce re-use issues.
Compare pre-signed transactions with on-chain addresses’ nonce states. The nonce is owned solely by our internal hot wallet counter, so the on-chain nonce must match our expected nonce exactly — strict equality is intentional and preserved.
The happy path is a single
get_transaction_countread (unchanged). Only when that first read disagrees do we re-sample every fallback node and trust the most up-to-date one (highest block number): on an eventually-consistent multi-node RPC a single node can lag a transaction behind and return a stale count, which previously crashed the live loop. We raise only if the mismatch persists on the most-advanced node across all retries — a genuine desync — and include a per-node block/nonce diagnostic so the lagging node is obvious. Seedeps/web3-ethereum-defi/docs/README-hyperevm-goldsky-failure.md.- Parameters
web3 (web3.main.Web3) – Web3 connection, ideally a fallback provider over multiple nodes.
txs (Collection[Union[eth_account.datastructures.SignedTransaction, eth_defi.hotwallet.SignedTransactionWithNonce]]) – Pre-signed transactions to validate. May span multiple addresses; the lowest nonce per address is checked.
retries (int) – How many times to re-sample the nodes when the first read mismatches.
retry_delay (datetime.timedelta) – Sleep between resamples, giving a lagging node time to catch up. Total added wall-clock is bounded by
(retries - 1) * retry_delay.
- Raises
NonceMismatch – If the most up-to-date node still disagrees with our expected nonce after retries, or duplicate nonces appear in the same batch.