Hi - I'm having a hard time understanding the differences between the UUPS pattern and the UpgradeableBeacon. In both cases, the upgrade can be handled by a single transaction, correct? However it sounds like the Beacon pattern has some gas savings benefits? If that's the case, what are the benefits of UUPS over the Beacon pattern?
Hello @gigamesh
UUPS
- the proxy point to an implementation AND the implementation contains the upgrade logic.
- when doing an upgrade, you call the proxy, then call is relayed to the implementation, and if everything is fine (accesscontrol / security protection) the proxy target will change to the new implementation
- if you have many proxies, you need to upgrade them one at a time
BeaconProxy
- you have to deploy and implementation, a beacon that references the implementation, and a proxy that references the proxy
- neither the proxy nor the implementation contains any upgrade logic
- whenever the proxy receives a call, it asks the beacon which is the address of the implementation and will delegate call to it.
- when doing an upgrade, you go to the beacon and tell it to reference a new implementation
- if you have many proxies pointing to the same beacon, setting a new implementation at the beacon level will upgrade all proxy simultaneously (and for cheap)
- What not to do: don't create a new beacon everytime you want to upgrade and then go to the proxy to tell them to use the new beacon.
Big thanks! Very helpful.
The impression I get is that the primary benefit of UUPS is it allows the proxies to opt-in to upgrades, while the Beacon requires the proxy owners to trust the Beacon admin.
Does that sound right? Are there any other benefits to UUPS?
EDIT:
Already got the info I was looking for from Santiago. thank you
I'd say UUPS and Beacon target different usecases.
- UUPS: each proxy is independent, and has its own lifecycle with its own upgrade process
- Beacon: multiple proxies share a common upgrade process, with common governance
Just a question/note here:
When you said: " you have to deploy and implementation, a beacon that references the implementation, and a proxy that references the proxy"
Whas it is supposed to say: "and a proxy that references the beacon" ??
Thanks.
Yes, I think the line should be:
"you have to deploy an implementation, a beacon that references the implementation, and a proxy that references the beacon"