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

Add _initializableStorageSlot #5337

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

ernestognw
Copy link
Member

@ernestognw ernestognw commented Dec 3, 2024

Fixes #4782

Adding _initializableStorageSlot seems like a good abstraction for developers who want to override the initializable storage slot. This makes sense in the context of Account Abstraction since some wallets might reuse the slot. For these case it may be better that each implementation has its own customized slot.

PR Checklist

  • Tests
  • Documentation
  • Changeset entry (run npx changeset add)

Copy link

changeset-bot bot commented Dec 3, 2024

🦋 Changeset detected

Latest commit: ce4ce8f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
openzeppelin-solidity Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@ernestognw ernestognw requested a review from a team December 3, 2024 23:25
contracts/proxy/utils/Initializable.sol Outdated Show resolved Hide resolved
.changeset/fast-coats-try.md Outdated Show resolved Hide resolved
@ernestognw
Copy link
Member Author

Alternatively, we can make _getInitializableStorage internal. Thoughts?

@Amxx Amxx added this to the 5.3 milestone Dec 4, 2024
Copy link
Collaborator

@Amxx Amxx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm concerned by line 63

     * when using with upgradeable contracts.
     *
     * @custom:storage-location erc7201:openzeppelin.storage.Initializable // <<== HERE !
     */
    struct InitializableStorage {

This comment will be wrong if the value is overriden. How will the plugin handle that ?

@Amxx
Copy link
Collaborator

Amxx commented Dec 11, 2024

function _getInitializableStorage() internal virtual pure returns (InitializableStorage storage $) {

Would be a smaller change, that we could easily generalize to all the upgradeable contracts. The downside is that overriding it would likely require the user writting assembly.

@arr00
Copy link
Contributor

arr00 commented Dec 13, 2024

function _getInitializableStorage() internal virtual pure returns (InitializableStorage storage $) {

Would be a smaller change, that we could easily generalize to all the upgradeable contracts. The downside is that overriding it would likely require the user writting assembly.

I imagine that most teams requiring this functionality won't have an issue writing minimal yul. Don't think it's worth the extra function call just to bypass that.

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

Successfully merging this pull request may close these issues.

Rigidity in Initializable's INITIALIZABLE_STORAGE slot
3 participants