question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Delay between confirming a transaction and incrementing the transaction count

See original GitHub issue

When 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

  1. Call eth_getTransactionCount to get the nonce for an account.
  2. Call eth_sendTransaction to send a transaction from the same account as step 1.
  3. Call eth_getTransactionReceipt to verify that the transaction from step 2 has been confirmed.
  4. 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:closed
  • Created 3 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
gnidancommented, Mar 24, 2021

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 👋 )

1reaction
iamdefinitelyahumancommented, Jun 20, 2020

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Delay between confirming a transaction and incrementing the ...
When using --fork mode with Infura, the account nonce does not always increment immediately after performing a transaction.
Read more >
sql server - transaction() doesn't increment @@TRANCOUNT?
After that, first db.commit() confirms all changes (by sending "SQLEndTran" command) and change mode back to "auto commit mode" again.
Read more >
How To Use Confirmation Delay Of Transactions - Collect! Help
Enter the number of confirmation delay days on the Payment Posting Options form. Then switch this ON for a given Transaction Type or...
Read more >
Returned error: Transaction nonce is too low. Try incrementing ...
Try incrementing the nonce. I get my nonce this way: const nonce = web3.eth.getTransactionCount(account);. I have double- ...
Read more >
Considerations for the autogrow and autoshrink - SQL Server
If the growth increment is large or there is some other factor that causes it to take a long time, the query in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found