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

getting Call the parent initializers in your initializer function error in the assertUpgradeSafe method when a fragment other then initialize is used when deploying a proxy #1124

Closed
viraj124 opened this issue Feb 11, 2025 · 7 comments

Comments

@viraj124
Copy link

Hi,

I have been getting this issue when deploying a proxy contract in my docker env, here is my deploy script.

The issue is in my contract which has been deployed on mainnet and testnet, I have the following logic

    function initialize(FuelChainState) public virtual override {
        revert NotSupported();
    }

    function initializerV3(FuelChainState fuelChainState, uint256 _limitAmount) public reinitializer(3) {
        initializerV1(fuelChainState);
        _setInitParams(_limitAmount);
    }

now the issue is when I deploy my contracts on a local hardhat node it works fine, but in my docker env I get the error I mentioned in this issue, if I remove the initialize method in my contract then it works fine, but otherwise it doesn't, I also checked this after making the @openzeppelin/hardhat-upgrades version same in both local and docker env, but got the same issue

in docker env
node version : 20.x.x
@openzeppelin/hardhat-upgrades: 3.9.0

I started getting this issue around last week, before it was working fine

what can be the issue here ? would be great if it can be looked at on priority if at all possible

@viraj124 viraj124 changed the title getting Call the parent initializers in your initializer function error in the assertUpgradeSafe method when a fragment other then initialize is used getting Call the parent initializers in your initializer function error in the assertUpgradeSafe method when a fragment other then initialize is used when deploying a proxy Feb 11, 2025
@viraj124
Copy link
Author

hey @ericglau can you look at this

@ericglau
Copy link
Member

In recent versions of the plugin, we added checks for issues with parent initializer calls.

The plugin looks for initializer functions in your contract, but does not check reinitializers (since reinitializers do not necessarily need to initialize the entire state).

Since your contract has an initialize override function, which does not call parent initializers (although this is intended from your design), an error is reported. Additionally, the initializerV3 function is not considered in the checks since it is a reinitializer.

(Side note: when you removed the initialize function, the reason it did not trigger the error should be because the parent contract FuelMessagePortal still has an initializer which could be called and was not overridden, so that was considered valid.)

For now, you can bypass this error by adding the unsafeAllow: ['missing-initializer-call'] option in your script, for example:

const contract = await deployProxy(
    new FuelMessagePortal(deployer),
    [fuelChainState, RATE_LIMIT_AMOUNT.toString()],
    {
      initializer: 'initializerV3',
      constructorArgs: [MaxUint256, RATE_LIMIT_DURATION],
      unsafeAllow: ['missing-initializer-call'],
    }
  );

I expect the proper fix for this in the plugin should be to support a way for you to specify the function that you want to validate as the initializer.

@viraj124
Copy link
Author

thanks, gonna do this, wanted to mention that I got this error even with older versions of the plug-inside the docker env, but locally with those versions didn’t face it, is that sort of expected due to the reasons you mentioned ?

@ericglau
Copy link
Member

The Hardhat plugin @openzeppelin/hardhat-upgrades uses semantic versioning to support newer versions of @openzeppelin/upgrades-core. The initializer validations are in @openzeppelin/[email protected], so it is possible that older versions of the Hardhat plugin can use the latest dependencies.

@viraj124
Copy link
Author

viraj124 commented Feb 11, 2025

I see and the versioning for the upgrade-core package can’t be overridden by us explicitly when using the hardhat-upgrades package ?

@ericglau
Copy link
Member

You could try specifying a specific version of @openzeppelin/upgrades-core in your package.json or by having a specific version in your lockfile.

@viraj124
Copy link
Author

this worked @ericglau thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants