0

are there some testRPC limitations? I'm frequently experiencing "out of gas" exceptions for contracts with moderate amount of methods. For example, let's have contract:

contract TestSize{
    event Test1(uint param1, string param2); function test1(uint param1, string param2){ Test1(param1, param2);}
    event Test2(uint param1, string param2); function test2(uint param1, string param2){ Test2(param1, param2);}
    event Test3(uint param1, string param2); function test3(uint param1, string param2){ Test3(param1, param2);}
    ...
    event Test87(uint param1, string param2); function test87(uint param1, string param2){ Test87(param1, param2);}
}

This contract deploys on testRPC with truffle without problems, gas used is 6614230.

However, when I add one additional line with test88/Test88:

contract TestSize{
    event Test1(uint param1, string param2); function test1(uint param1, string param2){ Test1(param1, param2);}
    event Test2(uint param1, string param2); function test2(uint param1, string param2){ Test2(param1, param2);}
    event Test3(uint param1, string param2); function test3(uint param1, string param2){ Test3(param1, param2);}
    ...
    event Test87(uint param1, string param2); function test87(uint param1, string param2){ Test87(param1, param2);}
    event Test88(uint param1, string param2); function test88(uint param1, string param2){ Test88(param1, param2);}
}

the deployment ends with out of gas exception, basically consuming whatever amount of gas I give it:

eth_sendTransaction

  Transaction: 0x5b838c29352638fc360302f9b15920359feb4d107837684e2ff2a4637e2c2c89
  Contract created: 0x7703276d61ff3a1e081d1ed1d3bbf1738cb0d554
  Gas usage: 9000000000
  Block Number: 24
  Block Time: Thu Jan 25 2018 19:12:53 GMT+0100 (CET)
  Runtime Error: out of gas

Any ideas? It seriously limits development of even a bit larger contracts.

1

Ganache-cli (previously called testrpc) allows to set an arbitrary large amount of gas with the -l parameter.

For example to set the gas limit to 100M you can use

ganache-cli -l 100000000

You can check the readme page on their github repo for more options https://github.com/trufflesuite/ganache-cli.

| improve this answer | |
  • Naturally I increased the number, as you can see - the gas sent with the contract creation Tx AND consumed was 9 billion - what is a ridiculous number. Something very odd inside testrpc. – ejossev Jan 27 '18 at 15:05
  • It is likely you are reaching an internal limit and it causes the deployment to fail and it charges with all the remaining gas. – Ismael Jan 27 '18 at 15:49
  • That is what I wanna to figure out :) – ejossev Jan 28 '18 at 16:39
0

I recently went down the same trail you've described. Right down to "N copies of the same trivial function, foo_NNNN()". My conclusion is that the issue is bytecode size, and it appears that perhaps the culprit is EIP170, which limits bytecode size to 24k bytes.

Others have suggested factoring code out into libraries, and that helps, I guess. This is a fundamental and unavoidable limitation on the complexity of code in Ethereum, and I don't know how to work around it. Because sometimes you have a body of code that's so complex, finding a place to cut in two only increases its size (b/c too many calls across the cutting-plane).

Sorry I don't have anything to suggest, but I'm in the same spot, is why.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.