About the contract size limit

When I tried to deploy the implementation with Openzeppelin-SDK and I failed to deploy.
I think it is problem about contract size as following article suggested.

Does one implementation size need to be lower than 24KB when it is deployed with Openzeppelin-SDK?
Thank you.

2 Likes

Hi @Shinsaku,

What was the error that you got?

When using openzeppelin create there is:

  • A transaction to deploy the logic (implementation) contract.
  • A transaction to deploy the ProxyAdmin contract.
  • A transaction to deploy the proxy contract.

Just like any contract deployment, the size for each contract (including the logic/implementation contract) needs to be lower than the size limit in EIP-170

You could always flatten your logic contract and try deploying using Remix.

Thank you for the response.
The error message said Contract deployment failed with error: Returned error: VM Exception while processing transaction: out of gas.

And I want to ask more.
You said when the create command is executed, the logic, ProxyAdmin and Proxy contract are deployed.
The two of three contracts (ProxyAdmin and Proxy) you mentioned are in here?
Thank you.

1 Like

Hi @Shinsaku,

Which network are you deploying to?
Can you share your network.js file (removing any sensitive information such as Infura Project ID).
Are you able to share your contract?


Regards your other question:

The ProxyAdmin and the AdminUpgradeabilityProxy (Proxy contract) are found in the OpenZeppelin SDK repository: https://github.com/OpenZeppelin/openzeppelin-sdk/tree/master/packages/lib/contracts/upgradeability

I deployed an upgradeable contract earlier today to Ropsten, and you can see the ProxyAdmin and Proxy contracts on Etherscan:

ProxyAdmin:
https://ropsten.etherscan.io/address/0x8c080f094f6dbd4f9622a6f7518878f9ab9e8462#code

AdminUpgradeabilityProxy (Proxy contract):
https://ropsten.etherscan.io/address/0xf0bcb16c9921ee92c382f0b68e51c6345e00c05b#code

1 Like

Hi @abcoathup,

Here is network.js.

module.exports = {
  networks: {
    development: {
      protocol: 'http',
      host: 'localhost',
      port: 8545,
      gas: 8000000,
      gasPrice: 5e9,
      networkId: '*',
    },
  },
};

The contract code is big about 5.7million gas.

1 Like

Hi @Shinsaku,

You could try running ganache-cli with the unlimited contract size option (see below) and then see what the actual deployed size is.

https://github.com/trufflesuite/ganache-cli
--allowUnlimitedContractSize : Allows unlimited contract sizes while debugging. By enabling this flag, the check within the EVM for contract size limit of 24KB (see EIP-170) is bypassed. Enabling this flag will cause ganache-cli to behave differently than production environments.

If your contract is over the 24KB limit then you will need to look at reducing the size.

Hi @Shinsaku,

I wanted to check in with you and see how you were getting on?

Hi @abcoathup
I am successful in deploying the contract with the option you mentioned.
Thank you!
It seemed that the problem about the contract size problem.
Thank you for telling me.

1 Like

Hi @Shinsaku,

Assuming that your contract is over the size limit, you will still need to reduce the size to be able to deploy to a public network.

Though at least you can deploy to ganache-cli --allowUnlimitedContractSize whilst you investigate.

1 Like

Hi @abcoathup
That is right.
I have to reduce the contract size somehow…
Thank you!

1 Like

You can use the Diamond Standard to get around the 24KB contract size limit: https://github.com/ethereum/EIPs/issues/2535

2 Likes