mirror of
https://github.com/filecoin-project/lotus.git
synced 2025-05-17 15:20:37 +08:00

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.