Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allowUnlimitedContractSize flag not working #3208

Closed
Benen66 opened this issue Sep 22, 2022 · 5 comments
Closed

allowUnlimitedContractSize flag not working #3208

Benen66 opened this issue Sep 22, 2022 · 5 comments
Assignees

Comments

@Benen66
Copy link

Benen66 commented Sep 22, 2022

I've been trying to run a fork of Set Protocol on localhost using hardhat and I'm getting a ProviderError: Error: Transaction reverted: trying to deploy a contract whose code is too large even when the file in question (SetTokenCreator.sol) is only a 100 lines long and I've enabled allowUnlimitedContractSize: true.

My hardhat.config looks like this:

solidity: "0.8.11",
  defaultNetwork: "hardhat",
  hardhat: {
    allowUnlimitedContractSize: true,
    gas: 12000000,
    blockGasLimit: 0x1fffffffffffff,
    ignoreUnknownTxType: true,
  },
  localhost: {
    allowUnlimitedContractSize: true,
    timeout: 200000,
    gas: 12000000,
    blockGasLimit: 0x1fffffffffffff,
    ignoreUnknownTxType: true,
  },

the ignoreUnknownTxType is because I'm attempting to fork Arbitrum using the patch in #2995. The patch is working correctly and the unknown transactions are indeed being ignored correctly. My hardhat reset in the test file looks like this:

await hre.network.provider.request({
      method: 'hardhat_reset',
      params: [
          {
            allowUnlimitedContractSize: true,
              forking: {
                  jsonRpcUrl: 'https://rinkeby.arbitrum.io/rpc',
                  // enabled: true,
                  // blockNumber: 15216420,
                  ignoreUnknownTxType: true,
                  allowUnlimitedContractSize: true,
              },
          },
      ],
  })
const setTokenCreator = await hre.ethers.getContractFactory("SetTokenCreator");
 const setTokenCreatorInterface = await setTokenCreator.deploy(controllerInterface.address, {gasLimit: BigNumber.from("655592")});
 await setTokenCreatorInterface.deployed();

The full error message is

Error: Transaction reverted: trying to deploy a contract whose code is too large
      at SetTokenCreator.constructor (contracts/protocol/SetTokenCreator.sol:50)

why is allowUnlimitedContractSize not kicking in? I'm confused because in a couple of old projects I didn't have this problem. And a couple of bigger contracts in terms of code length are deploying correctly in this same file

@github-actions
Copy link
Contributor

This issue is also being tracked on Linear.

We use Linear to manage our development process, but we keep the conversations on Github.

LINEAR-ID: c2f0f356-c097-4552-b8ab-3be67859e3b7

@fvictorio
Copy link
Member

This might be a wrong diagnostic, telling you that the problem is a "contract too large" when it's actually running out of gas. Can you try increasing the gas limit of the transaction?

@fvictorio
Copy link
Member

I'm pretty sure this is caused by #3420, so I'm going to close this one.

@fvictorio fvictorio closed this as not planned Won't fix, can't repro, duplicate, stale Dec 24, 2022
@JustCallMeDavid
Copy link

JustCallMeDavid commented Dec 24, 2022

Ciao @fvictorio, I just had the same issue and indeed increasing the gas limit of the transaction when deploying it seems to have fixed it. Adding allowUnlimitedContractSize: true to the hardhat.config.js file did not make a difference.

Maybe also worth methioning: I checked the size of my contract's bytecode and it should be ~16kb, well under the 24kb limit of EIP170.

@fvictorio
Copy link
Member

Maybe also worth methioning: I checked the size of my contract's bytecode and it should be ~16kb, well under the 24kb limit of EIP170.

This is a bit confusing. The EIP170 limit is about the size of the resulting bytecode. But if the deployment code spends a lot of gas (say, there's a loop in the constructor or whatever) then you might hit #3420. This is, of course, a bug in Hardhat.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 25, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
Archived in project
Development

No branches or pull requests

4 participants