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

Add support for finalized tag. #728

Merged
merged 4 commits into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
34 changes: 22 additions & 12 deletions docs/developers/guides/finalized-block.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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}'
m4sterbunny marked this conversation as resolved.
Show resolved Hide resolved
```

## 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:

Expand Down
9 changes: 6 additions & 3 deletions docs/developers/reference/api/linea-estimategas.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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`, 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

Expand Down
18 changes: 7 additions & 11 deletions docs/developers/reference/api/linea-getproof.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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`, 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

Expand Down