Gas on Linea
What does gas pay for?​
Gas must be paid to cover any kind of on-chain computation. For a zk rollup like Linea, this mainly involves execution and storage on L2 and posting L2 transaction and messaging data to L1.
Of these, interacting with L1 has historically been far more costly. The main costs associated with L1 are:
- Verifying 'proofs', the cryptographic functions that confirm the validity of the state changes being recorded on L1.
- Posting data about L2 transactions in 'blobs', although this costs far less than the method it replaced.
Since the process of publishing data and verifying zk proofs on Ethereum mainnet is an indispensable and vital feature of Linea, we can consider the Linea gas price to cover two dimensions: the L2 execution and storage resources on Linea, and the L1 cost of guaranteeing the computational integrity of each Linea batch.
Minimizing gas fees​
Since the network's inception, offering cheap, accessible transaction costs has been a core objective for Linea.
Iterative changes have gradually driven these costs down; for example, the Alpha v2 upgrade in February 2024 introduced an improved data compression algorithm that dramatically reduced L1 computational costs by enabling more transactions to be included in each batch submitted to L1.
Linea's Alpha v3 upgrade builds on this progress by implementing EIP-4844, or "proto-danksharding".
EIP-4844: Proto-danksharding​
EIP-4844 arrived on Ethereum Mainnet on March 13, 2024, enabling Ethereum L2s to start using a
new transaction type that transports L2 transaction and messaging data to L1 in "blobs". Blobs
are a considerably more cost-efficient alternative to the existing method of posting L2
transaction and messaging data to L1, which involved sending calldata
embedded in a transaction.
With Linea Alpha v3, L2 transaction data is added to blobs appended to special blob-carrying transactions — the new transaction type mentioned previously.
The savings generated by using blobs rather than calldata
mainly derive from avoiding the highly
competitive L1 gas fee market altogether.
Since transactions containing calldata
have to compete with regular L1 transactions for
L1 block space, the L2s sending the data are vulnerable to L1 network congestion and the fee
spikes it generates. Before the transition to using blobs, L1 data availability—i.e. the cost
of posting data to L1 in calldata
—made up more than 95% of the gas costs on Linea.
Conversely, blobs have their own fee market, completely separate to the regular gas fee market on L1. As a result, L2s like Linea now have an alternative to paying regular gas fees, and can instead compete for blob space.
Due to having an entirely new market designed for L2 data availability, the cost of using blobs
will be a fraction of the cost of using calldata
.
Data compression​
Data compression significantly reduces the cost of posting L2 transaction and messaging data
to L1. With Alpha v2, compression was applied to calldata
; with Alpha v3, it's applied to blobs.
Linea's existing data compression mechanisms were upgraded in Alpha v2, in February 2024.
The system leverages the Linea prover's ability to operate with a compressed input, meaning it
can decompress calldata
or blob data to validate L2 state transitions. The data passed to the
L1 smart contract can therefore be considerably smaller, driving down the sum cost of transactions
in each block.
As of Alpha v3, the same data compression system is used on blob data instead.
The data compression algorithm is completely lossless, and can achieve compression ratios of up to 15:1 (where the data is 15 times smaller than its uncompressed state). This affords Linea the ability to submit data about far more transactions in each batch: before Alpha v2, Linea averaged ~150 transactions per batch; afterwards, it averages ~1,500.
As a result, significantly more transactions can be processed for the same computational cost on L1. The combination of blobs and data compression further amplifies the gas fee savings that are passed on to Linea users.
Proof aggregation​
Generating a zkSNARK proof on L1 is an essential step for finalizing transactions, as a verified proof demonstrates the integrity and validity of the submitted transactions.
Previously, Linea generated one proof per batch of transactions. After Alpha v2, Linea began to recursively aggregate multiple proofs into one.
The verification process on L1 costs ~400,000 gas — a cost that previously had to be covered for every batch. This gas cost is the same, however, for verifying a single batch of conflated batches (as Linea did in Alpha v1) as it is for verifying an aggregated proof representing multiple batches (as in Alpha v2). A proof that aggregates N proofs is N times cheaper, as the cost remains consistent.
With Alpha v2 upgrades, Linea now averages ~30 batches per final proof, making the process 1/30th as costly as it was in Alpha v1.