Detect issues in parent initializer calls#1095
Merged
ericglau merged 55 commits intoOpenZeppelin:masterfrom Jan 23, 2025
Merged
Detect issues in parent initializer calls#1095ericglau merged 55 commits intoOpenZeppelin:masterfrom
ericglau merged 55 commits intoOpenZeppelin:masterfrom
Conversation
Amxx
reviewed
Dec 17, 2024
Amxx
reviewed
Dec 17, 2024
ernestognw
reviewed
Dec 18, 2024
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)) && |
Member
There was a problem hiding this comment.
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;
}
...
}
ernestognw
approved these changes
Dec 18, 2024
Member
Author
|
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. |
ernestognw
approved these changes
Jan 23, 2025
This was referenced Feb 10, 2025
This was referenced May 7, 2025
This was referenced May 20, 2025
Merged
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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