Skip to content

Commit fe65cf4

Browse files
authored
feat: implement initial Lotus V2 State APIs (#13027)
Implement the Lotus V2 APIs for : * `StateGetActor` - enhanced to accept tipset selector. * `StateGetID` - enhanced to accept tipset selector / renamed from `LookupID` in v1 for consistency. Tests are added to exercise the end-to-end API call through JSON rpc with the raw wire format of the JSON-RPC request. Additional factory functions are added for `TipSetLimit`, a new concept to specify a limit for tipsets either as absolute height or relative to some tipset selector. The future State message search APIs in v2 aim to use Limit in upcoming PRs. To unblock progress in making incremental progress at v2 apis I am removing the implementation of StateSimulate and StateCompute in light of discussions at #13028.
1 parent 790c61b commit fe65cf4

File tree

11 files changed

+826
-181
lines changed

11 files changed

+826
-181
lines changed

CHANGELOG.md

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,13 @@
1010
# UNRELEASED
1111

1212
- fix(eth): always return nil for eth transactions not found ([filecoin-project/lotus#12999](https://github.com/filecoin-project/lotus/pull/12999))
13-
- feat: add experimental v2 APIs that are "F3 aware." (TODO: expand this section significantly to cover where someone learns about the new APIs, how they enable them, and what expectations they should have around them—i.e., they may change)
1413
- feat: add gas to application metric reporting `vm/applyblocks_early_gas`, `vm/applyblocks_messages_gas`, `vm/applyblocks_cron_gas` ([filecoin-project/lotus#13030](https://github.com/filecoin-project/lotus/pull/13030))
14+
- feat: add Lotus v2 experimental APIs with F3 awareness
15+
The Lotus V2 APIs introduce a powerful new TipSet selection mechanism that significantly enhances how applications interact with the Filecoin blockchain. The design reduces API footprint, seamlessly handles both traditional Expected Consensus and the new F3 protocol, and provides graceful fallbacks. See [Filecoin v2 APIs](https://filoznotebook.notion.site/Filecoin-V2-APIs-1d0dc41950c1808b914de5966d501658) for an
16+
in-depth overview.
17+
Pull requests:
18+
- https://github.com/filecoin-project/lotus/pull/13003
19+
- https://github.com/filecoin-project/lotus/pull/13027
1520

1621
# Node and Miner v1.32.2 / 2025-04-04
1722

@@ -66,7 +71,7 @@ The Lotus v1.32.1 release is a **MANDATORY patch release**, which will deliver t
6671
- The minimum supported Golang version is now `1.23.6` ([filecoin-project/lotus#12910](https://github.com/filecoin-project/lotus/pull/12910)).
6772
- The `SupportedProofTypes` field has been removed from the `Filecoin.StateGetNetworkParams` method because it was frequently overlooked during proof type updates and did not accurately reflect the FVM's supported proofs ([filecoin-project/lotus#12881](https://github.com/filecoin-project/lotus/pull/12881)).
6873
- Introduced `Agent` field to the `Filecoin.Version` response. Note that this change may be breaking, depending on the clients deserialization capabilities. ([filecoin-project/lotus#12904](https://github.com/filecoin-project/lotus/pull/12904)).
69-
- The `--only-cc` option has been removed from the `lotus-miner sectors extend` command.
74+
- The `--only-cc` option has been removed from the `lotus-miner sectors extend` command.
7075

7176
## 🏛️ Filecoin network version 25 FIPs
7277

@@ -120,7 +125,7 @@ For certain node operators, such as full archival nodes or systems that need to
120125
- chore: switch to pure-go zstd decoder for snapshot imports. ([filecoin-project/lotus#12857](https://github.com/filecoin-project/lotus/pull/12857))
121126
- chore: upgrade go-state-types with big.Int{} change that means an empty big.Int is now treated as zero for all operations ([filecoin-project/lotus#12936](https://github.com/filecoin-project/lotus/pull/12936))
122127
- chore(eth): make `EthGetBlockByNumber` & `EthGetBlockByHash` share the same cache and be impacted by `EthBlkCacheSize` config settings ([filecoin-project/lotus#12979](https://github.com/filecoin-project/lotus/pull/12979))
123-
- chore(deps): bump go-state-types to v0.16.0-rc8 ([filecoin-project/lotus#12973](https://github.com/filecoin-project/lotus/pull/12973))
128+
- chore(deps): bump go-state-types to v0.16.0-rc8 ([filecoin-project/lotus#12973](https://github.com/filecoin-project/lotus/pull/12973))
124129
- chore: set Mainnet nv25 upgrade epoch and update deps ([filecoin-project/lotus#12986](https://github.com/filecoin-project/lotus/pull/12986))
125130
- chore(eth): make EthGetBlockByNumber & EthGetBlockByHash share cache code ([filecoin-project/lotus#12979](https://github.com/filecoin-project/lotus/pull/12979))
126131

@@ -186,7 +191,7 @@ This is the stable release of the **upcoming MANDATORY Lotus v1.32.0 release**,
186191
- The minimum supported Golang version is now `1.23.6` ([filecoin-project/lotus#12910](https://github.com/filecoin-project/lotus/pull/12910)).
187192
- The `SupportedProofTypes` field has been removed from the `Filecoin.StateGetNetworkParams` method because it was frequently overlooked during proof type updates and did not accurately reflect the FVM's supported proofs ([filecoin-project/lotus#12881](https://github.com/filecoin-project/lotus/pull/12881)).
188193
- Introduced `Agent` field to the `Filecoin.Version` response. Note that this change may be breaking, depending on the clients deserialization capabilities. ([filecoin-project/lotus#12904](https://github.com/filecoin-project/lotus/pull/12904)).
189-
- The `--only-cc` option has been removed from the `lotus-miner sectors extend` command.
194+
- The `--only-cc` option has been removed from the `lotus-miner sectors extend` command.
190195

191196
## 🏛️ Filecoin network version 25 FIPs
192197

@@ -239,7 +244,7 @@ For certain node operators, such as full archival nodes or systems that need to
239244
- chore: switch to pure-go zstd decoder for snapshot imports. ([filecoin-project/lotus#12857](https://github.com/filecoin-project/lotus/pull/12857))
240245
- chore: upgrade go-state-types with big.Int{} change that means an empty big.Int is now treated as zero for all operations ([filecoin-project/lotus#12936](https://github.com/filecoin-project/lotus/pull/12936))
241246
- chore(eth): make `EthGetBlockByNumber` & `EthGetBlockByHash` share the same cache and be impacted by `EthBlkCacheSize` config settings ([filecoin-project/lotus#12979](https://github.com/filecoin-project/lotus/pull/12979))
242-
- chore(deps): bump go-state-types to v0.16.0-rc8 ([filecoin-project/lotus#12973](https://github.com/filecoin-project/lotus/pull/12973))
247+
- chore(deps): bump go-state-types to v0.16.0-rc8 ([filecoin-project/lotus#12973](https://github.com/filecoin-project/lotus/pull/12973))
243248
- chore: set Mainnet nv25 upgrade epoch and update deps ([filecoin-project/lotus#12986](https://github.com/filecoin-project/lotus/pull/12986))
244249
- chore(eth): make EthGetBlockByNumber & EthGetBlockByHash share cache code ([filecoin-project/lotus#12979](https://github.com/filecoin-project/lotus/pull/12979))
245250

@@ -420,8 +425,8 @@ This is the final release of the MANDATORY Lotus v1.30.0 release, which delivers
420425
- If you are running the v1.28.x version of Lotus, please go through the Upgrade Warnings section for the v1.28.* releases and v1.29.*, before upgrading to this release.
421426
- This release requires a minimum Go version of v1.22.7 or higher.
422427
- The `releases` branch has been deprecated with the 202408 split of 'Lotus Node' and 'Lotus Miner'. See https://github.com/filecoin-project/lotus/blob/master/LOTUS_RELEASE_FLOW.md#why-is-the-releases-branch-deprecated-and-what-are-alternatives for more info and alternatives for getting the latest release for both the 'Lotus Node' and 'Lotus Miner' based on the Branch and Tag Strategy.
423-
- To get the latest Lotus Node tag: git tag -l 'v*' | sort -V -r | head -n 1
424-
- To get the latest Lotus Miner tag: git tag -l 'miner/v*' | sort -V -r | head -n 1
428+
- To get the latest Lotus Node tag: git tag -l 'v*' | sort -V -r | head -n 1
429+
- To get the latest Lotus Miner tag: git tag -l 'miner/v*' | sort -V -r | head -n 1
425430

426431
## 🏛️ Filecoin network version 24 FIPs
427432

@@ -532,4 +537,4 @@ For the set of changes since the last stable release:
532537
| DemoYeti | 1 | +2/-1 | 1 |
533538
| qwdsds | 1 | +1/-1 | 1 |
534539
| Samuel Arogbonlo | 1 | +2/-0 | 2 |
535-
| Elias Rad | 1 | +1/-1 | 1 |
540+
| Elias Rad | 1 | +1/-1 | 1 |

api/v2api/full.go

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ package v2api
33
import (
44
"context"
55

6+
"github.com/filecoin-project/go-address"
7+
68
"github.com/filecoin-project/lotus/chain/types"
79
)
810

@@ -49,4 +51,51 @@ type FullNode interface {
4951
// fmt.Printf("Latest TipSet: %v\n", tipSet)
5052
//
5153
ChainGetTipSet(context.Context, types.TipSetSelector) (*types.TipSet, error) //perm:read
54+
55+
// MethodGroup: State
56+
// The State method group contains methods for interacting with the Filecoin
57+
// blockchain state, including actor information, addresses, and chain data.
58+
// These methods allow querying the blockchain state at any point in its history
59+
// using flexible TipSet selection mechanisms.
60+
61+
// StateGetActor retrieves the actor information for the specified address at the
62+
// selected tipset.
63+
//
64+
// This function returns the on-chain Actor object including:
65+
// - Code CID (determines the actor's type)
66+
// - State root CID
67+
// - Balance in attoFIL
68+
// - Nonce (for account actors)
69+
//
70+
// The TipSetSelector parameter provides flexible options for selecting the tipset:
71+
// - TipSetSelectors.Latest: the most recent tipset with the heaviest weight
72+
// - TipSetSelectors.Finalized: the most recent finalized tipset
73+
// - TipSetSelectors.Height(epoch, previous, anchor): tipset at the specified height
74+
// - TipSetSelectors.Key(key): tipset with the specified key
75+
//
76+
// See types.TipSetSelector documentation for additional details.
77+
//
78+
// If the actor does not exist at the specified tipset, this function returns nil.
79+
//
80+
// Experimental: This API is experimental and may change without notice.
81+
StateGetActor(context.Context, address.Address, types.TipSetSelector) (*types.Actor, error) //perm:read
82+
83+
// StateGetID retrieves the ID address for the specified address at the selected tipset.
84+
//
85+
// Every actor on the Filecoin network has a unique ID address (format: f0123).
86+
// This function resolves any address type (ID, robust, or delegated) to its canonical
87+
// ID address representation at the specified tipset.
88+
//
89+
// The function is particularly useful for:
90+
// - Normalizing different address formats to a consistent representation
91+
// - Following address changes across state transitions
92+
// - Verifying that an address corresponds to an existing actor
93+
//
94+
// The TipSetSelector parameter provides flexible options for selecting the tipset.
95+
// See StateGetActor documentation for details on selection options.
96+
//
97+
// If the address cannot be resolved at the specified tipset, this function returns nil.
98+
//
99+
// Experimental: This API is experimental and may change without notice.
100+
StateGetID(context.Context, address.Address, types.TipSetSelector) (*address.Address, error) //perm:read
52101
}

api/v2api/proxy_gen.go

Lines changed: 28 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/v2api/v2mocks/mock_full.go

Lines changed: 32 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)