-
Notifications
You must be signed in to change notification settings - Fork 11.9k
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
Redundant SSTORE in BeaconProxy constructor #4850
Comments
Hello @kadenzipfel This sstore was kept on purpose. While it is not necessary for the contract to work, it is used for "beacon discovery". The beacon proxy contains no public function, so that it is fully transparent, but that means it also does not (and cannot) include any getter. Now immagine you want to know which beacon a proxy uses. There is no easy way to do so. Our tolling used to rely (and still relies) on ERC-1967 slots for that kind of information. Writting the address of the beacon to the |
Fair enough, but fwiw I think a better solution would be to retrieve the immutable from the end of the bytecode or emit an event instead of using storage |
Both methods can be effective, and the choice often depends on factors such as gas efficiency. |
These are all great reasons to avoid the extra SSTORE. Also, an SSTORE is on the list of things we'd push to optimize for. Nonetheless, ERC1967 didn't provide a standard way to retrieve the beacon address from a client but it suggests doing it by reading from the slot:
Aside from our upgrades plugins library relying on the slot value, we also agreed that, if following the standard, there's not a more reliable option to retrieve the admin, implementation, and beacon addresses than from the slot.
Yeah this is good, but it's non-standard. It's breaking for platforms and tooling supporting EIP-1967, although it's possible everyone just adapts (not optimistic about this).
The EIP states that storage slot changes SHOULD be notified by events. If we're not changing the slot, then clients should arguably not expect an event to be emitted. This is just too ambiguous to rely on imo. Since this is only done at construction, we generally thought the extra SSTORE was not the end of the world in this case 😅 |
Closing for inactivity. I'll assume we agreed on the resolution 😋 Comments will be kept open in case anyone wants to add something. |
#4435 introduced the usage of an immutable implementation address. However, it still makes use of
ERC1967Utils.upgradeBeaconToAndCall
, which sets theBEACON_SLOT
tonewBeacon
.Setting
BEACON_SLOT
here is redundant since we use an immutable implementation address.The text was updated successfully, but these errors were encountered: