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

Metamask nonce issue #156

Closed
jtremback opened this issue Jul 10, 2018 · 5 comments
Closed

Metamask nonce issue #156

jtremback opened this issue Jul 10, 2018 · 5 comments
Labels
🐛 bug An unexpected behavior of the API

Comments

@jtremback
Copy link
Contributor

I was running into this issue: MetaMask/metamask-extension#1999

I fixed it with this janky hack: e2509c2

Is there a better long term solution?

@izqui
Copy link
Contributor

izqui commented Jul 10, 2018

I was missing this context when reviewing #155 and I think my addition to it setting the network id to 15 won't be fixing your problem. This commit should be reverted f7c25c1

Trying to think about the implications of starting with a different network_id every time. I assume that you started noticing the issue after doing a devchain --reset (or run --reset) and metamask was still trying to send transactions with the cached nonce.

However I don't really understand how your hack may have fixed the issue, as right now every time you run aragon devchain the network id changes (if no network id is passed, ganache defaults to setting the current timestamp as the network id).

@izqui izqui added the 🐛 bug An unexpected behavior of the API label Jul 10, 2018
@jtremback
Copy link
Contributor Author

Yea, what I actually do is run devchain on my modified aragon-cli, and leave it up for a while. This works for a long time. When the nonce issue shows up, I restart devchain and it goes away for another long time.

@jtremback
Copy link
Contributor Author

Also, maybe just restarting devchain was enough and I'm fooling myself into thinking it needed more.

@izqui
Copy link
Contributor

izqui commented Jul 11, 2018

Are you running aragon devchain directly rather than it being started by aragon run every time you execute it?

If that's the case, I think I know what the root of issue may be:

  • aragon devchain starts the network with a random network id (the timestamp).
  • aragon run performs some transactions incrementing the nonce of the main account
  • Using the app with metamask caches the nonce when performing sending transactions via Metamask
  • Doing aragon run or any other action that sends transactions from the CLI increments the nonce of the account.
  • When using metamask again, it assumes the nonce should be the one it has cached, not being aware that the CLI has sent more transactions.

In order to circumvent the issue you can either not run aragon devchain independently and just rely on aragon run starting it every time (which will start it with another networkId) or do a 'Reset Account' in Metamask which will invalidate the nonce cache.

@izqui
Copy link
Contributor

izqui commented Aug 10, 2018

@jtremback I investigated the issue a bit more, and I think it is now solved. I brought back your idea of randomizing the network id every time the chain is started (I didn't detect any side effects). Sometimes Metamask is still stuck even if the networkID changes, but switching to another network and then switching back seems to resolve it in all cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug An unexpected behavior of the API
Projects
None yet
Development

No branches or pull requests

2 participants