Summary
NonceManager::init calls eth_getTransactionCount to seed the local nonce counter. If the alloy default block tag (Latest) is used, any transactions submitted by a previous bot run that are still pending in the mempool are invisible. The manager starts at the mined nonce, re-issues those nonces, and the new txs will either:
- Replace the old pending txs (if
max_fee is higher) — unintended replacement of a previous liquidation with different params
- Be rejected by the node as nonce-already-used if the old tx is already in mempool with same or higher fee
The correct call uses the Pending block tag:
provider
.get_transaction_count(signer.address())
.block_id(BlockId::Tag(BlockNumberOrTag::Pending))
.await
This exact bug was flagged as Finding 2 in PR #41 for the old TxBuilder nonce handling. The nonce manager is the intended fix — if it makes the same mistake, the fix is incomplete and PR #41 Finding 2 remains open.
File
crates/charon-executor/src/nonce.rs — NonceManager::init()
Risk
On bot restart after a crash (the most important scenario for the nonce manager), re-issued nonces silently replace or collide with pending liquidation txs in the BSC mempool.
Refs #43
Summary
NonceManager::initcallseth_getTransactionCountto seed the local nonce counter. If the alloy default block tag (Latest) is used, any transactions submitted by a previous bot run that are still pending in the mempool are invisible. The manager starts at the mined nonce, re-issues those nonces, and the new txs will either:max_feeis higher) — unintended replacement of a previous liquidation with different paramsThe correct call uses the
Pendingblock tag:provider .get_transaction_count(signer.address()) .block_id(BlockId::Tag(BlockNumberOrTag::Pending)) .awaitThis exact bug was flagged as Finding 2 in PR #41 for the old TxBuilder nonce handling. The nonce manager is the intended fix — if it makes the same mistake, the fix is incomplete and PR #41 Finding 2 remains open.
File
crates/charon-executor/src/nonce.rs—NonceManager::init()Risk
On bot restart after a crash (the most important scenario for the nonce manager), re-issued nonces silently replace or collide with pending liquidation txs in the BSC mempool.
Refs #43