diff --git a/docs/developers/guides/gas/gas-fees.mdx b/docs/developers/guides/gas-fees.mdx similarity index 89% rename from docs/developers/guides/gas/gas-fees.mdx rename to docs/developers/guides/gas-fees.mdx index f2bbdda00..51f959c6a 100644 --- a/docs/developers/guides/gas/gas-fees.mdx +++ b/docs/developers/guides/gas-fees.mdx @@ -17,8 +17,8 @@ total fee = units of gas used * (base fee + priority fee) Linea fundamentally works exactly the same as Ethereum. The only difference is that **the base fee is constant at 7 wei.** Blocks created by Linea use up to 24 million gas (less than 50% of the -maximum Linea block size of 61 million gas), and the fee decreases by 12.5% per block, effectively -keeping it at a stable 7 wei. +maximum Linea block size of 61 million gas), and the fee decreases by 12.5% per block, keeping it +at a stable 7 wei. The gas cost to submit your transaction and include it on Ethereum involves the following fee components: @@ -31,10 +31,11 @@ components: These two resource costs are abstracted by the rollup and covered by the recommended L2 gas price and gas used. -> Learn more about [gas on Linea](./gas-on-linea.mdx). +> Learn more about gas on Linea on our [support page](https://support.linea.build/getting-started/what-does-gas-pay-for/) +and release notes for [Alpha v2](../linea-version/index.mdx#alpha-v2) and [Alpha v3](../linea-version/index.mdx#alpha-v3). `linea_estimateGas` is the recommended method for estimating gas on Linea. See our -[reference page](../../reference/api/linea-estimategas.mdx) for more information. +[reference page](../reference/api/linea-estimategas.mdx) for more information. Linea also supports: - [`eth_estimateGas`](https://docs.infura.io/api/networks/linea/json-rpc-methods/eth_estimategas) @@ -57,7 +58,7 @@ by `linea_estimateGas` to calculate the cost of a transaction: The `extraData` field is a 32-byte space used to store arbitrary data, such as metadata or additional information relevant to the block. -On Linea, it is used by the sequencer and Linea Besu nodes running the correct plugins to expose +On Linea, it's used by the sequencer and Linea Besu nodes running the correct plugins to expose `linea_estimateGas`. ::: @@ -119,13 +120,13 @@ In some cases, transactions with lower priority fees are included ahead of other priority fees. This is because the nonce order of transactions submitted from the same account takes precedence. -## [`linea_estimateGas`](../../reference/api/linea-estimategas.mdx) +## [`linea_estimateGas`](../reference/api/linea-estimategas.mdx) `linea_estimateGas` is the recommended method for estimating gas on Linea. It returns `gasLimit`, `baseFeePerGas`, and `priorityFeePerGas`, and therefore provides a more precise gas estimate than the alternatives. -It can also help prevent transactions from being rejected due to exceeding [module limits](../../../architecture/stack/trace-expansion-proving/prover-limits.mdx). +It can also help prevent transactions from being rejected due to exceeding [module limits](../../architecture/stack/trace-expansion-proving/prover-limits.mdx). ### Example @@ -152,4 +153,4 @@ curl https://linea-mainnet.infura.io/v3/YOUR-API-KEY \ } ``` -See the [reference page](../../reference/api/linea-estimategas.mdx) for full usage. +See the [reference page](../reference/api/linea-estimategas.mdx) for full usage. diff --git a/docs/developers/guides/gas/gas-on-linea.mdx b/docs/developers/guides/gas/gas-on-linea.mdx deleted file mode 100644 index ef52e9140..000000000 --- a/docs/developers/guides/gas/gas-on-linea.mdx +++ /dev/null @@ -1,99 +0,0 @@ ---- -title: Gas on Linea -description: Understanding gas on Linea -image: /img/socialCards/gas-on-linea.jpg ---- - -## 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](#eip-4844-proto-danksharding). - -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. diff --git a/docs/developers/linea-version/index.mdx b/docs/developers/linea-version/index.mdx index 665c70af4..c02c8875d 100644 --- a/docs/developers/linea-version/index.mdx +++ b/docs/developers/linea-version/index.mdx @@ -216,6 +216,30 @@ Begin using blobs to post compressed L2 data to L1, with the aim of reducing dat costs. Blobs represent a transient data storage mechanism and an alternative to `calldata`, and can be significantly cheaper in L1 ETH costs depending on market demand. +
+ Learn more about EIP-4844 + + EIP-4844's arrival on Ethereum Mainnet enabled 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 Alpha v3, L2 transaction data is added to blobs. The savings generated by using blobs rather + than `calldata` mainly derive from avoiding the highly competitive L1 gas fee market. + + Since transactions containing `calldata` have to compete with regular L1 transactions for + block space, L2s are vulnerable to L1 network congestion and the fee spikes it can generate. + 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`. +
+ L1 and L2 smart contracts have been updated and deployed for Alpha v3. The contract addresses are: - New verifier contract @@ -270,7 +294,7 @@ None. Learn how to use the Linea Gas API [here](https://docs.linea.build/reference/api/linea-estimategas). ::: -## Alpha v2 release notes +## Alpha v2 @@ -293,14 +317,14 @@ Learn how to use the Linea Gas API [here](https://docs.linea.build/reference/api This release focuses on reducing L1 costs, enabling lower prices for end users. -Primarily, the L1 costs are driven by the following: +L1 costs are primarily driven by the following: - Proof verification, which is essentially a fixed cost for every batch submission. - Hashing the batch submission data to produce the public input of the Plonk verifier. -- Calldata costs, driven by the size of the batch submission data. This includes all the transaction data - from L2, as well as messaging data (one hash per L2 to L1 message). +- Calldata costs, driven by the size of the batch submission data. This includes all the +transaction data from L2, as well as messaging data (one hash per L2 to L1 message). ### Features @@ -311,8 +335,52 @@ To decrease L1 costs, we implemented the following features: that verifies that all the batches are correct. Since it takes the same amount of gas to verify an aggregated proof vs. a proof for a single batch of conflated blocks, the average cost of verifying a proof aggregating N proofs is N times cheaper. + +
+ + Learn more about 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. +
+ - Data compression: - This reduces the call data cost on L1 by compressing L2 block data. (Post EIP-4844 this will be stored in blobs) + +
+ + Learn more about data compression + + Data compression significantly reduces the cost of posting L2 transaction and messaging data + to L1. + + 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. + + 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. +
+ - Switched L2 to L1 messaging anchoring from individual hashes to Merkle trees: - Due to the size of the Merkle trees (32 messages) requiring only one Merkle root to be anchored, there is a 32x calldata size reduction for message hashes diff --git a/docs/developers/reference/api/linea-estimategas.mdx b/docs/developers/reference/api/linea-estimategas.mdx index fc5c185dd..3be0c84b4 100644 --- a/docs/developers/reference/api/linea-estimategas.mdx +++ b/docs/developers/reference/api/linea-estimategas.mdx @@ -13,7 +13,7 @@ Generates and returns an estimate of how much gas is necessary to allow the tran and be published on Ethereum. The transaction will not be added to the blockchain. For more information about estimating gas, and how this API formulates the transaction costs, see -the [Estimate transaction costs](../../guides/gas/gas-fees.mdx) topic. +the [Estimate transaction costs](../../guides/gas-fees.mdx) topic. The `priorityFeePerGas` returned by this method includes the cost of submitting the transaction to Ethereum, which can vary based on the size of the calldata. diff --git a/docusaurus.config.js b/docusaurus.config.js index ffaab4cfc..24497942a 100644 --- a/docusaurus.config.js +++ b/docusaurus.config.js @@ -326,11 +326,17 @@ const config = { from: "/build-on-linea/use-linea-testnet/bridge-funds", }, { - to: "/developers/guides/gas/gas-fees", - from: "/use-mainnet/gas-import", + to: "/developers/guides/gas-fees", + from: [ + "/use-mainnet/gas-import", + "/build-on-linea/gas-fees", + "/developers/guides/gas/gas-fees", + "/use-mainnet/gas-on-linea", + "/developers/guides/gas/gas-on-linea" + ], }, { - to: "/developers/guides/gas/gas-fees", + to: "/developers/reference/api/linea-estimategas", from: "/reference/api/linea-estimategas", }, { @@ -349,10 +355,6 @@ const config = { to: "/developers/quickstart/ethereum-differences", from: "/build-on-linea/ethereum-differences", }, - { - to: "/developers/guides/gas/gas-fees", - from: "/build-on-linea/gas-fees", - }, { to: "/developers/guides/run-a-node", from: [ @@ -414,10 +416,6 @@ const config = { to: "/architecture/stack/trace-expansion-proving", from: "/architecture/trace-expansion-proving", }, - { - to: "/developers/guides/gas/gas-on-linea", - from: "/use-mainnet/gas-on-linea", - }, { to: "/developers/tooling/cross-chain/shortcuts", from: "/build-on-linea/tooling/cross-chain/shortcuts", diff --git a/sidebars.js b/sidebars.js index 9fbb6cddb..a94442056 100644 --- a/sidebars.js +++ b/sidebars.js @@ -50,18 +50,6 @@ const sidebars = { id: "developers/guides/index", }, items: [ - { - type: "category", - label: "Gas", - link: { - type: "doc", - id: "developers/guides/gas/gas-fees", - }, - items: [ - "developers/guides/gas/gas-fees", - "developers/guides/gas/gas-on-linea", - ], - }, { type: "category", label: "Bridge your tokens", @@ -101,6 +89,7 @@ const sidebars = { }, ], }, + "developers/guides/gas-fees", "developers/guides/linea-api", "developers/guides/linea-sdk/index", "developers/guides/finalized-block",