6

I have two contracts A and B, both deploy and work correctly in ganache (they both use less than 6M gas). Now I want to create a third contract C that inherit both A and B.

contract C is A, B {
}

This contract C fails to deploy with out of gas exception. But gas should not be an issue because ganache is configured with a block gas limit of 4 billion.

After trial and error commenting out my code, I found it fails with a public function in contract B. After reordering functions I found it doesn't matter which function in particular, it will fail if there are more than N public functions in contract B.

Update: Trying the deploy the same contracts in a geth private testnet causes the error "oversized data". So I think is not the number of public functions but the resulting contract is too big.

Ismael
  • 30,570
  • 21
  • 53
  • 96

1 Answers1

6

There is exactly one place in geth code where "oversized data" is thrown. It's in func (pool *TxPool) validateTx(tx *types.Transaction, local bool) error.

Heuristic limit, reject transactions over 32KB to prevent DOS attacks

Moreover, there is also a limit for bytecode size of a smart contract. It's 24576 bytes (see protocol_params.go).

maxCodeSize can be set in genesis.json. 32KB for TX size limit is a hard-coded constant in the code.

ivicaa
  • 7,519
  • 1
  • 20
  • 50