Skip to content

Commit e37d45f

Browse files
authored
docs: add ETH API information to V2 API documentation (#13068)
* docs: v2 api docs updated to cover ETH group 1. Added status update about ETH APIs in v2 2. Made clear that Eth APIs have updated (F3 aware) `safe` and `finalized` semantics. 3. Added a couple of examples. 4. Removed some cruft/unnecessary sections at the top of the document I started with Claude for this change but felt it was too wordy. I want this addition to be short and sweet and reference other parts of the doc rather than duplicate about safe and finalized. * Updated status to be clear about what PR certain additions were made in. * Incorporating PR feedback about safe differences with v2 and ETH to Eth.
1 parent a6ceaff commit e37d45f

File tree

2 files changed

+59
-16
lines changed

2 files changed

+59
-16
lines changed

documentation/en/api-experimental-user-facing-v2-docs/CLAUDE.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,27 @@ This directory contains the experimental user-facing documentation for Filecoin'
2020
- `api-v2-experimental.md`: The main user facing documentation file that is copied to Notion.
2121
- Related code: `api/v2api/full.go` (API implementation)
2222
- Related code: `chain/types/tipset_selector.go` (Key types)
23+
- Related code: `node/impl/eth/api.go` (ETH V2 API implementation)
24+
- Related code: `node/impl/eth/tipsetresolver.go` (ETH block specifier to tipset conversion)
25+
- Related code: `node/impl/eth/filecoin.go` (Filecoin-specific ETH methods)
2326
- Generated docs: `documentation/en/api-v2-unstable-methods.md`
2427

28+
## ETH V2 APIs Key Implementation Details
29+
30+
The ETH V2 APIs implementation in PR #13026 introduces important changes to how block specifiers like "safe" and "finalized" work:
31+
32+
1. **TipSet Resolution**: The file `node/impl/eth/tipsetresolver.go` contains the key logic for converting Ethereum block specifiers to Filecoin tipsets. The V2 implementation:
33+
- Connects directly to the F3 subsystem for finality information
34+
- Implements a more responsive definition of "safe" and "finalized" blocks
35+
- Falls back gracefully to EC finality when F3 is not available
36+
37+
2. **Block Handling**: In V2 ETH APIs, there's no longer a `-1` offset that was present in V1. This means:
38+
- "latest" truly refers to the latest tipset (head)
39+
- "safe" refers to either F3 finalized or head-200, whichever is more recent
40+
- "finalized" directly maps to F3 finality when available
41+
42+
3. **Request Path**: Requests to `/v2` ETH endpoints are processed through dedicated handlers that use the F3-aware tipset resolution logic, offering faster confirmation times.
43+
2544
## Commands
2645

2746
### Regenerating the Table of Contents

documentation/en/api-experimental-user-facing-v2-docs/api-v2-experimental.md

Lines changed: 40 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
# Meta
99
## Status
1010

11-
- 2025-04-23: This document has been updated to account for the minimum initial set of non-ETH /v2 API groups as specified in [issue #12991](https://github.com/filecoin-project/lotus/issues/12991).
11+
- 2025-04-24: This document has been updated to include information about Eth APIs in `/v2`. This was reviewed in [PR #13068](https://github.com/filecoin-project/lotus/pull/13068).
12+
- 2025-04-23: This document has been updated to account for the minimum initial set of non-Eth /v2 API groups as specified in [issue #12991](https://github.com/filecoin-project/lotus/issues/12991). This was reviewed in [PR #13051](https://github.com/filecoin-project/lotus/pull/13051)
1213
- 2025-04-09: This document is still actively a Work In Progress. It has a draft discussing `ChainGetTipSet`. Additional APIs and API Groups will be added as part of working on [issue #12987](https://github.com/filecoin-project/lotus/issues/12987).
1314

1415
## Table of Contents
@@ -24,8 +25,6 @@ This ToC was generated using [Markdown All in One](https://marketplace.visualstu
2425
- [Table of Contents](#table-of-contents)
2526
- [Introduction](#introduction)
2627
- [The Selector Pattern](#the-selector-pattern)
27-
- [Overview](#overview)
28-
- [Groups](#groups)
2928
- [Chain](#chain)
3029
- [ChainGetTipSet](#chaingettipset)
3130
- [Selector Types](#selector-types)
@@ -43,6 +42,8 @@ This ToC was generated using [Markdown All in One](https://marketplace.visualstu
4342
- [Parameters](#parameters-1)
4443
- [Request Example](#request-example-1)
4544
- [Response](#response-2)
45+
- [Ethereum (Eth)](#ethereum-eth)
46+
- [Examples](#examples)
4647
- [Consensus Protocol Notes](#consensus-protocol-notes)
4748
- [Understanding `finalized` TipSets](#understanding-finalized-tipsets)
4849
- [Node Configuration Impact](#node-configuration-impact)
@@ -118,19 +119,7 @@ This documentation focuses on the `TipSetSelector` as implemented in the `ChainG
118119

119120
Each API group follows the same design principles of extensibility, expressiveness, and F3 awareness while minimising the API surface area.
120121

121-
The remainder of this documentation explores the `TipSetSelector` in detail, showing how to use it with the `ChainGetTipSet` method through various examples and use cases.
122122

123-
# Overview
124-
125-
This documentation covers the TipSet selection mechanisms in the Filecoin V2 APIs, focusing on the flexible selection patterns introduced for retrieving tipsets from the Filecoin blockchain.
126-
127-
## Groups
128-
129-
- Chain
130-
- `ChainGetTipSet`
131-
- State
132-
- `StateGetActor`
133-
- `StateGetID`
134123

135124
# Chain
136125

@@ -441,6 +430,41 @@ The method returns the ID address (string) corresponding to the input address at
441430

442431
If the address cannot be resolved to an ID address at the specified tipset state (e.g., it never existed or was created after that tipset), an error is returned.
443432

433+
## Ethereum (Eth)
434+
435+
The V2 API namespace includes all the Ethereum (Eth) APIs that `/v1` supports, but the `finalized` and `safe` tags have been updated to consult the F3 subsystem (if enabled) for finality information. `finalized` and `safe` for the "Eth" APIs has the same meaning and fallback outlined in [Consensus Protocol Notes](#consensus-protocol-notes). In addition, in V2, `safe` will look back a maximum 30 epochs, whereas V1 looks back 30.
436+
437+
For a complete list of available Eth methods in V2, refer to the [V2 autogenerated documentation](https://github.com/filecoin-project/lotus/blob/master/documentation/en/api-v2-unstable-methods.md#eth).
438+
439+
### Examples
440+
**Example: getting an Eth block by number using the `finalized` tag:**
441+
442+
```json
443+
{
444+
"jsonrpc": "2.0",
445+
"method": "Eth.GetBlockByNumber",
446+
"params": [
447+
"finalized",
448+
true
449+
],
450+
"id": 1
451+
}
452+
```
453+
454+
**Example: retrieving account balance at a `safe` block:**
455+
456+
```json
457+
{
458+
"jsonrpc": "2.0",
459+
"method": "Eth.GetBalance",
460+
"params": [
461+
"0x5cbeecf99d3fdb3f25e309cc264f240bb0664031",
462+
"safe"
463+
],
464+
"id": 1
465+
}
466+
```
467+
444468
# Consensus Protocol Notes
445469

446470
The Filecoin network is currently in the process of testing and activating Filecoin Fast Finality (F3), a new consensus mechanism that provides faster finality guarantees. During this transition period, the network will contain a mix of nodes - some with F3 enabled and others still using only the traditional Expected Consensus (EC) finality mechanism.
@@ -1107,7 +1131,7 @@ JSON-RPC allows named parameters (using a JSON object instead of an array for `p
11071131

11081132
## Future API Groups
11091133

1110-
The Filecoin V2 APIs initiative will expand beyond the Chain and State API groups demonstrated in this document. Each API group will follow the same principles of using selectors for expressive queries while maintaining a minimal API surface.
1134+
The Filecoin V2 APIs initiative will expand beyond the Chain, State, and Eth API groups demonstrated in this document. Each API group will follow the same principles of using selectors for expressive queries while maintaining a minimal API surface.
11111135

11121136
### State API Group
11131137

0 commit comments

Comments
 (0)