Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a toggle in settings to never cache the nonce for development #16332

Open
shanejonas opened this issue Oct 31, 2022 · 3 comments
Open

Add a toggle in settings to never cache the nonce for development #16332

shanejonas opened this issue Oct 31, 2022 · 3 comments

Comments

@shanejonas
Copy link
Contributor

Describe the bug

In development for MetaMask or Smart Contracts I am constantly restarting my local dev node which resets the nonce. And when I try to use MetaMask after, I am forced to go into settings and Reset Account.

Steps to reproduce

  1. Use ganache for local dev
  2. Make a tx with metamask on localhost
  3. restart ganache
  4. try to make another tx with metamask on localhost

Error messages or log output

No response

Version

10.20.0

Build type

No response

Browser

Chrome

Operating system

MacOS

Hardware wallet

No response

Additional context

No response

@zcstarr
Copy link

zcstarr commented Oct 31, 2022

+1

@danfinlay
Copy link
Contributor

The reason this behavior exists is because when submitting to Infura (a load balanced cluster), each node might return a different nonce (since they might be aware of different pending transactions). This is why we cache local txs, and use the greatest nonce of our local + RPC views.

If we wanted to ignore the local tx cache, it might have to be some special case, like

  • a per RPC setting
  • Only for localhost?

@ondratra
Copy link

ondratra commented Feb 7, 2023

Error messages or log output

No response

It is worth noting that MetaMask has improved error message for this issue now: Nonce too high. Expected nonce to be 0 but got 90 (90 represents the nonce used on the network before restart.)

The reason this behavior exists is because when submitting to Infura (a load balanced cluster), each node might return a different nonce (since they might be aware of different pending transactions). This is why we cache local txs, and use the greatest nonce of our local + RPC views.

If we wanted to ignore the local tx cache, it might have to be some special case, like

  • a per RPC setting
  • Only for localhost?

I would like to see another option:

  • a per-account settings

This will be handy when using one of the accounts that are pre-generated by HardHat, Ganache, etc., testing blockchains. Usually, 10 accounts are pre-generated at the testing blockchain startup. Once a developer marks an account as testing, they will be able to send transactions even after network restart (meaning destroy & recreate).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants