0

I'm trying to deploy the 'solo' (https://github.com/dydxprotocol/solo) After cloning [email protected]:dydxprotocol/solo.git and resolving all dependencies

Contracts compilation is successful, however when deploying I get:

npm run deploy_test

"OperationImpl" ran out of gas (using a value you set in your network config or deployment parameters.)
* Block limit:  4294967295 (0xffffffff)
* Gas sent:     6721975 (0x6691b7)

This is what the ganace-cli shows:

Transaction: 0x6883c81917b755b236af91f2167713a6f5d9d6a3cd0db0a9b62a728046193e94
Contract created: 0xe8dedc22f660cc6c5de0873bd92b075962cc4723
Gas usage: 6721975
Block Number: 18
Block Time: Mon Sep 27 2021 22:45:13 GMT+0000 (Coordinated Universal Time)
Runtime Error: out of gas

I've seen some similar posts and they suggest to change the account gas value, but that didn't help:

ganache-cli -h 0.0.0.0 -p8445 -l 4294967295 -e 100 -g 1 -i 1313 -a 2

Tool Versions:

  • Truffle v5.4.11 (core: 5.4.11)
  • Node v16.9.1
  • Ganache CLI v6.12.2 (ganache-core: 2.13.2)

1 Answer 1

1

This turned out to be related to bytecode rather than the gas limit

Found this: Ganache: out-of-gas during deployment

Saying:

The real reason (see the answer) is: apparently, there is a 24kB size restriction on the deployed bytecode (besides the gas limits).

So I read https://blog.polymath.network/solidity-tips-and-tricks-to-save-gas-and-reduce-bytecode-size-c44580b218e6 which sais that the number of 'runs' controls the trade-off between the deployment cost and the call cost a smaller amount of runs means a smaller bytecode

runs is not how many times the optimizer will run but how many times you expect to call functions in that smart contract. If the smart contract is only of one-time use as a smart contract for vesting or locking of tokens, you can set the runs value to 1 so that the compiler will produce the smallest possible bytecode but it may cost slightly more gas to call the function(s). If you are deploying a contract that will be used a lot (like an ERC20 token), you should set the runs to a high number like 1337 so that initial bytecode will be slightly larger but calls made to that contract will be cheaper.

Unfortunately, the OperationImpl library holds the basic operations of the dydx exchange, including the 'transfer' and 'sell' commands, but that seems to be good enough for testing.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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