Polygon zkEVM: Effective Gas Price Live on Mainnet Beta

How transaction fees are calculated on the network is changing. Here’s how it’s evolving, what that means for users, and what it has to do with Don Quixote

Polygon Labs
January 5, 2024
Polygon Solutions
Image source: Dribbble

Today, a new mechanism called effectiveGasPrice was enabled on Polygon zkEVM Mainnet Beta, providing users with transaction fees that are more accurate and complete.

The effectiveGasPrice function uses two factors to calculate a transaction fee: the amount of execution in any given transaction and the cost of posting the raw transaction data to Ethereum, also known as data availability.

This is how the variables for effectiveGasPrice are determined, how it differs from the prior formula, and what it means for users of Polygon zkEVM Mainnet Beta.

Transaction Fees, Gas, and Don Quixote

When a user sends a transaction on a rollup, the transaction fee paid is meant to cover the cost of two things: the L2 network resources needed to execute the transaction + the L1 network resources for making the transaction data available. 

In the case of rollups built on top of Ethereum, this second part of the formula is what’s costly. On Polygon zkEVM Mainnet Beta, calldata accounts for approximately 80% of a transaction fee. 

Prior to effectiveGasPrice, Polygon zkEVM calculated transaction fees by referencing the gas prices on an L1 node and applying a fixed percentage of that gas price to a user. The challenge with this formula is that not all transactions contain the same amount of execution. 

Conceivably, there are transactions that use a lot of calldata (L1 network resources) but contain little execution (L2 network resources). Internally, the Polygon Hermez team refers to these transactions as a “Quixote” after the hero who does a lot but accomplishes very little. 

Because calldata costs are the main driver of transaction fees, such a transaction would have been expensive for the network but cheap for the user. Enabling effectiveGasPrice solves that problem.

Transaction Fees with effectiveGasPrice

With effectiveGasPrice enabled, this is the formula used for calculating the transaction fee users will pay:

L1 gas price * (L2 gas price reduction factor)

ELI5: The gas price estimate that the users see and sign is going to be higher than under the previous formula. But the final transaction fee will be more representative of the transaction’s use of L2 and L1 network resources. In practice this means that, in general, the final transaction fee for DeFi transactions will be lower than it was previously, and Quixote transactions will be more expensive.

For a detailed explanation of effectiveGasPrice and how the L2 gas price reduction factor is calculated, see [docs]: effective-gas-price 

Future Fee Optimizations and DYOR

Improvements, optimizations, and blob space are all coming this year. With EIP-4844 expected in the Cancun hard fork and data compression on the roadmap for Polygon zkEVM, the cost of both L1 and L2 network resources are expected to come down throughout the year.  

Users can verify and test the algorithm used to calculate transaction fees here:

zkevm-commonjs / test-vectors / effective-gas-price

zkevm-rom / process-tx.zkasm 

Tune into the blog and our social channels to keep up with updates about the Polygon ecosystem.

Together, we can build an equitable future for all through the mass adoption of Web3.

Website | Twitter | Developer Twitter | Forum | Telegram | Reddit | Discord | Instagram | Facebook | LinkedIn

More from blogs