feat: expose /v2 APIs through Lotus Gateway#13075
Merged
Conversation
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.
/v2 APIs through Lotus Gateway/v2 APIs through Lotus Gateway
Kubuxu
approved these changes
Apr 28, 2025
Contributor
Kubuxu
left a comment
There was a problem hiding this comment.
SGTM although I haven't reviewed the proxy files in detail
Member
Author
|
Thanks Kuba.
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. |
Member
Author
|
Landing this and will iterate in the background on improving test/further refactoring. Happy to reflect on any comments retrospectively. |
8 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Integrate the existing v2 APIs into Lotus Gateway such that they are accessible via
/rpc/v2endpoint 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.Gatewayinterface 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
gatewaypackage. 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
gatewaypackage. The code can use further restructuring, but for now the focus is to expose existing /v2 APIs over the gateway.The implementation of
Versionin /v2 APIs is also left as a TODO since it requires implementation at the top level API and bubbles up intoCommonAPIs.Fixes #13036