I asked about this on gitter:
i am trying to create a contract from other contract on gnache-cli using remix web3 provider but getting following error VM Exception while processing transaction: revert. Issue is that when i try it on JavaScript VM (on remix) i am not getting any error. Kindly note that i am running ganache cli with following parameters: ganache-cli -h 0.0.0.0 -p 8545 -l 3000000000 As a sidenote, i am able to deploy the contract... issue is while deploying from another contract only. On ganache-cli console, i am getting error: Transaction: 0x1f77d94278c27412affe6be5f7bd50d6f95d47503fa6c302553e1a94cfb7111c
Gas usage: 2250998
Block Number: 3
Block Time: Fri Sep 28 2018 13:33:14 GMT+0400 (+04)
Runtime Error: revert. Version i am running on are: Ganache CLI v6.1.8 (ganache-core: 2.2.1)
solc, the solidity compiler commandline interface Version: 0.4.24+commit.e67f0147.Linux.g++ and npm: 6.4.1
Receiving Error:
Transaction: 0x1f77d94278c27412affe6be5f7bd50d6f95d47503fa6c302553e1a94cfb7111c
Gas usage: 2250998
Block Number: 3
Block Time: Fri Sep 28 2018 13:33:14 GMT+0400 (+04)
Runtime Error: revert
ganache-cli -h 0.0.0.0 -p 8545 -l 3000000000contract Test2{
constructor() {
}
}
contract Test{
function createInstance() public{
address test2 = new Test2();
}
}
```
I am trying to run a contract for testing purpose.
Ganache CLI v6.1.8 (ganache-core: 2.2.1)Truffle v4.1.13 (core: 4.1.13)Solidity v0.4.24 (solc-js)v8.11.3)Ubuntu 16.04I ran ganache-cli in verbose mode and got following dump:
eth_sendTransaction
> {
> "jsonrpc": "2.0",
> "id": 114,
> "method": "eth_sendTransaction",
> "params": [
> {
> "from": "0xfae46f35deebe8c2a37738c6f03195f74e3f185c",
> "to": "0x2e7f2fa79508bfb1b00118ef4f0137eb90f01117",
> "data": "0xad501467",
> "value": "0x0",
> "gas": "0xfaca"
> }
> ]
> }
< {
< "id": 114,
< "jsonrpc": "2.0",
< "result": "0xa19622639b6d72157109f2b6ab31187e99c95ec9af3365d78a4ab4000a8b9202",
< "error": {
< "message": "VM Exception while processing transaction: revert",
< "code": -32000,
< "data": {
< "0xa19622639b6d72157109f2b6ab31187e99c95ec9af3365d78a4ab4000a8b9202": {
< "error": "revert",
< "program_counter": 131,
< "return": "0x0"
< },
< "stack": "i: VM Exception while processing transaction: revert\n at Function.i.fromResults (/usr/lib/node_modules/ganache-cli/build/cli.node.js:10:163747)\n at /usr/lib/node_modules/ganache-cli/build/cli.node.js:30:121483\n at /usr/lib/node_modules/ganache-cli/build/cli.node.js:37:15061\n at p (/usr/lib/node_modules/ganache-cli/build/cli.node.js:37:15496)\n at /usr/lib/node_modules/ganache-cli/build/cli.node.js:37:15549\n at a.default (/usr/lib/node_modules/ganache-cli/build/cli.node.js:149:104558)\n at /usr/lib/node_modules/ganache-cli/build/cli.node.js:37:14433\n at v.r.emit (/usr/lib/node_modules/ganache-cli/build/cli.node.js:134:1257132)\n at /usr/lib/node_modules/ganache-cli/build/cli.node.js:134:472444\n at /usr/lib/node_modules/ganache-cli/build/cli.node.js:134:472467\n at /usr/lib/node_modules/ganache-cli/build/cli.node.js:134:1259919\n at /usr/lib/node_modules/ganache-cli/build/cli.node.js:2:67763\n at d (/usr/lib/node_modules/ganache-cli/build/cli.node.js:2:70993)\n at /usr/lib/node_modules/ganache-cli/build/cli.node.js:2:71035\n at Da (/usr/lib/node_modules/ganache-cli/build/cli.node.js:2:80468)\n at Object.<anonymous> (/usr/lib/node_modules/ganache-cli/build/cli.node.js:2:71124)\n at /usr/lib/node_modules/ganache-cli/build/cli.node.js:134:1259840\n at /usr/lib/node_modules/ganache-cli/build/cli.node.js:2:70705\n at n (/usr/lib/node_modules/ganache-cli/build/cli.node.js:2:85832)\n at /usr/lib/node_modules/ganache-cli/build/cli.node.js:134:1259821\n at n (/usr/lib/node_modules/ganache-cli/build/cli.node.js:2:85804)\n at /usr/lib/node_modules/ganache-cli/build/cli.node.js:134:1259821",
< "name": "i"
< }
< }
< }
Transaction: 0xa19622639b6d72157109f2b6ab31187e99c95ec9af3365d78a4ab4000a8b9202
Gas usage: 64076
Block Number: 2
Block Time: Fri Sep 28 2018 18:44:33 GMT+0400 (+04)
Runtime Error: revert
Thanks @furqanbaqai for reporting this. I was able to reproduce the issue and have now added it to our issue backlog to be worked on in the future.
@furqanbaqai I think it's likely that remix is using eth_estimateGas and expecting it to give a tight bound on the amount of gas to be consumed. Solidity injects gas checks before doing expensive operations which will result in a gas price that can be calculated at compile time. If it detects that carrying out the expensive operation (in this case, a contract creation) will not succeed due to not having enough gas it will REVERT rather than attempting the operation and burning up all your gas.
The bug here is almost certainly that eth_estimateGas is coming back with too low of a number. If you can set the gas limit for the transaction in remix manually, do that as a work around. Otherwise the next release of ganache will have much improved gas estimates.
Sounds like I was wrong to close this. @davidmurdoch tells me this is still an issue on current develop branch. 馃槵
@furqanbaqai Thanks for reporting this issue. I was able to confirm this error when using Remix and Ganache. Also was able to confirm this is not an issue with a local unit test. We are still working to confirm the root cause.
@ccowell any updates at this? This issue is currently a blocker for our development
Hi @S3bb1,
After further investigation, it appears that our gas estimates are slightly low in certain cases. We are looking into a better implementation.
This should now be fixed in the latest beta tagged releases of ganache-cli and ganache-core.
This fix involved pretty significant code changes; check out the release notes for details.
We'd love it if you'd test this beta out to make sure things are good to go before we release to stable.
If you using ganache-cli, run:
npm install -g ganache-cli@beta
If you are using ganache-core, run:
npm install ganache-core@beta
Let us know if you discover any bugs with this new beta release! Thanks!
Most helpful comment
Hi @S3bb1,
After further investigation, it appears that our gas estimates are slightly low in certain cases. We are looking into a better implementation.