I have a smart contract that has a fair number of functions, but a large number of require() statements because I carefully check every incoming parameter and some intermediate calculation results too. I've been fighting an out-of-gas error during my Truffle 5.0 beta migrations for a long time now with this contract.
On a hunch, I did a search-and-replace throughout the contract that commented out every require() statement. The out-of-gas error went away and I could deploy successfully.
If I use the solc optimizer I can deploy successfully with the require() statements intact. But then I can't use the Truffle debugger since currently it can't coexist with optimized code, and I really need the debugger.
I thought it might be due to the long strings I was using as my "revert messages" for the require() statements, so I radically cut down their size, but the error still occurred. Then I tried changing them all to empty strings but still got the error. It really appears to be the sheer number of require() statements that is causing the out-of-gas error but only when I don't use the optimizer.
Has anyone experience this and can suggest a technique to get the gas low enough that I can deploy. Note I am sending an extremly high amount of gas with my migration, just below the Block Limit for the Ganache client.
2_deploy_ebb.js
===============
Replacing 'EtherBandBattlesManager'
-----------------------------------
Error: *** Deployment Failed ***
"EtherBandBattlesManager" ran out of gas (using a value you set in your network config or deployment parameters.)
* Block limit: 100000000
* Gas sent: 99999999
at ./.nvm/versions/node/v8.11.1/lib/node_modules/truffle/build/webpack:/packages/truffle-deployer/src/deployment.js:364:1
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
Truffle v5.0.0-beta.2 (core: 5.0.0-beta.2)
Solidity v0.5.0 (solc-js)
Node v8.11.1