Protocols use specific design patterns to work around this to be maintainable in practice
This leads to several risks as functionality can be changed
Proxy Pattern
The EIP 1822 proxy pattern is commonly used to allow upgradeability
This works by delegate calling functions in another contract that can be exchanged
Contract Setting Pattern
This works by splitting functionality in an entry point and a logic contract
The address of the logic contract can be set and changed
This offers more control as not everything is exchangeable but also limits flexibility
Governance and Upgradeability
Upgrades are executed by some governance mechanims
Typically two patterns exist: On-chain voting or a multisig with optional off-chain voting
Timelocks are used to allow users to react to changes - trade-off between being able to react to problems and risk for users not being able to react to changes
Trade-off between gate-keeper function of multisig and trust requirement
Taxonomy
If large parts of a protocol are upgradeable, the barrier to executing upgrades should be high
Automating Upgradeability Detection
The tool scans contracts for upgradeability using the EIP 1822 pattern:
By convention, EIP 1822 stores the address of the logic contract in a specific storage slot
The tool analyses the bytecode to detect whether this solt has been set
The contract setting pattern and patterns deviating from EIP 1822 are harder to detect as these differ across protocols
The tool also checks for common proxy pattern functions such as implementation()
Proxy Pattern Upgradeable Contracts
Protocol
Scanned
Upgradeable
Percentage
Aave
50
39
78.00%
MakerDAO
278
10
3.60%
Curve
111
1
0.90%
Convex
33
0
0.00%
Compound
72
36
50.00%
Case Study #1: Compound
Everything upgradeable (proxy pattern), everything goes through on-chain governance
Time locks are enforced (currently 2 days)
Reliance on voters to review and understand proposals
Timelocks meant that they couldn't immediately react: $90m funds lost
Smart Contract Upgradeability in DeFi protocols Daniel Perez and Paul Pritz Imperial College London
{"metaMigratedAt":"2023-06-16T23:35:10.136Z","metaMigratedFrom":"YAML","title":"Smart Contracts Upgradeability in DeFi protocols","breaks":true,"description":"Slides for FC22 DeFi workshop","slideOptions":"{\"theme\":\"white\"}","contributors":"[{\"id\":\"3f4fe1bb-6fd5-400f-b366-e0b40bf7913e\",\"add\":5150,\"del\":2511},{\"id\":\"53025b32-e778-4a7a-ba5f-3e8ab5cefb3a\",\"add\":6504,\"del\":2543}]"}