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

Error when using OpenZeppelin openzeppelin-foundry-upgrades in combination with MC #49

Open
naizo01 opened this issue Oct 5, 2024 · 1 comment
Labels
priority: medium Issues or pull requests with medium priority status: todo Issues that need to be addressed type: bug Issues or pull request related to bug reports or malfunctions

Comments

@naizo01
Copy link

naizo01 commented Oct 5, 2024

While trying to compile using the OpenZeppelin openzeppelin-foundry-upgrades plugin alongside MC, the following error is encountered:

[FAIL. Reason: setup failed: revert: Failed to run upgrade safety validation: /Users/user/.npm/_npx/fb3494f8bab08a4d/node_modules/@openzeppelin/upgrades-core/dist/validate/run.js:169
                throw new error_1.UpgradesError(`${decodeSrc(node)}: Namespace struct ${node.name} is defined outside of a contract`, () => `Structs with the @custom:storage-location annotation must be defined within a contract. Move the struct definition into a contract, or remove the annotation if the struct is not used for namespaced storage.`);
                      ^

UpgradesError: lib/mc/devkit/Flattened.sol:24695: Namespace struct ConfigState is defined outside of a contract

Structs with the @custom:storage-location annotation must be defined within a contract. Move the struct definition into a contract, or remove the annotation if the struct is not used for namespaced storage.
    at checkNamespacesOutsideContract (/Users/user/.npm/_npx/fb3494f8bab08a4d/node_modules/@openzeppelin/upgrades-core/dist/validate/run.js:169:23)
    at validate (/Users/user/.npm/_npx/fb3494f8bab08a4d/node_modules/@openzeppelin/upgrades-core/dist/validate/run.js:90:9)
    at runValidations (/Users/user/.npm/_npx/fb3494f8bab08a4d/node_modules/@openzeppelin/upgrades-core/dist/cli/validate/validations.js:23:41)
    at validateBuildInfoContracts (/Users/user/.npm/_npx/fb3494f8bab08a4d/node_modules/@openzeppelin/upgrades-core/dist/cli/validate/validations.js:14:29)
    at validateUpgradeSafety (/Users/user/.npm/_npx/fb3494f8bab08a4d/node_modules/@openzeppelin/upgrades-core/dist/cli/validate/validate-upgrade-safety.js:23:74)
    at async main (/Users/user/.npm/_npx/fb3494f8bab08a4d/node_modules/@openzeppelin/upgrades-core/dist/cli/validate.js:30:24)
    at async run (/Users/user/.npm/_npx/fb3494f8bab08a4d/node_modules/@openzeppelin/upgrades-core/dist/cli/cli.js:6:5)
@naizo01 naizo01 added priority: medium Issues or pull requests with medium priority status: todo Issues that need to be addressed labels Oct 5, 2024
@kaihiroi
Copy link
Contributor

Thank you for the report.

The error seems to be related to validation within the openzeppelin-upgrades library. https://github.com/OpenZeppelin/openzeppelin-upgrades/blob/08c6cd4f789338617c19e8165b73c7084b11b45c/packages/core/src/validate/run.ts#L287

Since using namespaces within the devkit is unlikely to cause storage conflicts, temporarily disabling the strict validation (by setting the "strict" boolean variable to false or excluding devkit from the check) might resolve the issue.

I'll add a backlog item to remove unnecessary annotations from devkit.

@kaihiroi kaihiroi mentioned this issue Oct 15, 2024
8 tasks
@kaihiroi kaihiroi added this to the Version 0.2.0 Release milestone Oct 15, 2024
@kaihiroi kaihiroi removed this from the Version 0.2.0 Release milestone Oct 15, 2024
@kaihiroi kaihiroi added the type: bug Issues or pull request related to bug reports or malfunctions label Oct 31, 2024
@kaihiroi kaihiroi added this to the Version 0.2.0 Release milestone Oct 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: medium Issues or pull requests with medium priority status: todo Issues that need to be addressed type: bug Issues or pull request related to bug reports or malfunctions
Projects
None yet
Development

No branches or pull requests

2 participants