proxy_server: forward unsupported requests to main node
Context
The proxy server supports a subset of the RPCs that a full node can serve, and at present making a request to a proxy server for an unsupported RPC fails with a 404 because the endpoint does not exist.
This MR adds the ability to transparently forward any unsupported RPCs to a configurable endpoint, intended to be a full node that can handle them correctly. This is done via a 301 Moved Permanently response that redirects the HTTP client to the full node, which we accomplish using a Resto middleware (introduced recently in nomadic-labs/resto!35 (merged)) that rewrites the 404s into 301s.
Closes #2436 (closed).
Manually testing the MR
Start a proxy server in the usual way. Run curl -L http://127.0.0.1:18732/chains/main/blocks/head/header - to query the proxy server on a URL it does not handle - witness that it works. You can add -v to the call to see a redirect to the full node being honored. If you were to execute this on master, it would fail.
Run ./tezos-client -E http://127.0.0.1:18732 rpc get /chains/main/blocks/head/header, witness it fails as follows:
Error:
Rpc request failed:
- meth: GET
- uri: http://127.0.0.1:18732/chains/main/blocks/head/header
- error: The client does not support following HTTP redirects yet.
Note the last line that shows the client is aware of redirects now, but does not handle them yet (this is future work). On master the client would have failed with a generic error.
Checklist
-
Document the interface of any function added or modified (see the coding guidelines) -
Document any change to the user interface, including configuration parameters (see node configuration) -
Provide automatic testing (see the testing guide). -
For new features and bug fixes, add an item in the appropriate changelog ( docs/protocols/alpha.rstfor the protocol and the environment,CHANGES.rstat the root of the repository for everything else). -
Select suitable reviewers using the Reviewersfield below. -
Select as Assigneethe next person who should take action on that MR