I have a bunch of contracts which deploy just fine.
Deployment of one of the contracts, XBRNetwork takes exactly 5418911 gas - no problems with that.
However, once I add another trivial (public) function to the contract, deployment during CI run for the PR fails:
Replacing 'XBRNetwork' ---------------------- Error: *** Deployment Failed *** "XBRNetwork" ran out of gas (using a value you set in your network config or deployment parameters.) * Block limit: 0x989680 * Gas sent: 10000000 at /home/oberstet/scm/crossbario/xbr-protocol/node_modules/truffle/build/webpack:/packages/deployer/src/deployment.js:364:1 at process._tickCallback (internal/process/next_tick.js:68:7) Truffle v5.1.11 (core: 5.1.11) Node v10.16.0 Makefile:110: recipe for target 'deploy' failed make: *** [deploy] Error 1 I have set:
--gasLimit=10000000in ganache command optionsgas=10000000in migrations
What other option do I need? How would I change the PR to get rid of the "out of gas" issue?
Do test, start ganache:
docker-compose up --force-recreate ganache and deploy
truffle migrate --reset --network ganache UPDATE (solution)
The real reason (see the answer) is: apparently, there is a 24kB size restriction on the deployed bytecode (besides the gas limits).
I have added this helper to our CI:
Result:
WORKS: (cpy381_3) oberstet@intel-nuci7:~/scm/crossbario/xbr-protocol$ python check-abi-files.py .. ABI file "abi/XBRNetwork.json " bytecode= 25547 bytes, deployedBytecode= 23998 bytes .. FAILS: (cpy381_3) oberstet@intel-nuci7:~/scm/crossbario/xbr-protocol$ python check-abi-files.py .. ABI file "abi/XBRNetwork.json " bytecode= 26344 bytes, deployedBytecode= 24795 bytes WARNING - maximum deployed contract size of 24kB exceeded .. And the actual solution consequently: refactoring the contract code into a library. Can be done .. np .. now that I know this hidden limit;)