-
Notifications
You must be signed in to change notification settings - Fork 270
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
Detect issues in parent initializer calls #1095
base: master
Are you sure you want to change the base?
Conversation
packages/core/src/validate/run.ts
Outdated
(fnDef.modifiers.some(modifier => | ||
['initializer', 'reinitializer', 'onlyInitializing'].includes(modifier.modifierName.name), | ||
) || | ||
['initialize', 'initializer', 'reinitialize', 'reinitializer'].includes(fnDef.name)) && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For another PR, I think it may be useful if we annotate initializers with @custom:initializer
or similar.
The idea is that there are contracts with initializers that don't follow the initialize
or initializer
convention in its name.
A concrete example is any of the Signers we created for ERC4337 accounts:
abstract contract SignerRSA is AbstractSigner {
error SignerRSAUninitializedSigner(bytes e, bytes n);
bytes private _e;
bytes private _n;
/// @custom:initializer true
function _initializeSigner(bytes memory e, bytes memory n) internal {
if (_e.length != 0 || _n.length != 0) revert SignerRSAUninitializedSigner(e, n);
_e = e;
_n = n;
}
...
}
Added recursive checks in the initializer function, to detect cases where its called functions (e.g. helper functions or parent initializer calls) may have duplicate calls or incorrect order of calls to parent initializers. |
Ready for re-re-review! @Amxx @ernestognw |
Reports if a contract is non-abstract and any of the following are true:
Note that reinitializers will be ignored for these validations.
Future improvements:
Fixes #160