Feature request: wait for n confirmations between migration transactions (nonce too low error with Infura)
See original GitHub issueIssue
Deploying to mainnet via INFURA using Truffle is susceptible to breaking. Errors I’ve seen:
gas price too low
This happens when a tx is in the mempool and you send another tx with the same nonce.
nonce too low
This happens when a tx has been mined but you send another tx with the same nonce.
These things can happen when you talk to INFURA because they run many nodes behind a load balancer. Lets say you send a tx to node A, which later tells you the tx has been mined. Truffle now prepares to move onto the next tx it needs to send and queries INFURA for the nonce it should use for the sending address, and happens to get routed to node B. The block that node A saw hasn’t propagated to node B yet, so node B tells you to use the nonce of the prior transaction!
Steps to Reproduce
You can’t reproduce it deterministically, and it really only happens on mainnet because the peering situation is apparently bad, but try deploying something with a few txs to mainnet. Use this repo if you like: https://github.com/skmgoldin/tcr
Expected Behavior
The issue could be resolved if I could specify to Truffle a number of blocks to wait after a tx has been mined before sending the next tx.
When the number of blocks has elapsed, Truffle should double check at that point that the original transaction was actually mined, since it’s possible it got the original mined alert for a block that ultimately wound up uncle’d. If that block was in fact uncle’d, wait again for the tx to be mined and repeat.
Actual Results
I can’t specify a block depth to wait on. So I get these failures.
Environment
- Operating System: Ubuntu 16
- Truffle version: 4.0.5
- Ethereum client: INFURA
- node version: 8
- npm version: 5
Issue Analytics
- State:
- Created 6 years ago
- Reactions:8
- Comments:10 (1 by maintainers)
Small update @skmgoldin.
This is a really good idea - adding it to the work underway to migrate to Web3 1.0 at truffle-contract 95. We could have
truffle-deployer
expose Web3’s new event emitter interface and the pattern for waiting might look something like:For record keeping, these are related:
I got stuck on this issue too. This workaround solved it for me: https://ethereum.stackexchange.com/questions/44349/truffle-infura-on-mainnet-nonce-too-low-error