Delay between confirming a transaction and incrementing the transaction count
See original GitHub issueWhen using --fork
mode with Infura, the account nonce does not always increment immediately after performing a transaction. In some cases, particularly after deploying a large contract, I’ve had to wait up to 3 seconds before the nonce proper increments.
Expected Behavior
- Call
eth_getTransactionCount
to get the nonce for an account. - Call
eth_sendTransaction
to send a transaction from the same account as step 1. - Call
eth_getTransactionReceipt
to verify that the transaction from step 2 has been confirmed. - Call
eth_getTransactionCount
on the same account, and receive a value that is +1 from the value received in the first step.
Current Behavior
In step 4, the value returned is sometimes identical to the value in step 1. After deploying a contract, I’m seeing a typical delay of 1 to 3 seconds before it increments. For transactions the delay is usually much smaller (less than 1/10th of a second) but does still exist.
Possible Solution
It’s just a guess, but there must be some async logic happening after the txid is returned and prior to incrementing the transaction count. I’ve never encountered this bug in a purely local environment, so maybe the delay is a result of querying state from the actual mainnet. Adjusting the sequence of events so that the transaction count increments prior to returning the txid seems like a good solution.
Steps to Reproduce (for bugs)
Launch ganache in --fork
mode and then run a loop where you deploy contracts from the same account and then check the value of eth_getTransactionCount
immediately after each deployment.
Context
We’re trying to test a deployment script in a forked environment prior to deploying on the mainnet. The issue is not a blocker, we can simply sleep a few seconds between transactions. But it’s definitely a bug worth fixing.
Your Environment
- Version used:
Ganache CLI v6.9.1 (ganache-core: 2.10.2)
- Operating System and version: Unbuntu 20.04
- Link to your project: The issue was found on
curfefi/curve-pool-registry
but affects all projects using Ganache with Brownie
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (5 by maintainers)
Top GitHub Comments
This is likely fixed in the upcoming v7.0.0; we’ll add it to our list to validate that this is, in fact, the case.
Thanks! (Also hi @iamdefinitelyahuman 👋 )
Nothing is being cached, and I’m not using any subscriptions. The RPC calls i listed under “expected behavior” is the exact sequence of calls I’m making.
I have a downstream fix in place already (https://github.com/eth-brownie/brownie/pull/645) so it’s not a blocker by any means.