Substrate RPC server `CLI changes/updates`

Hey

A while ago, #4792 was merged, and substrate now comes with a new CLI option that is called --experimental-rpc-endpoint. This is a single CLI option that can be specified several times and gives more fine-grained options, such as specifying the listening address, which wasn’t possible prior to this change.

How to use it

So, it’s now possible to start up an arbitrary number of RPC endpoints when launching the node and let’s go through how to start three endpoints with different configurations:

$ polkadot --experimental-rpc-endpoint "listen-addr=127.0.0.1:9944,methods=unsafe" --experimental-rpc-endpoint "listen-addr=0.0.0.0:9945,methods=safe,rate-limit=100" --experimental-rpc-endpoint "listen-addr=[::1]:9944,optional=true"

The format for this option is --experimental-rpc-endpoint" listen-addr=<ip:port>,<key=value>,..." where each option is separated by a comma and listen-addr is the only required param.

Possible settings

The following options are available:

  • listen-addr: The socket address (ip:port) to listen on. Be careful to not expose the server to the public internet unless you know what you’re doing. (required)
  • disable-batch-requests: Disable batch requests (optional)
  • max-connections: The maximum number of concurrent connections that the server will accept (optional)
  • max-request-size: The maximum size of a request body in megabytes (optional)
  • max-response-size: The maximum size of a response body in megabytes (optional)
  • max-subscriptions-per-connection: The maximum number of subscriptions per connection (optional)
  • max-buffer-capacity-per-connection: The maximum buffer capacity per connection (optional)
  • max-batch-request-len: The maximum number of requests in a batch (optional)
  • cors: The CORS allowed origins, this can enabled more than once (optional)
  • methods: Which RPC methods to allow, valid values are “safe”, “unsafe” and “auto” (optional)
  • optional: If the listen address is optional i.e the interface is not required to be available For example this may be useful if some platforms doesn’t support ipv6 (optional)
  • rate-limit: The rate limit in calls per minute for each connection (optional)
  • rate-limit-trust-proxy-headers: Trust proxy headers for disable rate limiting (optional)
  • rate-limit-whitelisted-ips: Disable rate limiting for certain ip addresses (optional)
  • retry-random-port: If the port is already in use, retry with a random port (optional)

Cons

The params are not automatically generated by the CLI parsing (clap) instead these options are manually documented and manually parsed which isn’t as ergonomic both for usage (not as nice help menu) and maintenance (manual documentation needs to be updated with changes). That’s why it’s currently --experimental and needs to be battle-tested by different use cases, etc…

Stabilize/call for feedback on this feature

We are happy to get feedback on this feature, bug reports, or any changes you want to see until stabilization.

Please reply in rpc server: tracking/stabilize `--experimental-rpc-endpoint` CLI · Issue #5508 · paritytech/polkadot-sdk · GitHub or in this thread.

Roadmap

  1. Stabilize --rpc-endpoint
  2. Deprecate old CLI rpc params --rpc-port, --rpc-methods, and all other --rpc_x except --rpc-endpoint
3 Likes