Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove gas fees explainer and relocate its content #816

Merged
merged 4 commits into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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

Expand All @@ -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.
99 changes: 0 additions & 99 deletions docs/developers/guides/gas/gas-on-linea.mdx

This file was deleted.

76 changes: 72 additions & 4 deletions docs/developers/linea-version/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,30 @@
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.

<details>
<summary>Learn more about EIP-4844</summary>

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`.
</details>

L1 and L2 smart contracts have been updated and deployed for Alpha v3. The contract addresses are:

- New verifier contract
Expand Down Expand Up @@ -270,7 +294,7 @@
Learn how to use the Linea Gas API [here](https://docs.linea.build/reference/api/linea-estimategas).
:::

## Alpha v2 release notes
## Alpha v2

<table>
<tbody>
Expand All @@ -293,14 +317,14 @@

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

Expand All @@ -311,8 +335,52 @@
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.

<details>

<summary>Learn more about proof aggregation</summary>

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

Check failure on line 349 in docs/developers/linea-version/index.mdx

View workflow job for this annotation

GitHub Actions / Spelling

[vale] reported by reviewdog 🐶 [Microsoft.Dashes] Remove the spaces around ' — '. Raw Output: {"message": "[Microsoft.Dashes] Remove the spaces around ' — '.", "location": {"path": "docs/developers/linea-version/index.mdx", "range": {"start": {"line": 349, "column": 52}}}, "severity": "ERROR"}
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

Check warning on line 351 in docs/developers/linea-version/index.mdx

View workflow job for this annotation

GitHub Actions / Spelling

[vale] reported by reviewdog 🐶 [Microsoft.Contractions] Use 'it's' instead of 'it is'. Raw Output: {"message": "[Microsoft.Contractions] Use 'it's' instead of 'it is'.", "location": {"path": "docs/developers/linea-version/index.mdx", "range": {"start": {"line": 351, "column": 33}}}, "severity": "WARNING"}
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.
</details>

- Data compression:
- This reduces the call data cost on L1 by compressing L2 block data. (Post EIP-4844 this will be stored in blobs)

<details>

<summary>Learn more about data compression</summary>

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

Check failure on line 369 in docs/developers/linea-version/index.mdx

View workflow job for this annotation

GitHub Actions / Spelling

[vale] reported by reviewdog 🐶 [Vale.Spelling] Did you really mean 'prover's'? Raw Output: {"message": "[Vale.Spelling] Did you really mean 'prover's'?", "location": {"path": "docs/developers/linea-version/index.mdx", "range": {"start": {"line": 369, "column": 34}}}, "severity": "ERROR"}

Check warning on line 369 in docs/developers/linea-version/index.mdx

View workflow job for this annotation

GitHub Actions / Spelling

[vale] reported by reviewdog 🐶 [Consensys.CaseSensitive-Substitution] Consider standard format, '"Prover"' instead of "prover" (may not apply for start of sentence). Raw Output: {"message": "[Consensys.CaseSensitive-Substitution] Consider standard format, '\"Prover\"' instead of \"prover\" (may not apply for start of sentence).", "location": {"path": "docs/developers/linea-version/index.mdx", "range": {"start": {"line": 369, "column": 34}}}, "severity": "WARNING"}
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.

Check warning on line 377 in docs/developers/linea-version/index.mdx

View workflow job for this annotation

GitHub Actions / Spelling

[vale] reported by reviewdog 🐶 [Microsoft.Terms] Prefer 'afterward' over 'afterwards'. Raw Output: {"message": "[Microsoft.Terms] Prefer 'afterward' over 'afterwards'.", "location": {"path": "docs/developers/linea-version/index.mdx", "range": {"start": {"line": 377, "column": 47}}}, "severity": "WARNING"}

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.
</details>

- 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
Expand Down
2 changes: 1 addition & 1 deletion docs/developers/reference/api/linea-estimategas.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
20 changes: 9 additions & 11 deletions docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -333,11 +333,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",
},
{
Expand All @@ -356,10 +362,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: [
Expand Down Expand Up @@ -421,10 +423,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",
Expand Down
13 changes: 1 addition & 12 deletions sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -101,6 +89,7 @@ const sidebars = {
},
],
},
"developers/guides/gas-fees",
"developers/guides/linea-api",
"developers/guides/linea-sdk/index",
"developers/guides/finalized-block",
Expand Down
Loading