Skip to content

feat: expose /v2 APIs through Lotus Gateway#13075

Merged
masih merged 3 commits intomasterfrom
masih/v2-gateway
Apr 29, 2025
Merged

feat: expose /v2 APIs through Lotus Gateway#13075
masih merged 3 commits intomasterfrom
masih/v2-gateway

Conversation

@masih
Copy link
Copy Markdown
Member

@masih masih commented Apr 28, 2025

Integrate the existing v2 APIs into Lotus Gateway such that they are accessible via /rpc/v2 endpoint similar to full node APIs except through the gateway reverse proxy along with rate limiting and handling of stateful connections over web socket.

The prior gateway implementation did not have a concept of per-uri reverse proxy handling. The changes here separate reverse proxy implementation in gateway from the gateway node to introduce separate handling of v1 and v2 APIs. The work introduces a top-level v2api.Gateway interface to capture the APIs exposed by the v2 gateway and generate any relevant documentation based on the interface.

Specifically, the work here separates the handling of stateful connections between v1 and v2 to avoid any cross-contamination between Eth calls to either API. However, the total rate limiting has stayed shared across both URIs.

The underused mock interface in v1 is now removed in favor of the generated gomock interfaces to reduce the LOC in gateway package. The interface was barely used by the tests and would have resulted in unnecessary LOC to implement v2.

I have held back on unrelated refactoring of gateway package. The code can use further restructuring, but for now the focus is to expose existing /v2 APIs over the gateway.

The implementation of Version in /v2 APIs is also left as a TODO since it requires implementation at the top level API and bubbles up into Common APIs.

Fixes #13036

Integrate the existing v2 APIs into Lotus Gateway such that they are
accessible via `/rpc/v2` endpoint similar to full node APIs except
through the gateway reverse proxy along with rate limiting and handling
of stateful connections over web socket.

The prior gateway implementation did not have a concept of per-uri
reverse proxy handling. The changes here separate reverse proxy
implementation in gateway from the gateway node to introduce separate
handling of v1 and v2 APIs. The work introduces a top-level
`v2api.Gateway` interface to capture the APIs exposed by the v2 gateway
and generate any relevant documentation based on the interface.

Specifically, the work here separates the handling of stateful
connections between v1 and v2 to avoid any cross-contamination between
Eth calls to either API. However, the total rate limiting has stayed
shared across both URIs.

The underused mock interface in v1 is now removed in favor of the
generated gomock interfaces to reduce the LOC in `gateway` package. The
interface was barely used by the tests and would have resulted in
unnecessary LOC to implement v2.

I have held back on unrelated refactoring of `gateway` package. The code
can use further restructuring, but for now the focus is to expose
existing /v2 APIs over the gateway.

The implementation of `Version` in /v2 APIs is also left as a TODO since
it requires implementation at the top level API and bubbles up into
`Common` APIs.
@github-project-automation github-project-automation Bot moved this to 📌 Triage in FilOz Apr 28, 2025
@masih masih changed the title Expose /v2 APIs through Lotus Gateway feat: expose /v2 APIs through Lotus Gateway Apr 28, 2025
@masih masih marked this pull request as ready for review April 28, 2025 16:45
@masih masih requested a review from Kubuxu April 28, 2025 16:45
Copy link
Copy Markdown
Contributor

@Kubuxu Kubuxu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SGTM although I haven't reviewed the proxy files in detail

@github-project-automation github-project-automation Bot moved this from 📌 Triage to ✔️ Approved by reviewer in FilOz Apr 28, 2025
@BigLep BigLep added this to F3 Apr 29, 2025
@masih
Copy link
Copy Markdown
Member Author

masih commented Apr 29, 2025

Thanks Kuba.

the proxy files

Those are mostly a fork of v1 behaviour with minor adjustments to use selectors (i.e. v2 APIs ) for eth block hash to tipset resolution as well as separate stateful connection handling.

@masih
Copy link
Copy Markdown
Member Author

masih commented Apr 29, 2025

Landing this and will iterate in the background on improving test/further refactoring. Happy to reflect on any comments retrospectively.

@masih masih merged commit d9a9318 into master Apr 29, 2025
98 checks passed
@masih masih deleted the masih/v2-gateway branch April 29, 2025 09:02
@github-project-automation github-project-automation Bot moved this from ✔️ Approved by reviewer to 🎉 Done in FilOz Apr 29, 2025
@github-project-automation github-project-automation Bot moved this to Done in F3 Apr 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done
Status: 🎉 Done

Development

Successfully merging this pull request may close these issues.

Expose initial F3-aware /v2/ APIs through lotus-gateway

3 participants