Deciphering the dilemma around Upgradeable Smart Contracts
A quick article that will help you clear your dilemma about using upgradeable smart contracts and their use
Hey, fam ๐๐ป
Welcome to another quick post on this classic dilemma around Upgradeable Smart Contracts:
๐ด Should we even consider upgradeable smart contracts?
๐ด Isnโt it safer to keep smart contracts as simple as possible? Additional complexity means more bugs, right?
๐ด But, how can we securely develop upgradeable smart contracts? What if we run into issues like storage collisions or inadequate upgrades?
๐ด Even if we develop, how should we upgrade them securely?
โฆ..
And such questions or confusion is what keeps us from choosing upgradeable features for our smart contracts.
I was in a similar discussion a few days ago and therefore wrote this quick post to eliminate some of these dilemmas around the upgradeable smart contracts.
๐ค Dev 1 who wanted to start developing his smart contracts was quite confused about whether or not he should make it upgradeable.
He believed his smart contracts might need additional functionalities in the future which is why upgradable contracts are perhaps the right choice.
However, he wasnโt sure if he should proceed with it, given the complexity of dealing with Upgradeable contracts.
๐จโ๐ปDev 2: ๐๐ฑ๐จ๐ณ๐ข๐ฅ๐ฆ๐ข๐ฃ๐ญ๐ฆ ๐ค๐ฐ๐ฏ๐ต๐ณ๐ข๐ค๐ต๐ด ๐ข๐ณ๐ฆ๐ฏโ๐ต ๐ณ๐ฆ๐ข๐ญ๐ญ๐บ ๐ข ๐ด๐ข๐ง๐ฆ ๐ช๐ฅ๐ฆ๐ข ๐ข๐ด ๐ต๐ฉ๐ฆ๐บ ๐ฎ๐ช๐จ๐ฉ๐ต ๐ช๐ฏ๐ต๐ณ๐ฐ๐ฅ๐ถ๐ค๐ฆ ๐ข๐ฅ๐ฅ๐ช๐ต๐ช๐ฐ๐ฏ๐ข๐ญ ๐ค๐ฐ๐ฎ๐ฑ๐ญ๐ฆ๐น๐ช๐ต๐บ ๐ต๐ฐ ๐บ๐ฐ๐ถ๐ณ ๐ค๐ฐ๐ฏ๐ต๐ณ๐ข๐ค๐ต๐ด ๐ข๐ฏ๐ฅ ๐ฎ๐ช๐จ๐ฉ๐ต ๐ฆ๐ฏ๐ฅ ๐ถ๐ฑ ๐ช๐ฏ๐ต๐ณ๐ฐ๐ฅ๐ถ๐ค๐ช๐ฏ๐จ ๐ฉ๐ช๐จ๐ฉ-๐ด๐ฆ๐ท๐ฆ๐ณ๐ช๐ต๐บ ๐ฃ๐ถ๐จ๐ด.
๐ฉ๐ฆ๐ณ๐ฆ ๐ค๐ฐ๐ถ๐ญ๐ฅ ๐ฃ๐ฆ ๐ข ๐ฃ๐ถ๐จ ๐ต๐ฉ๐ข๐ต ๐ญ๐ฆ๐ข๐ฅ๐ด ๐ต๐ฐ ๐ด๐ต๐ฐ๐ณ๐ข๐จ๐ฆ ๐ค๐ฐ๐ญ๐ญ๐ช๐ด๐ช๐ฐ๐ฏ๐ด ๐ฐ๐ณ ๐ข๐ฏ ๐ช๐ฏ๐ข๐ฅ๐ฆ๐ฒ๐ถ๐ข๐ต๐ฆ ๐ข๐ถ๐ต๐ฉ๐ฆ๐ฏ๐ต๐ช๐ค๐ข๐ต๐ช๐ฐ๐ฏ ๐ฑ๐ณ๐ฐ๐ค๐ฆ๐ฅ๐ถ๐ณ๐ฆ ๐ต๐ฉ๐ข๐ต ๐ข๐ญ๐ญ๐ฐ๐ธ๐ด ๐ข๐ฏ๐บ๐ฐ๐ฏ๐ฆ ๐ต๐ฐ ๐ถ๐ฑ๐จ๐ณ๐ข๐ฅ๐ฆ, ๐ธ๐ฉ๐ช๐ค๐ฉ ๐ฑ๐ถ๐ต๐ด ๐บ๐ฐ๐ถ๐ณ ๐ข๐ด๐ด๐ฆ๐ต๐ด ๐ข๐ต ๐ณ๐ช๐ด๐ฌ.
๐ฉโ๐ปDev 3: ๐๐ง ๐บ๐ฐ๐ถ ๐ข๐ณ๐ฆ๐ฏโ๐ต ๐ด๐ถ๐ณ๐ฆ ๐ข๐ฃ๐ฐ๐ถ๐ต ๐ข๐ญ๐ญ ๐บ๐ฐ๐ถ๐ณ ๐ด๐ฎ๐ข๐ณ๐ต ๐ค๐ฐ๐ฏ๐ต๐ณ๐ข๐ค๐ต ๐ง๐ถ๐ฏ๐ค๐ต๐ช๐ฐ๐ฏ๐ด ๐ข๐ฏ๐ฅ ๐ต๐ฉ๐ฆ๐ณ๐ฆ ๐ข๐ณ๐ฆ ๐ค๐ฉ๐ข๐ฏ๐ค๐ฆ๐ด ๐ต๐ฉ๐ข๐ต ๐ฏ๐ฆ๐ธ ๐ง๐ถ๐ฏ๐ค๐ต๐ช๐ฐ๐ฏ๐ข๐ญ๐ช๐ต๐ช๐ฆ๐ด ๐ฎ๐ช๐จ๐ฉ๐ต ๐ค๐ฐ๐ฎ๐ฆ ๐ช๐ฏ, ๐๐ฑ๐จ๐ณ๐ข๐ฅ๐ฆ๐ข๐ฃ๐ญ๐ฆ ๐ค๐ฐ๐ฏ๐ต๐ณ๐ข๐ค๐ต๐ด ๐ข๐ณ๐ฆ ๐ต๐ฉ๐ฆ ๐ณ๐ช๐จ๐ฉ๐ต ๐ค๐ฉ๐ฐ๐ช๐ค๐ฆ.
๐๐ฑ๐จ๐ณ๐ข๐ฅ๐ฆ๐ข๐ฃ๐ญ๐ฆ ๐ค๐ฐ๐ฏ๐ต๐ณ๐ข๐ค๐ต๐ด ๐ฅ๐ฐ ๐ฉ๐ฆ๐ญ๐ฑ ๐บ๐ฐ๐ถ ๐ง๐ช๐น ๐ข๐ฏ๐บ ๐ฃ๐ถ๐จ๐ด ๐ช๐ฏ ๐ด๐ฎ๐ข๐ณ๐ต ๐ค๐ฐ๐ฏ๐ต๐ณ๐ข๐ค๐ต๐ด ๐ธ๐ฉ๐ช๐ค๐ฉ ๐ค๐ข๐ฏโ๐ต ๐ฃ๐ฆ ๐ฐ๐ท๐ฆ๐ณ๐ญ๐ฐ๐ฐ๐ฌ๐ฆ๐ฅ.
๐๐ฅ๐ฅ๐ช๐ต๐ช๐ฐ๐ฏ๐ข๐ญ๐ญ๐บ, ๐ช๐ต ๐ช๐ด๐ฏโ๐ต ๐ณ๐ฆ๐ข๐ญ๐ญ๐บ ๐ต๐ฉ๐ข๐ต ๐ฉ๐ข๐ณ๐ฅ ๐ต๐ฐ ๐ฅ๐ฆ๐ท๐ฆ๐ญ๐ฐ๐ฑ ๐ถ๐ฑ๐จ๐ณ๐ข๐ฅ๐ฆ๐ข๐ฃ๐ญ๐ฆ ๐ค๐ฐ๐ฏ๐ต๐ณ๐ข๐ค๐ต๐ด, ๐ฏ๐ฐ๐ธ ๐ต๐ฉ๐ข๐ต ๐ธ๐ฆ ๐ฉ๐ข๐ท๐ฆ ๐ด๐ฐ๐ฎ๐ฆ ๐ณ๐ฆ๐ข๐ญ๐ญ๐บ ๐ฆ๐ง๐ง๐ฆ๐ค๐ต๐ช๐ท๐ฆ ๐ญ๐ช๐ฃ๐ณ๐ข๐ณ๐ช๐ฆ๐ด ๐ข๐ฏ๐ฅ ๐ต๐ฐ๐ฐ๐ญ๐ด ๐ธ๐ฉ๐ช๐ค๐ฉ ๐ฆ๐ฏ๐ด๐ถ๐ณ๐ฆ๐ด ๐ต๐ฉ๐ข๐ต ๐ช๐ด๐ด๐ถ๐ฆ๐ด ๐ญ๐ช๐ฌ๐ฆ ๐ด๐ต๐ฐ๐ณ๐ข๐จ๐ฆ ๐ค๐ฐ๐ญ๐ญ๐ช๐ด๐ช๐ฐ๐ฏ๐ด, ๐ถ๐ฏ๐ด๐ข๐ง๐ฆ ๐ถ๐ฑ๐จ๐ณ๐ข๐ฅ๐ฆ๐ด ๐ฆ๐ต๐ค ๐ข๐ณ๐ฆ ๐ต๐ข๐ฌ๐ฆ๐ฏ ๐ค๐ข๐ณ๐ฆ ๐ฐ๐ง.
My Thoughts๐ง
โฉ It has been a well-known theory in the Smart Contract world that ๐๐ฃ๐ ๐จ๐๐ค๐ช๐ก๐ ๐ ๐๐๐ฅ ๐ฉ๐๐๐๐ง ๐จ๐ข๐๐ง๐ฉ ๐๐ค๐ฃ๐ฉ๐ง๐๐๐ฉ ๐๐จ ๐จ๐๐ข๐ฅ๐ก๐ ๐๐จ ๐ฅ๐ค๐จ๐จ๐๐๐ก๐ ๐๐จ ๐๐๐๐๐ฃ๐ ๐๐ค๐ข๐ฅ๐ก๐๐ญ๐๐ฉ๐ฎ ๐ข๐๐๐๐ฉ ๐๐ฃ๐ฉ๐ง๐ค๐๐ช๐๐ ๐ฃ๐๐ฌ ๐๐ช๐๐จ.
And itโs quite true, to some extent, as we donโt really need to reinvent the wheel every time, and the security of smart contracts should always be a top priority.
โฉ However, smart contracts, despite their incredible powers of handling money or being immutable, are pieces of code too. And having some bugs in the code is inevitable.
As of now, ๐จ๐ฝ๐ด๐ฟ๐ฎ๐ฑ๐ฒ๐ฎ๐ฏ๐น๐ฒ ๐ฐ๐ผ๐ป๐๐ฟ๐ฎ๐ฐ๐๐ ๐ฎ๐ฟ๐ฒ ๐ผ๐ป๐ฒ ๐ผ๐ณ ๐๐ต๐ฒ ๐บ๐ผ๐๐ ๐ฒ๐ณ๐ณ๐ฒ๐ฐ๐๐ถ๐๐ฒ ๐๐ผ๐ผ๐น๐ ๐๐ฒ ๐ต๐ฎ๐๐ฒ ๐ถ๐ป ๐ต๐ฎ๐ป๐ฑ ๐ฟ๐ถ๐ด๐ต๐ ๐ป๐ผ๐ ๐๐ผ ๐ฟ๐ฒ๐๐ผ๐น๐๐ฒ ๐๐ต๐ฒ๐๐ฒ ๐ฏ๐๐ด๐ ๐ฒ๐๐ฒ๐ป ๐ถ๐ณ ๐ฐ๐ผ๐ป๐๐ฟ๐ฎ๐ฐ๐๐ ๐ฎ๐ฟ๐ฒ ๐ฑ๐ฒ๐ฝ๐น๐ผ๐๐ฒ๐ฑ, (in most cases).
โฉ Avoiding Upgradeable contracts just because they might add to the complexity of your existing smart contract architecture is probably a bad idea, especially when you know you might need one.
โฉ ๐๐ฉ๐ง๐๐ฃ๐๐ฉ๐๐๐ฃ๐๐ฃ๐ ๐ค๐ช๐ง ๐ช๐ฃ๐๐๐ง๐จ๐ฉ๐๐ฃ๐๐๐ฃ๐ ๐ค๐ ๐ช๐ฅ๐๐ง๐๐๐๐๐๐ก๐ ๐จ๐ข๐๐ง๐ฉ ๐๐ค๐ฃ๐ฉ๐ง๐๐๐ฉ๐จ ๐๐จ ๐ฌ๐๐๐ฉ ๐ฌ๐ ๐ฃ๐๐๐ ๐๐ฃ๐ ๐จ๐๐ค๐ช๐ก๐ ๐ฅ๐ง๐๐๐๐ง, ๐๐ฃ๐จ๐ฉ๐๐๐ ๐ค๐ ๐๐ซ๐ค๐๐๐๐ฃ๐ ๐๐ฉ.
โฉ Additionally, I believe smart contract upgrade patterns have now seen quite a journey starting from the Eternal Storage mechanism to the recent ones like Transparent Upgradeable proxy or UUPS.
Watch this video and enjoy, the very cool Thomas Wiesner, taking us to this entire journey of upgradeable smart contracts and how they evolved over time.
Therefore now we have a much safer procedure for upgrading contracts and amazing libraries and tools by Openzeppelin which simplifies the entire procedure.
Check out this treasure on Upgradeable smart contracts Here by OpenZeppelin.
โฉ While not every contract needs to be upgradeable, the ones that need to be should be upgradeable.
๐กThe right question for such contracts, however, isnโt whether or not they should be upgradeable.
Instead ๐
How should we Upgrade Smart Contracts Securely?
๐ด If you accumulate all the upgradeable capability of your smart contracts to a simple address (EOA), then itโs definitely not a secure contract.
๐ด One safe way of upgrading such smart contracts is to use ProxyAdmin contracts and a Multisig, thus eliminating a single authority control over upgrades.
๐ด Upgrading through on-chain governance is another secure, effective, and decentralized way of doing it.