0

I have a fairly large contract that I must create on Kovan network for testing. There is fairly weird behavior occurring when I am trying to create the said contract.

Behavior being: whenever transaction consumed limit goes over 6`000`000 gas the transaction fails with out of gas error (in spite of 10`000`000 gas limit specified (which was the block gas limit).

Now my contact theoretical size is around 6.8-7 million limit when created.

Here is some sample transactions: This one succeeded when I stripped away some functions from the code (unrelated to initialization): https://kovan.etherscan.io/tx/0x0d903408120c352876879d833ecfec01f7f4b8b3a17967b6f4920b4d30c9253b

This one fails (raw transaction size 58`236/2 bytes), meaning around 5.8236 million limit + some EVM specified gas costs (contract creation etc.) Which in result goes over 6 millions: https://kovan.etherscan.io/tx/0xc8a1a2d4c3c010801cd769b0325c4bf1c8dcb2bc47f76505f91dface7cb62050

Questions:

  • As you can see in both cases here where plenty of room left in the block for new transaction, is there some sort of limit that I am not aware of?
  • Any tips on how to solve this issue?
  • Is this behavior chain/node specific?

Haven't actually tested this on any other chains.

I know that this is a large contract by all standards, but splitting it into more subcontracts would increase the operational cost for each transaction + increase logical complexity (ensuring only allowed actors are accessing specific public methods). On top of that it already is one part of a series of interconnected contracts.

1 Answer 1

1

Ethereum has hard coded limit of 24 Kbytes for the smart contract runtime since https://eips.ethereum.org/EIPS/eip-170.

This limit is different from the block gas limit.

Note: compilation returns a bytecode which is composed of the constructor and the runtime, only the last part has to be within the 24 Kbytes limit.

2
  • Thanks for the answer! This means that when creating transaction data contract byte code + constructor must be less than 24Kbytes or just the contract byte code? In any event it looks like I am just a bit over this limit... Well back to the drawing board...
    – Kristaps
    Commented Oct 18, 2019 at 6:31
  • 1
    The 24 Kbytes limit is for the smart contract's runtime, the bytecode minus the constructor.
    – Ismael
    Commented Oct 18, 2019 at 12:23

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.