Proxy pattern - Good practices and SOC #521
-
Hello, I hope this is a good place to discuss about this topic, else please do not hesitate to redirect me in the right place. I'm learing and experiencing the upgradable features that you proposed. Since I'm still learning best practices around smart contracts, I was wondering if there was some kind of advice to follow on where some specific functions should be positioned either in the implementation or in the proxy Especially about a I don't know if there is a kind of rule saying that Proxy must only implement initializer and fallback functions to avoid any risk or smthg, so here is my point. Thank you for any advice about it 🙏 |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 6 replies
-
You probably shouldn't implement functions related to the business logic of your dApp in the proxy because the general idea of it is to redirect calls (like in EIP-1167). But, sometimes, you want some logic in the proxy related to extra functionality, like functions providing upgradeability of the implementation contract. Then you have a new issue: clashes between proxy and implementation functions. This can be solved in different ways, with some Pros and Cons that are out of the scope of this answer, but I recommend you to check Transparent Proxies and UUPS for upgrades.
|
Beta Was this translation helpful? Give feedback.
-
hey there @bal7hazar thanks for asking :) the lib today requires implementations to |
Beta Was this translation helpful? Give feedback.
-
hey! could you help me to know how the proxy is upgraded? |
Beta Was this translation helpful? Give feedback.
You probably shouldn't implement functions related to the business logic of your dApp in the proxy because the general idea of it is to redirect calls (like in EIP-1167).
But, sometimes, you want some logic in the proxy related to extra functionality, like functions providing upgradeability of the implementation contract. Then you have a new issue: clashes between proxy and implementation functions. This can be solved in different ways, with some Pros and Cons that are out of the scope of this answer, but I recommend you to check Transparent Proxies and UUPS for upgrades.
getImplementationHash
in the implementation results from using the UUPS proxy pattern.