metacontract / mc

A flexible and upgradeable smart contract framework optimized for AI integration and DevOps efficiency, enabling streamlined development and testing.
MIT License
43 stars 5 forks source link

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

Open naizo01 opened 3 weeks ago

naizo01 commented 3 weeks ago

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)
kaihiroi commented 1 week ago

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.