-
Notifications
You must be signed in to change notification settings - Fork 11.8k
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
Use immutable beacon address in BeaconProxy #4435
Conversation
🦋 Changeset detectedLatest commit: 6e2594e The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
Co-authored-by: Hadrien Croubois <hadrien.croubois@gmail.com>
Co-authored-by: Hadrien Croubois <hadrien.croubois@gmail.com>
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.
I've updated docs to describe the potential issue with upgradeToAndCall
.
Congrats, your important contribution to this open-source project has earned you a GitPOAP! GitPOAP: 2023 OpenZeppelin Contracts Contributor: Head to gitpoap.io & connect your GitHub account to mint! Learn more about GitPOAPs here. |
Fixes #2538
Uses an immutable variable to store the beacon's address in BeaconProxy, in addition to the beacon storage slot. This avoids an extra SLOAD when retrieving the beacon address before each delegate call.
The immutable variable is used in
_implementation()
to read the beacon address before each delegate call.The beacon slot is still written during construction, so that the beacon address can be read externally according to ERC-1967. This beacon slot is required because the immutable variable must be private to avoid generating a getter function that could clash with a function from the implementation.
Rationale:
upgradeBeaconToAndCall
internal function in ERC1967Utils which sets the beacon slot, that function is not exposed in BeaconProxy but is only called on construction. The BeaconProxy itself does not provide a way to modify the beacon address after the BeaconProxy is deployed.PR Checklist
npx changeset add
)