From e67b658d2bd043411e2cd968509220fad8a199cb Mon Sep 17 00:00:00 2001
From: Joel Willmore <95916148+jlwllmr@users.noreply.github.com>
Date: Mon, 7 Oct 2024 10:43:24 +0100
Subject: [PATCH] Update gas estimation pages (#758)
* Update gas estimation page
* Amend compatibility mode details and release notes
* Address feedback
---
docs/developers/guides/gas/gas-fees.mdx | 177 +++---------------
docs/developers/linea-version/index.mdx | 4 +-
.../reference/api/linea-estimategas.mdx | 12 +-
3 files changed, 33 insertions(+), 160 deletions(-)
diff --git a/docs/developers/guides/gas/gas-fees.mdx b/docs/developers/guides/gas/gas-fees.mdx
index 3e7c6d434..cfaf4b6b9 100644
--- a/docs/developers/guides/gas/gas-fees.mdx
+++ b/docs/developers/guides/gas/gas-fees.mdx
@@ -31,174 +31,49 @@ 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](./gas-on-linea.mdx).
-:::info
-A new API for estimating gas on Linea, `linea_estimateGas`, will be activated soon. See our
+`linea_estimateGas` is the recommended method for estimating gas on Linea. See our
[reference page](../../reference/api/linea-estimategas.mdx) for more information.
-If you intend to use `linea_estimateGas` once it is available, you want to find out more, or you
-have further questions, please get in touch on [Discord](https://discord.gg/linea).
-:::
-
-Linea supports [`eth_estimateGas`](https://docs.infura.io/api/networks/linea/json-rpc-methods/eth_estimategas),
+Linea also supports [`eth_estimateGas`](https://docs.infura.io/api/networks/linea/json-rpc-methods/eth_estimategas),
[`eth_gasPrice`](https://docs.infura.io/api/networks/linea/json-rpc-methods/eth_gasprice), and
[`eth_feeHistory`](https://docs.infura.io/api/networks/linea/json-rpc-methods/eth_feehistory).
You can use `eth_gasPrice` or `eth_feeHistory` to get the gas price, in wei, and you can use
`eth_estimateGas` to find out how many units of gas a specific transaction will need.
-:::note
-`eth_estimateGas` returns a total quantity of gas estimated for the transaction, whereas
-`linea_estimateGas` will return `gasLimit`, `baseFeePerGas`, and `priorityFeePerGas` once available,
-providing a more precise estimate.
-:::
-
-## `eth_gasPrice`
-
-### Parameters
+## [`linea_estimateGas`](../../reference/api/linea-estimategas.mdx)
-None.
+`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.
-### Returns
-
-A hexadecimal equivalent of an integer representing the current gas price in wei.
+It can also help prevent transactions from being rejected due to exceeding [module limits](../../../architecture/stack/trace-expansion-proving/prover-limits.mdx).
### Example
#### Request
-
-
- ```bash
- curl https://rpc.sepolia.linea.build \
- -X POST \
- -H "Content-Type: application/json" \
- -d '{"jsonrpc": "2.0","method": "eth_gasPrice","params": [],"id": 1}'
- ```
-
-
-
-#### Response
-
-
-
- ```json
- {
- "jsonrpc":"2.0",
- "id":1,
- "result":"0x12eb10e0c"
- }
- ```
-
-
-
-## `eth_feeHistory`
-
-### Parameters
-
-- `blockCount`: (integer) Number of blocks in the requested range. Between 1 and 1024 blocks can be
- requested in a single query. If blocks in the specified block range are not available, then only the
- fee history for available blocks is returned.
-- `newestBlock`: (string) Integer representing the highest number block of the requested range, or
- one of the string tags `latest`, `earliest`, or `pending`.
-- `array` of `integers`: (optional) A monotonically increasing list of percentile values to sample
- from each block's effective priority fees per gas in ascending order, weighted by gas used.
-
-### Returns
-
-- `oldestBlock`: Lowest number block of the returned range expressed as a hexadecimal number.
-- `baseFeePerGas`: An array of block base fees per gas, including an extra block value. The extra
- value is the next block after the newest block in the returned range. Returns zeroes for blocks
- created before EIP-1559.
-- `gasUsedRatio`: An array of block gas used ratios. These are calculated as the ratio of `gasUsed`
- and `gasLimit`.
-- `reward`: An array of effective priority fee per gas data points from a single block. All zeroes
- are returned if the block is empty.
-
-### Example
-
-#### Request
-
-
-
- ```bash
- curl https://rpc.sepolia.linea.build \
- -X POST \
- -H "Content-Type: application/json" \
- -d '{"id": 1, "jsonrpc": "2.0", "method": "eth_feeHistory", "params": ["0x1", "latest", [20]]}'
- ```
-
-
-
-#### Response
-
-
-
- ```json
- {
- "jsonrpc":"2.0",
- "id":1,
- "result":{
- "baseFeePerGas":[
- "0x7",
- "0x7"
- ],
- "gasUsedRatio":[0.0030745737704918033],
- "oldestBlock":"0x396334",
- "reward":[
- ["0x1427509c5"]
- ]
- }
- }
- ```
-
-
-
-## `eth_estimateGas`
-
-### Parameters
-
-- `TRANSACTION CALL OBJECT` [required]
- - `from`: [optional] 20 Bytes - The address the transaction is sent from.
- - `to`: 20 Bytes - The address the transaction is directed to.
- - `gas`: [optional] Hexadecimal value of the gas provided for the transaction execution. `eth_estimateGas` consumes zero gas, but this parameter may be needed by some executions.
- - `gasPrice`: [optional] Hexadecimal value of the gas price used for each paid gas.
- - `maxPriorityFeePerGas`: [optional] Maximum fee, in wei, the sender is willing to pay per gas above the base fee.
- - `maxFeePerGas`: [optional] Maximum total fee (base fee + priority fee), in wei, the sender is willing to pay per gas.
- - `value`: [optional] Hexadecimal value of the value sent with this transaction.
- - `data`: [optional] Hash of the method signature and encoded parameters. See the [Ethereum contract ABI specification](https://docs.soliditylang.org/en/latest/abi-spec.html).
- - `block number`: [required] A string representing a block number, or one of the string tags `latest`, `earliest`, `pending`, `safe`, or `finalized`. See the [default block parameter](https://ethereum.org/en/developers/docs/apis/json-rpc/#default-block).
-
-### Returns
-
-A hexadecimal of the estimate of the gas required for the given transaction.
-
-### Example
-
-#### Request
-
-
-
- ```bash
- curl https://rpc.sepolia.linea.build \
- -X POST \
- -H "Content-Type: application/json" \
- -d '{"jsonrpc":"2.0","method":"eth_estimateGas","params": [{"to": "0xd46e8dd67c5d32be8058bb8eb970870f07244567","gasPrice": "0x12eb10e0c","value": "0x9184e72a"}],"id":1}'
- ```
-
-
+```bash
+curl https://linea-mainnet.infura.io/v3/YOUR-API-KEY \
+-X POST \
+-H "Content-Type: application/json" \
+-d '{"jsonrpc": "2.0","method": "linea_estimateGas","params": [{"from": "0x971e727e956690b9957be6d51Ec16E73AcAC83A7","gas":"0x21000"}],"id": 53}'
+```
#### Response
-
-
- ```json
- {
- "jsonrpc":"2.0",
- "id":1,
- "result":"0x5208"
+```JSON
+{
+ "jsonrpc": "2.0",
+ "id": 53,
+ "result": {
+ "baseFeePerGas": "0x7",
+ "gasLimit": "0xcf08",
+ "priorityFeePerGas": "0x43a82a4"
}
- ```
-
-
+}
+```
+
+See the [reference page](../../reference/api/linea-estimategas.mdx) for full usage.
diff --git a/docs/developers/linea-version/index.mdx b/docs/developers/linea-version/index.mdx
index 583eac89e..5b835a997 100644
--- a/docs/developers/linea-version/index.mdx
+++ b/docs/developers/linea-version/index.mdx
@@ -77,7 +77,7 @@ See our [guide](../guides/finalized-block.mdx) for more.
### Reactivate `linea_estimateGas`
-**Mainnet: September 16**
+**Mainnet: September 30**
**Linea Sepolia: September 9**
@@ -121,7 +121,7 @@ Available on Linea Sepolia on July 31; available on Mainnet from August 1.
:::
-Activates the `linea_estimateGas` endpoint for use on Mainnet.
+Activates the `linea_estimateGas` endpoint for use on Mainnet in compatibility mode.
See our [reference page](../reference/api/linea-estimategas.mdx) for more information and usage.
diff --git a/docs/developers/reference/api/linea-estimategas.mdx b/docs/developers/reference/api/linea-estimategas.mdx
index ccf3ee53b..7ba36f779 100644
--- a/docs/developers/reference/api/linea-estimategas.mdx
+++ b/docs/developers/reference/api/linea-estimategas.mdx
@@ -14,9 +14,8 @@ import TabItem from '@theme/TabItem';
`linea_estimateGas` is currently only available on Linea Sepolia fully activated and on Mainnet in compatibility mode, which means it
returns the same results as `eth_gasPrice` on mainnet.
-`linea_estimateGas` will be fully activated on Mainnet on September 30. Infrastructure providers
-must adjust their node configurations to ensure compatibility mode is deactivated and `linea_estimateGas`
-functions fully. See our [guide](#compatibility-mode).
+If you're an infrastructure provider you must deactivate compatibility mode in your node
+configurations to ensure `linea_estimateGas` functions fully. See our [guide](#compatibility-mode).
:::
@@ -139,13 +138,12 @@ decimals to get the wei value. You can use any hexadecimal to decimal converter
## Compatibility mode
-When `linea_estimateGas` is activated on Mainnet on September 30, infrastructure providers and those
+`linea_estimateGas` was activated on Mainnet on September 30. Infrastructure providers and those
using their own nodes to submit transactions must adjust their configuration files to disable
compatibility mode.
No action is required for Linea Sepolia nodes using the `advanced-testnet` profile from the
-[`linea-besu-package` repository](https://github.com/Consensys/linea-besu-package/tree/main), since
-`linea_estimateGas` is already activated on Linea Sepolia.
+[`linea-besu-package` repository](https://github.com/Consensys/linea-besu-package/tree/main).
### Effects
@@ -164,7 +162,7 @@ reflects L1 costs and prover costs, which rise with transaction complexity/`call
### How to disable
For most people running an `advanced` Linea Besu node —a prerequisite for using `linea_estimateGas`—
-compatibility mode will already be disabled in the files you downloaded from the [`linea-besu-package`
+compatibility mode is already be disabled in the files you downloaded from the [`linea-besu-package`
repository](https://github.com/Consensys/linea-besu-package/tree/main).
:::note