Table of Contents
Fetching ...

A Comparative Gas Cost Analysis of Proxy and Diamond Patterns in EVM Blockchains for Trusted Smart Contract Engineering

Anto Benedetti, Tiphaine Henry, Sara Tucci-Piergiovanni

TL;DR

This study benchmarks gas costs for upgradeable smart contract patterns in EVM blockchains by comparing the classic monolithic approach with Proxy (UUPS) and Diamond (Facet-based) implementations using a notarization scenario. It employs Foundry to simulate deployments and upgrades across three versions, quantifying deployment and execution costs, and analyzes function-level gas usage through detailed traces. The results show that while upgradeable patterns incur higher deployment costs, the Diamond pattern offers superior modularity and lower minor-upgrade costs, with execution costs generally similar across patterns but increased by delegation overhead in proxy and diamond patterns. The work contributes two consolidated Alexandrian-form patterns and a decision model to guide developers in selecting between proxy and diamond patterns based on upgrade needs and tradeoffs, advancing practical guidance for trusted smart contract engineering.

Abstract

Blockchain applications are witnessing rapid evolution, necessitating the integration of upgradeable smart contracts. Software patterns have been proposed to summarize upgradeable smart contract best practices. However, research is missing on the comparison of these upgradeable smart contract patterns, especially regarding gas costs related to deployment and execution. This study aims to provide an in-depth analysis of gas costs associated with two prevalent upgradeable smart contract patterns: the Proxy and diamond patterns. The Proxy pattern utilizes a Proxy pointing to a logic contract, while the diamond pattern enables a Proxy to point to multiple logic contracts. We conduct a comparative analysis of gas costs for both patterns in contrast to a traditional non-upgradeable smart contract. We derive from this analysis a theoretical contribution in the form of two consolidated blockchain patterns and a corresponding decision model. By so doing we hope to contribute to the broader understanding of upgradeable smart contract patterns.

A Comparative Gas Cost Analysis of Proxy and Diamond Patterns in EVM Blockchains for Trusted Smart Contract Engineering

TL;DR

This study benchmarks gas costs for upgradeable smart contract patterns in EVM blockchains by comparing the classic monolithic approach with Proxy (UUPS) and Diamond (Facet-based) implementations using a notarization scenario. It employs Foundry to simulate deployments and upgrades across three versions, quantifying deployment and execution costs, and analyzes function-level gas usage through detailed traces. The results show that while upgradeable patterns incur higher deployment costs, the Diamond pattern offers superior modularity and lower minor-upgrade costs, with execution costs generally similar across patterns but increased by delegation overhead in proxy and diamond patterns. The work contributes two consolidated Alexandrian-form patterns and a decision model to guide developers in selecting between proxy and diamond patterns based on upgrade needs and tradeoffs, advancing practical guidance for trusted smart contract engineering.

Abstract

Blockchain applications are witnessing rapid evolution, necessitating the integration of upgradeable smart contracts. Software patterns have been proposed to summarize upgradeable smart contract best practices. However, research is missing on the comparison of these upgradeable smart contract patterns, especially regarding gas costs related to deployment and execution. This study aims to provide an in-depth analysis of gas costs associated with two prevalent upgradeable smart contract patterns: the Proxy and diamond patterns. The Proxy pattern utilizes a Proxy pointing to a logic contract, while the diamond pattern enables a Proxy to point to multiple logic contracts. We conduct a comparative analysis of gas costs for both patterns in contrast to a traditional non-upgradeable smart contract. We derive from this analysis a theoretical contribution in the form of two consolidated blockchain patterns and a corresponding decision model. By so doing we hope to contribute to the broader understanding of upgradeable smart contract patterns.
Paper Structure (18 sections, 4 figures)

This paper contains 18 sections, 4 figures.

Figures (4)

  • Figure 1: Illustration of the Proxy and Diamond patterns
  • Figure 2: Evolution of the notarization application across versions by patterns.
  • Figure 3: Evaluation results
  • Figure 4: Decision model for upgradeable smart contract pattern usage.