truffle
truffle copied to clipboard
Forked network can't deploy if dryRun is true
- [ Y ] I've opened a support ticket before filing this issue.
Issue
Forked ethereum mainnet can't deploy any contract because insufficient fund (0 wei).
Steps to Reproduce
Env:
~# truffle version
Truffle v5.5.23 (core: 5.5.23)
Ganache v7.3.2
Solidity - 0.8.15 (solc-js)
Node v16.15.1
Web3.js v1.7.4
Ganache:
~# ganache-cli --fork https://mainnet.infura.io/v3/<infuraToken> --unlock "0xb527a981e1d415AF696936B3174f2d7aC8D11369" --chain.chainId 1
truffle-config.js network part:
mainfork: {
host: "127.0.0.1",
port: 8545,
network_id: 1,
}
truffle deploy
~# truffle deploy --network mainfork
Compiling your contracts...
===========================
> Compiling .\contracts\Migrations.sol
> Artifacts written to C:\Users\Bing\ethereum\BingProjects\truffle-ganache\build\contracts
> Compiled successfully using:
- solc: 0.8.15+commit.e14f2714.Emscripten.clang
Migrations dry-run (simulation)
===============================
> Network name: 'mainfork-fork'
> Network id: 1
> Block gas limit: 30000000 (0x1c9c380)
1_initial_migration.js
======================
Replacing 'Migrations'
----------------------
*** Deployment Failed ***
"Migrations" could not deploy due to insufficient funds
* Account: 0x85Fe0DC8cf7bAC660E781B001C0f084Abdc400c2
* Balance: 0 wei
* Balance: 0 wei
* Message: insufficient funds for gas * price + value -- Reason given: Custom error (could not decode).
* Try:
+ Using an adequately funded account
+ If you are using a local Geth node, verify that your node is synced.
at C:\Users\Bing\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\deployer\src\deployment.js:331:1
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at Migration._deploy (C:\Users\Bing\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\migrate\Migration.js:68:1)
at Migration._load (C:\Users\Bing\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\migrate\Migration.js:54:1)
at Migration.run (C:\Users\Bing\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\migrate\Migration.js:202:1)
at Object.runMigrations (C:\Users\Bing\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\migrate\index.js:142:1)
at Object.runFrom (C:\Users\Bing\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\migrate\index.js:107:1)
at Object.run (C:\Users\Bing\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\migrate\index.js:91:1)
at module.exports (C:\Users\Bing\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\core\lib\commands\migrate\runMigrations.js:10:1)
at module.exports (C:\Users\Bing\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\core\lib\commands\migrate\setUpDryRunEnvironmentThenRunMigrations.js:37:1)
at Object.module.exports [as run] (C:\Users\Bing\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\core\lib\commands\migrate\run.js:33:1)
at runCommand (C:\Users\Bing\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\core\lib\command-utils.js:184:1)
Truffle v5.5.23 (core: 5.5.23)
Node v16.15.1
Expected Behavior
Deploy success.
Actual Results
Deploy fails as mentioned above.
I found that skipping dryRun can by-pass this issue
But the default value is false, and I don't think everyone knows about it.
mainfork: {
host: "127.0.0.1",
port: 8545,
network_id: 1,
skipDryRun: true
}
Environment
- Operating System: Windows
- Ethereum client: N/A
- Truffle version (
truffle version): - node version (
node --version): - npm version (
npm --version):
Hi, I want to confirm my understanding of what's going on here. So, you are saying, that with skipDryRun, the deployment to mainfork succeeds, but with the dry-run enabled, the dry run fails due to insufficient funds? That's pretty surprising, because it means that the fork works fine, but the fork of the fork does not. Is that in fact what's going on? If it is, then this sounds like a Ganache issue. But I want to make sure I have that right before we try to do anything here because this is a little confusing. Thank you!
(Actually, while I'm at it, could I ask what the relevance is of the unlock address as opposed to the address doing the deployment? I was surprised to see that these are different. Is this relevant? Thanks!)
Hi @haltman-at,
Thanks for your reply!
Your understanding is correct. As the steps to reproduce demonstrates, seems that the fork is fine, but the fork of the fork is not correct. I'm not sure if this is truffle's issue or ganache. Since I executed with truffle command, I'm opening the ticket here.
I don't think the unlock option is relevant, I'm just randomly using an account with huge eth for learning purpose.
Since I have listed my environment above, could you execute the same command yourself and see if it can be reproduced?
Do you have a more complete reproduction example we could try? Say a repo we could check out? Thanks!
Hi @haltman-at,
Thanks for your suggestion. I've created a temporary repo for the example.
While I was testing this, I suddenly found that when I create the mainnet fork, I specified chain.chainId option.
If I directly start the mainnet fork like below, it won't complain during dryRun.
~# ganache-cli --fork https://mainnet.infura.io/v3/<infuraToken>
But if I add the chain.chainId option, it will complain.
~# ganache-cli --fork https://mainnet.infura.io/v3/<infuraToken> --chain.chainId 1
Is this expected behavior? I don't understand why the chainId difference will cause this inconsistency.
We'll add this to our backlog. Seems like next step here is for someone on the team to reproduce this issue locally. From there we'll have a better sense what is going wrong.
Thank you!
@baibinghere I just noticed that you are using ganache-cli which is a deprecated package. Try using ganache and using the latest version (7.4.4). I was able to successfully migrate a test project using a setup similar to yours. Let me know how it goes and I'll try and help get to the bottom of this!
Closing this for issue maintenance. @baibinghere If you're still experiencing this with the latest ganache feel free to open another issue! Thanks :)