Skill 3.2.3
Explain upgradeable contract patterns and their risks
Key Concepts
Deployed bytecode cannot change. A proxy contract works around this: users interact with the proxy, which holds the state and forwards every call with delegatecall to an implementation contract. Upgrading means pointing the proxy to a new implementation. In a transparent proxy, the upgrade logic lives in the proxy and an admin manages it; in a UUPS proxy (ERC-1822), the upgrade function lives in the implementation; a beacon proxy lets many proxies share one implementation address.
Because the implementation's code runs in the proxy's storage, constructors do not initialise the proxy; an initialize function protected by an initializer modifier is used instead, and implementations call _disableInitializers() so that nobody can initialise the implementation itself. New versions must keep the existing storage layout, adding variables only at the end, or state will be corrupted. OpenZeppelin uses standard storage slots (ERC-1967) for the implementation address to avoid collisions.
Upgradeability adds trust: whoever controls the upgrade can replace the logic. Production systems protect upgrades with multisig wallets and timelocks, and some teams deliberately choose immutable contracts.