Skip to content

Transparent Proxy Pattern (UUPS) vs Beacon Proxy Pattern

Muhammad Farrell Hauzan edited this page Jul 13, 2024 · 1 revision

Proxy Upgradeable Smart Contracts

Proxy upgradeable smart contracts are a design pattern in blockchain development that allows for the upgrade of a smart contract's logic without changing its address. This is achieved by separating the contract into two components:

  1. Proxy Contract: Holds the contract's state and delegates all calls to the implementation contract.
  2. Implementation Contract: Contains the actual logic of the contract.

The main advantage of this pattern is that it allows for contract upgrades while preserving the contract's address and state, which is crucial for maintaining contract interactions and data continuity.

Types of Proxy Patterns

UUPS (Universal Upgradeable Proxy Standard)

image

UUPS proxies are a specific type of upgradeable proxy that follows the EIP-1822 standard. In this pattern:

  • Proxy Contract: It includes minimal logic, primarily to delegate calls to the implementation contract and handle upgrades.
  • Implementation Contract: Contains both the logic and the upgrade functionality.

The upgrade process in UUPS involves calling an upgradeTo function within the implementation contract. This function modifies the storage of the proxy to point to a new implementation contract.

Key Characteristics of UUPS

  • Upgrade logic is embedded in the implementation contract.
  • Lower gas costs due to reduced complexity in the proxy contract.
  • Increased security as the upgrade logic is not part of the proxy.

Beacon Proxy Pattern

image

The Beacon Proxy Pattern involves a beacon contract that manages the implementation contract addresses. The beacon provides the logic address for multiple proxy contracts.

  • Beacon Contract: Manages and provides the implementation address for proxies.
  • Proxy Contract: Delegates calls to the address provided by the beacon.
  • Implementation Contract: Contains the logic to be executed.

In this pattern, when an upgrade is required, the beacon contract is updated to point to a new implementation. All proxies using the beacon will automatically start using the new implementation.

Key Characteristics of Beacon Proxy

  • Centralized upgrade management through the beacon.
  • Simplifies upgrades across multiple proxies.
  • Suitable for scenarios where multiple proxies need to share the same logic.

UUPS vs. Beacon Proxy

Upgrade Mechanism

  • UUPS: Upgrade logic within the implementation contract.
  • Beacon Proxy: Centralized upgrade logic via the beacon.

Proxy Complexity

  • UUPS: Simpler, minimal logic.
  • Beacon Proxy: Slightly more complex due to beacon interaction.

Gas Costs

  • UUPS: Lower, as upgrade logic is in the implementation contract.
  • Beacon Proxy: Potentially higher due to beacon management.

Centralized Control

  • UUPS: Each proxy can have its upgrade path.
  • Beacon Proxy: Centralized control through the beacon.

Upgrade Scope

  • UUPS: Individual proxies upgraded separately.
  • Beacon Proxy: All proxies linked to a beacon upgraded together.

Use Case

  • UUPS: Suitable for individual or fewer contracts requiring independent upgrades.
  • Beacon Proxy: Ideal for managing multiple contracts with shared logic.