From 23833f5c2237ad44687ce04c71e2e192db971417 Mon Sep 17 00:00:00 2001 From: bgravenorst Date: Tue, 10 Sep 2024 09:52:31 +1000 Subject: [PATCH 1/3] Add support for finalized tag. Signed-off-by: bgravenorst --- docs/developers/guides/finalized-block.mdx | 34 ++++++++++++------- .../reference/api/linea-estimategas.mdx | 9 +++-- .../reference/api/linea-getproof.mdx | 18 ++++------ 3 files changed, 35 insertions(+), 26 deletions(-) diff --git a/docs/developers/guides/finalized-block.mdx b/docs/developers/guides/finalized-block.mdx index 83ab96b63..f41ca1b06 100644 --- a/docs/developers/guides/finalized-block.mdx +++ b/docs/developers/guides/finalized-block.mdx @@ -6,24 +6,34 @@ image: /img/socialCards/retrieve-finalized-l2-blocks.jpg A finalized L2 block is a block on an L2 blockchain (Linea) that has been confirmed and validated by the L1 blockchain (Ethereum), ensuring its immutability and security. -Linea doesn't currently support the Ethereum-standard `finalized` block parameter tag, meaning you -cannot use the tag in JSON-RPC API calls to retrieve blocks that have been confirmed by the L1 -network. This includes, for example, methods where you can specify a block parameter, such as -[`linea_estimateGas`](../reference/api/linea-estimategas.mdx). +There are two methods to obtain the current finalized block: -:::note -Support for the `finalized` block parameter is planned in a future Linea release. -::: +- [Use the `finalized` block parameter tag](#use-the-finalized-tag) in JSON-RPC API calls. +- [Query the Linea L1 rollup contract](#query-the-rollup-contract). -This limitation requires you to query the [Linea L1 rollup contract](https://etherscan.io/address/0xd19d4b5d358258f05d7b411e21a1460d11b0876f#readProxyContract) -to retrieve the value of the current finalized L2 block number stored in the `currentL2BlockNumber` -variable. +## Use the `finalized` tag -## Prerequisites +Use the `finalized` tag in API calls to specify a block that has been confirmed by the L1 +network. For example, here the `eth_getBlockByNumber` method returns information about the current +finalized block: + +```bash +curl https://rpc.linea.build \ + -X POST \ + -H "Content-Type: application/json" \ + -d '{"jsonrpc":"2.0","method":"eth_getBlockByNumber","params":["finalized",false],"id":1}' +``` + +## Query the rollup contract + +Query the [Linea L1 rollup contract](https://etherscan.io/address/0xd19d4b5d358258f05d7b411e21a1460d11b0876f#readProxyContract) +to retrieve the value of the current finalized L2 block number stored in the `currentL2BlockNumber` variable. + +### Prerequisites - [Download and install Node.js](https://nodejs.org/en) -## Create the script +### Create the script 1. In your project folder, initialize the project and install the `web3` package: diff --git a/docs/developers/reference/api/linea-estimategas.mdx b/docs/developers/reference/api/linea-estimategas.mdx index e5de7920b..d9527493b 100644 --- a/docs/developers/reference/api/linea-estimategas.mdx +++ b/docs/developers/reference/api/linea-estimategas.mdx @@ -61,10 +61,13 @@ using `linea_estimateGas` for more accurate results. - `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`: _\[optional]_ A string representing a block number, or one of the string tags `latest`, `earliest`, or - `pending`. See the [default block parameter](https://ethereum.org/en/developers/docs/apis/json-rpc/#default-block). - You can [query the L1 rollup contract](../../guides/finalized-block.mdx) to retrieve the current finalized block. + - `block number`: _\[optional]_ A string representing a block number, or one of the string tags `latest`, `earliest`, + `pending`, `safe`, or `finalized`. + :::note + A `finalized` block is a block on an L2 blockchain (Linea) that has been confirmed and validated by + the L1 blockchain (Ethereum). + ::: ## Returns diff --git a/docs/developers/reference/api/linea-getproof.mdx b/docs/developers/reference/api/linea-getproof.mdx index 94a614e89..09c78bfc0 100644 --- a/docs/developers/reference/api/linea-getproof.mdx +++ b/docs/developers/reference/api/linea-getproof.mdx @@ -16,21 +16,17 @@ The supplied block parameter must be an L2 block that has been finalized on L1. In the [example response](#response) the account exists but the slot does not. -:::info important - -Linea currently does not support the block parameter `finalized`, meaning that to get the current -finalised block on the L1, users must [retrieve the value from the `currentL2BlockNumber`](../../guides/finalized-block.mdx) -variable in the [LineaRollup L1 contract](https://etherscan.io/address/0xd19d4b5d358258f05d7b411e21a1460d11b0876f#readProxyContract). - -::: - ## Parameters - `address`: A string representing the address (20 bytes) for which the proof is requested. - `storageKeys`: An array of 32-byte storage keys to be proofed and included. -- `blockParameter`: A hexadecimal block number, or one of the string tags `latest`, `earliest`, or - `pending`. See the [default block parameter](https://ethereum.org/en/developers/docs/apis/json-rpc/#default-block). - You can [query the L1 rollup contract](../../guides/finalized-block.mdx) to retrieve the current finalized block. +- `blockParameter`: A hexadecimal block number, or one of the string tags `latest`, `earliest`, + `pending`, `safe`, or `finalized`. + + :::note + A `finalized` block is a block on an L2 blockchain (Linea) that has been confirmed and validated by + the L1 blockchain (Ethereum). + ::: ## Returns From 534e752d15d0d29fd3bb7ce6c0ff016dabe0d12f Mon Sep 17 00:00:00 2001 From: m4sterbunny Date: Wed, 11 Sep 2024 11:01:16 +0100 Subject: [PATCH 2/3] Update docs/developers/reference/api/linea-estimategas.mdx safe not supported --- docs/developers/reference/api/linea-estimategas.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/developers/reference/api/linea-estimategas.mdx b/docs/developers/reference/api/linea-estimategas.mdx index d9527493b..0887def84 100644 --- a/docs/developers/reference/api/linea-estimategas.mdx +++ b/docs/developers/reference/api/linea-estimategas.mdx @@ -62,7 +62,7 @@ using `linea_estimateGas` for more accurate results. - `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`: _\[optional]_ A string representing a block number, or one of the string tags `latest`, `earliest`, - `pending`, `safe`, or `finalized`. + `pending`, or `finalized`. :::note A `finalized` block is a block on an L2 blockchain (Linea) that has been confirmed and validated by From 56e9907a34801ac39f65285890a972c09c29bc08 Mon Sep 17 00:00:00 2001 From: m4sterbunny Date: Wed, 11 Sep 2024 11:02:00 +0100 Subject: [PATCH 3/3] Update docs/developers/reference/api/linea-getproof.mdx safe not supported --- docs/developers/reference/api/linea-getproof.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/developers/reference/api/linea-getproof.mdx b/docs/developers/reference/api/linea-getproof.mdx index 09c78bfc0..c4c0c395b 100644 --- a/docs/developers/reference/api/linea-getproof.mdx +++ b/docs/developers/reference/api/linea-getproof.mdx @@ -21,7 +21,7 @@ In the [example response](#response) the account exists but the slot does not. - `address`: A string representing the address (20 bytes) for which the proof is requested. - `storageKeys`: An array of 32-byte storage keys to be proofed and included. - `blockParameter`: A hexadecimal block number, or one of the string tags `latest`, `earliest`, - `pending`, `safe`, or `finalized`. + `pending`, or `finalized`. :::note A `finalized` block is a block on an L2 blockchain (Linea) that has been confirmed and validated by