0

A hackathon shows preference towards a bridge smart contract that is not upgradeable. Why would developers view this as an advantage when building a protocol or dapp? Wouldn't it sound better to say it is "upgradeable" instead of not?

What even is an upgradeable contract anyway to (1) a developer and (2) an everyday user of that dapp/contract, and the implications of upgradeability to these 2 parties?

3 Answers 3

3

An upgradeable contract is a contract for which the logic can be changed while keeping the same storage (data). For example you can add new functionality to an upgradeable contract without losing any of its data.

From a developer point of view it works by using two contracts: a proxy contract and a logic (implementation) contract. Everyone interacts with the proxy contract, which simply relays the transactions onwards to the logic contract. And the logic contract can be switched to be a new contract simply by updating the contract reference (address) in the proxy. All data is stored in the proxy contract.

From user perspective there is not much difference. They just interact with the proxy contract (which displays the functionality of the implementation contract) and they probably don't even notice if the underlying logic contract is switched (upgraded).

The reason why some consider upgradeability bad is that some entity has the power to change the logic. In theory they can rugpull the project by switching to a contract which sends them all of its assets. If there is no upgradeability, this attack vector doesn't exist.

4
  • by switching an address in the logic contract, aren't you effectively also altering the proxy contract simultaneously? Or is the proxy contract more like a container for variables? (not sure what you mean by data in the proxy contract, since it sounds like the logic contract is the one with data being manipulated).
    – user610620
    Commented Dec 9, 2022 at 5:46
  • All of the data is stored in the proxy, since calls to the logic contract are done by delegatecall. How things work at the implementation level depend on the used proxy pattern, but the basic idea remains the same: the proxy simply points to an address where an implementation contract resides and this address can be switched. Commented Dec 9, 2022 at 5:52
  • How does one technically identify that a contract is an upgradeable contract and that 2 additional (logic and proxy) contracts co-exist with it? If 2 not 3, then is the proxy contract the one that is directly called the upgradeable contract?
    – user610620
    Commented Dec 9, 2022 at 5:55
  • 2
    Well there is no strict technical definition, but typically if one contract (proxy) relays transactions to another contract (logic) and the logic contract can be switched, then it's using upgradeability. There are usually just these two contracts involved in upgadeability; an "upgradeable contract" usually refers to these two contracts working together - or maybe just to the logic contract.. Please read here for more: docs.openzeppelin.com/upgrades-plugins/1.x/writing-upgradeable Commented Dec 9, 2022 at 6:02
1

Upgradeable contracts are smart contracts where storage and logic are stored at two different addresses. That allows for the logic to be changed after the contract is deployed (more info at https://blog.chain.link/upgradable-smart-contracts/). The main issue with those is centralization. We're allowing the contract owner to change the logic (to something potentially malicious) at any time. Less important, but still worth noting, it incurs additional gas cost.

For a developper, upgradeability is a double-edged sword, as you have to be mindful of the original contract's storage layout when upgrading, amongst other things.

For the end user, it doesn't really change anything, apart from the point I talked about earlier (centralization issue + increased gas cost).

3
  • How does one technically identify that a contract is an upgradeable contract and that 2 additional (logic and proxy) contracts co-exist with it? If 2 not 3, then is the proxy contract the one that is directly called the upgradeable contract?
    – user610620
    Commented Dec 9, 2022 at 5:48
  • etherscan.io/address/… Here's an example (it's not upgradeable, but the idea is the same, except the point of using a proxy here isnt to enable upgradeability but to avoid deploying the same contract many times, and deploy a cheaper one instead that delegateCalls to a master copy of the code). Etherscan identifies them automatically, but typically, proxies have a fallback function that passes the data to the implementation contract through delegateCall, that's how you'd go about identifying them.
    – Foxxxey
    Commented Dec 9, 2022 at 5:58
  • (a proxy for an upgradeable contract would just implement another function that lets the owner change the implementation address)
    – Foxxxey
    Commented Dec 9, 2022 at 6:00
0

The reason why someone might prefer a non-upgradeable contract is simple: what you see is what you get. If you invest in, for example, an AMM which is not upgradeable, then you know the AMM is always going to follow the rules which it says in the contract, and not steal your money.

If the contract is upgradeable, the owner could upgrade it to one which steals your money. So an upgradeable contract isn't exactly a contract but more like a complicated way to trust someone else with your money.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.