Go to file
riordanp c63a212e57
Deploy QUIC Proxy (#210)
* Load listen addr from env

* Add deployment config for quic-forward-proxy

* ipv6 support

* Fix rpc_tester

* Read QUIC_PROXY_ADDR from env

* Add traces for debugging

* Add timeout for writing to SendStream

* disable GSO (Generic Segmentation Offload) for all outgoing QUIC-connects

should fix https://github.com/blockworks-foundation/lite-rpc/issues/199

* disable GSO (Generic Segmentation Offload) for all outgoing QUIC-connects (#200)

should fix https://github.com/blockworks-foundation/lite-rpc/issues/199

Co-authored-by: GroovieGermanikus <groovie@mango.markets>

* Add staging config, remove traces

* cargo fmt

* delete fly.toml - was split+renamed - see cd/

* remove misleading line

* comment on quic proxy

* revert some files

* Deploy dev from main, prod from production

---------

Co-authored-by: GroovieGermanikus <groovie@mango.markets>
Co-authored-by: Steve <95291500+grooviegermanikus@users.noreply.github.com>
2023-12-01 12:02:41 +00:00
.github/workflows Deploy QUIC Proxy (#210) 2023-12-01 12:02:41 +00:00
bench bench: wrap result from caller thread 2023-10-04 18:50:11 +02:00
benches
cd Deploy QUIC Proxy (#210) 2023-12-01 12:02:41 +00:00
cluster-endpoints Resubscribing grpc block subsciption on failure, get vote accounts every 10 minutes instead of 1s 2023-12-01 11:12:54 +01:00
core identity (#249) 2023-11-27 21:01:59 +05:30
docs
history simple config, env and cli (#247) 2023-11-27 14:24:59 +05:30
lite-rpc identity (#249) 2023-11-27 21:01:59 +05:30
migrations
quic-forward-proxy simple config, env and cli (#247) 2023-11-27 14:24:59 +05:30
quic-forward-proxy-integration-test fix throughput_50 2023-09-26 19:23:41 +02:00
services fixing issue with confusion of blockheight and slot 2023-10-25 20:58:50 +02:00
tests add epoch info test for process and finalized 2023-10-04 20:59:11 +02:00
.dockerignore
.env.example simple config, env and cli (#247) 2023-11-27 14:24:59 +05:30
.gitignore
CHANGELOG.md Updating changelog with version 0.2.3 2023-09-28 10:08:26 +02:00
Cargo.lock simple config, env and cli (#247) 2023-11-27 14:24:59 +05:30
Cargo.toml Update grpc version to 0.11.0 so that we can use the latest triton service 2023-11-14 10:42:58 +01:00
Dockerfile Fix launch args 2023-11-27 15:38:50 +00:00
LICENSE
README.md Deploy QUIC Proxy (#210) 2023-12-01 12:02:41 +00:00
config.example.json simple config, env and cli (#247) 2023-11-27 14:24:59 +05:30
jest.config.js
package-lock.json
package.json
rust-toolchain.toml
test.bash
tsconfig.json
yarn.lock

README.md

Lite RPC For Solana Blockchain

Submitting a transaction to be executed on the solana blockchain, requires the client to identify the next few leaders based on the leader schedule, look up their peering information in gossip and connect to them via the quic protocol. In order to simplify the process so it can be triggered from a web browser, most applications run full validators that forward the transactions according to the protocol on behalf of the web browser. Running full solana validators is incredibly resource intensive (>256GB RAM), the goal of this project would be to create a specialized micro-service that allows to deploy this logic quickly and allows horizontal scalability with commodity vms. Optionally the Lite RCP micro-services can be configured to send the transactions to a complementary QUIC forward proxy instead of the solana tpu (details).

Confirmation strategies

  1. Subscribe to new blocks using websockets (deprecated) (depricated)
  2. Polling blocks over RPC.(Current)
  3. Subscribe blocks over gRPC. (Current)
  4. Listening to gossip protocol. (Future roadmap)

Executing

run using

$ cargo run --release

to know about command line options

$ cargo run --release -- --help

Test and Bench

Make sure both solana-validator and lite-rpc is running

test

$ cargo test

bench

$ cd bench and cargo run --release

Find a new file named metrics.csv in the project root.

Deployment

Environment Variables

Thank you for providing the default values. Here's the updated table with the default values for the environment variables based on the additional information:

Environment Variable Purpose Required? Default Value
RPC_ADDR Address for the RPC node Replaces default if set http://0.0.0.0:8899 (from DEFAULT_RPC_ADDR)
WS_ADDR WebSocket address for the RPC node Replaces default if set ws://0.0.0.0:8900 (from DEFAULT_WS_ADDR)
LITE_RPC_HTTP_ADDR HTTP address for the lite RPC node Replaces default if set http://0.0.0.0:8890 (from DEFAULT_LITE_RPC_ADDR)
LITE_RPC_WS_ADDR WebSocket address for the lite RPC node Replaces default if set [::]:8891 (from Config::default_lite_rpc_ws_addr)
FANOUT_SIZE Configuration for the fanout size Replaces default if set 18 (from DEFAULT_FANOUT_SIZE)
IDENTITY Identity keypair Optional, replaces default if set None
PROMETHEUS_ADDR Address for Prometheus monitoring Replaces default if set None specified in provided defaults
MAX_RETRIES Maximum number of retries per transaction Replaces default if set 40 (from MAX_RETRIES)
RETRY_TIMEOUT Timeout for transaction retries in seconds Replaces default if set 3 (from DEFAULT_RETRY_TIMEOUT)
QUIC_PROXY_ADDR Address for QUIC proxy Optional None
USE_GRPC Flag to enable or disable gRPC Enables gRPC if set false
GRPC_ADDR gRPC address Replaces default if set http://127.0.0.0:10000 (from DEFAULT_GRPC_ADDR)
GRPC_X_TOKEN Token for gRPC authentication Optional None
PG_* Various environment variables for Postgres configuration Depends on Postgres usage Based on PostgresSessionConfig::new_from_env()

Postgres

lite-rpc implements an optional postgres service that can write to postgres database tables as defined in ./migrations. This can be enabled by either setting the environment variable PG_ENABLED to true or by passing the -p option when launching the executable. If postgres is enabled then the optional environment variables shown above must be set.

Metrics

Various Prometheus metrics are exposed on localhost:9091/metrics which can be used to monitor the health of the application in production.

Deployment on fly.io

While lite-rpc can be deployed on any cloud infrastructure, it has been tested extensively on https://fly.io. An example configuration has been provided in fly.toml. We recommend a dedicated-cpu-2x VM with at least 4GB RAM.

The app listens by default on ports 8890 and 8891 for HTTP and Websockets respectively. Since only a subset of RPC methods are implemented, we recommend serving unimplemented methods from a full RPC node using a reverse proxy such as HAProxy or Kong. Alternatively, you can connect directly to lite-rpc using a web3.js Connection object that is only used for sending and confirming transactions.

Troubleshooting: if you encounter issues with QUIC sendmsg check this - you might need to explicitly disable GSO (Generic Segmenatin Offload) see DISABLE_GSO=true

Example

fly apps create my-lite-rpc
fly secrets set -a my-lite-rpc RPC_URL=... WS_URL=...   # See above table for env options
fly scale vm dedicated-cpu-2x --memory 4096 -a my-lite-rpc
fly deploy -c cd/lite-rpc.toml -a my-lite-rpc --remote-only # To just launch lite-rpc
fly deploy -c cd/lite-rpc.toml -a my-lite-rpc --remote-only # To launch lite-rpc with proxy mode

Copyright (c) 2022 Blockworks Foundation

Licensed under the AGPL-3.0 license