-
Notifications
You must be signed in to change notification settings - Fork 813
Ganache fails to deploy contract with >29kb binary #674
Comments
@XertroV This could be because ganache-cli implements EIP-170 which was included in the Byzantium fork and limits contract sizes. @seesemichaelj (one of the ganache engineers) has been working to make that optional although AFAIK those vm changes haven't made it into a build here yet. If you need a short term workaround - ethereumjs-testrpc-sc is a coverage enabled ganache fork used by solidity-coverage which has EIP-170 turned off. (It's basically ganache-cli 6.1.0.)
|
Thanks @cgewecke! It is correct that the ignore EIP 170 PR (trufflesuite/ganache#79) hasn't been merged yet due to me not completing the tests. I'll follow up on this issue when it is merged and scheduled for release |
Ahh cool. Thanks for the info. No need for a workaround on my end.
As a suggestion though, maybe @seesemichaelj could add a specific error
message as part of his PR?
|
That's a great suggestion @XertroV! I'll look into it I'll keep this issue open until it's addressed in |
Also waiting for this fix, as we have contracts over 6.7 m of Gas. |
Hey everyone! I just wanted to clear things up by explaining what's causing this issue. This is not a problem of gas (despite the error is "out of gas"). EIP-170 states:
This means that the binary code that is being uploaded must be less than or equal to The feature that I am introducing in trufflesuite/ganache#79 is supposed to be used for debugging purposes only! We strongly encourage you to determine what is causing your contract bytecode to be too big as it will not deploy to any Ethereum chain based off Spurious Dragon. Note: It is likely that you are not optimizing your compilation. See https://solidity.readthedocs.io/en/develop/using-the-compiler.html?highlight=optimize for details. The only reason that you should use the flag to allow larger contracts is if you're using a debugger which requires you to not optimize the compilation. |
The code that supports the This is only for debug purposes!As previously mentioned, this issue should be addressed by optimizing the compilation of your contracts so they fit within the |
Is there a plan to add a setting to support fo "EIP-170" in "Gananche"? |
@w5pand #1020 is an open issue awaiting triage, but likely won't be implemented soon. There is an advanced-user, non-supported method for enabling this for the GUI. You can read the comments here: trufflesuite/ganache#1019 (comment) |
Have added as much detail (+example you can clone) as I could in reasonable time, LKM if you need more deets.
Expected Behavior
Current Behavior
With one of my contracts (links below) I cannot deploy the contract when it is above 29kb. Note: there might be other things going on but based on commenting out code (which is used it multiple places and not used in deployment) the deploy can succeed where otherwise it'd fail. Also, compiling is fine, and it's always the deployment step that fails.
I've confirmed that this is not a real out of gas error by setting the gas limits much higher than needed (20m).
Possible Solution
Not sure exactly what to do about it, but the problem exists in both
EthereumJS TestRPC v6.0.3 (ganache-core: 2.0.2)
andGanache CLI v6.1.0 (ganache-core: 2.1.0)
Steps to Reproduce (for bugs)
ganache-cli -l 20000000
(20m gas limit per block)git clone https://github.com/secure-vote/sv-light-smart-contracts
cd sv-light-smart-contracts
git checkout test/ganache-size-working
yarn test test/svLightIndex.js
-- this should "work" in that some test fail but contracts deploygit checkout test/ganache-size-broken
yarn test test/svLightIndex.js
-- this fails - all test fail on out of gasContext
Limits the size of contracts we can develop (note: although there might be some bad reasoning around mainnet (e.g. mainnet gas limit is X so what's the point supporting above X)) these conditions don't hold true for private networks.
Also it's often nice to be able to develop and then break up, as opposed to trying to break up just because ganache-cli doesn't work.
The error occurs in the tests (when broken) here: https://github.com/secure-vote/sv-light-smart-contracts/blob/cffb4ce137f1b299b68570ec11481f63547f00c4/test/svLightIndex.js#L77
I have set the default gas to use in truffle as 19m (see truffle.js) and I run ganache with a limit of 20m. Usually the gas to deploy is like 6.5m when everything is working, so this is not a real out of gas error.
This is the function where I'm commenting out the body:
working: https://github.com/secure-vote/sv-light-smart-contracts/blob/e1c095ab29f865dcc53ff6ccee609d934d885888/contracts/SVLightIndex.sol#L577
failing: https://github.com/secure-vote/sv-light-smart-contracts/blob/cffb4ce137f1b299b68570ec11481f63547f00c4/contracts/SVLightIndex.sol#L577
You can see the commit history in the branch
f/brokenTestRPC
Your Environment
ganache-cli 6.1.0
andtestrpc 6.0.3.
note: I still use testrpc because I can't get ganache to work as in https://github.com/secure-vote/sv-light-smart-contracts/blob/cffb4ce137f1b299b68570ec11481f63547f00c4/truffle.js#L7Truffle v4.1.11 (core: 4.1.11)
0.4.24 (solc-js)
macos 10.13.4
The text was updated successfully, but these errors were encountered: