-
Notifications
You must be signed in to change notification settings - Fork 1.3k
feat: implement ChainGetTipSet in Lotus v2 APIs #13003
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
Conversation
Introduce the first API for Lotus v2, focusing on `ChainGetTipSet` within the `Chain` group. Define `TipSetSelector` for advanced tipset retrieval options, and create a compact JSON-RPC call format. Gracefully accommodate both EC and F3 finalized tipsets based on node configuration, where: * EC finalized tipset is returned when F3 is turned off, has no finalized tipset or F3 isn't ready. * F3 finalized is returned otherwise. Support three categories of selectors under `TipSetSelector`: * By tag: either "latest" or "finalized." * By height: epoch, plus optional fallback to previous non-null tipset. * By tipset key. The selection falls back to tag "latest" if the user specifies no selection criterion. The JSON-RPC format is designed to use JSON Object as the parameters passed to the RPC call to remain compact, and extensible. Examples include: * Latest Tipset: ```json {"jsonrpc":"2.0","method":"Filecoin.ChainGetTipSet","id":1} ``` * Finalized Tipset: ```json {"jsonrpc":"2.0","method":"Filecoin.ChainGetTipSet","params":{"tag":"finalized"},"id":1} ``` * Tipset at specific height: ```json {"jsonrpc":"2.0","method":"Filecoin.ChainGetTipSet","params":{"height":{"at":1413,"previous":true}},"id":1} ``` The open API spec and Markdown generation is excluded from this work to reduce the PR verbosity and will be included in a follow-up PR once the basic API primitives are reviewed. Note that all v2 APIs are experimental and may change with no notice. Relates to: #12719 Part of: #12990
20231de
to
905966a
Compare
I can live with this I think. I don't love the verbosity of the nesting but at least you've come up with short descriptors, |
Unrelated flaky itest recorded @ #13005 |
Introduce the concept of tipset anchor, to which a selection by height is anchored, i.e. parent of the target tipset. The anchor may be a tipset tag or a tipset key. Reflect the changes across tests .
Initial quick skim:
|
Discussed at stand up:
It is. From internal notion doc discussions I got the sense that we want to switch to "height" as the new terminology. Happy to revert back to Epoch, or move on with Epoch. Either works. @Kubuxu kindly pointed out that the Go SDK to interact with selectors is slightly cumbersome. I am open to suggestions on this one and I think we can iterate on it as non-breaking API changes later. For now I am keen to pin down the primitives for the Lotus V2 API first and then iterate.
The generics is used solely as Type Constraint to During the discussion, the choice of default param as "Heaviest" if nothing is specified came up:
@Kubuxu please add anything that I might have missed. @rvagg thoughts? |
Discussed it a bit with Masih.
written before Masih wore the above ^^ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No blocking comments from me. Just following along.
I wanted to confirm we are good with how calling these APIs looks like from other languages (particularly JS).
(Not an expert opinion here), but I agree. I think it's important to help builders "avoid running into trouble unknowingly". We can do this by either (as Kuba says):
That said, maybe best to match ETH ecosystem here? Looking at getBlockByNumber (which I assume is a good corollary), it looks like there is no default. |
Going ahead with no default.
Let's see what things look like after explicit param is needed and we can iterate. Probably faster to sit down and go through it synchronously to distill actionables on this one. |
@Kubuxu Do you want to get rid of the default anchor for getting tipset by height too or leave it as optional? |
Remove transparent fallback to heaviest tipset when no selector is specified.
|
the |
Looks really good, I'll have to try and restart my Eth API work ontop of this for /v2 to remind myself about all the module hackery needed to make this work. But I like how the |
Thanks for pointing that out. I will pick up a
This has been my thinking so far: to eventually turn v1 APIs into a wrapper of v2. |
Make `at` in by-height selector a pointer and validate that it is specifically set. This is to avoid zero-valued Go types shadow accidental valid calls.
Unpack the fullnode interfaces because docsgen garbage heap does not support nested types. Generate docs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sweet to see the doc generation happening.
I left a couple of comments when wearing the lens of "learn about new APIs from the generated docs". (I'm not up on all the limitations of our custom doc generation system.)
# Conflicts: # CHANGELOG.md
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SGWM
@@ -10,6 +10,7 @@ | |||
# UNRELEASED | |||
|
|||
- fix(eth): always return nil for eth transactions not found ([filecoin-project/lotus#12999](https://github.com/filecoin-project/lotus/pull/12999)) | |||
- 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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also TODO, when we revisit this, we need the link to this PR; I'll try and remember to add it when I follow-up with Eth stuff if it's not done already by then
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Help Me Obi-Wan Kenobi Generative AI, You’re My Only Hope.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry I was slow on the draw here, but a post-merge LGTM from me
Inevitably this is going to come up again. I think we should capture the rationale for the decision. I extracted some of the statements I saw to https://www.notion.so/filecoindev/Filecoin-V2-APIs-1d0dc41950c1808b914de5966d501658?pvs=4#1d2dc41950c180019135f921e171e984 but it needs work with happened verbally. |
Introduce the first API for Lotus v2, focusing on
ChainGetTipSet
within theChain
group. DefineTipSetSelector
for advanced tipset retrieval options, and create a compact JSON-RPC call format.Gracefully accommodate both EC and F3 finalized tipsets based on node configuration, where:
Support three categories of selectors under
TipSetSelector
:The open API spec and Markdown generation is excluded from this work to reduce the PR verbosity and will be included in a follow-up PR once the basic API primitives are reviewed.
Note that all v2 APIs are experimental and may change with no notice.
Relates to: #12719
Part of: #12990