Go to file
Groovie | Mango d10910e737
reducing yellowstone dependencies (#389)
* WIP - not compiling

* remove connect_hacked

* use reimported types

* cleanup

* fix fmt
2024-04-17 15:11:51 +02:00
.github/workflows Merge production main 2024 03 27 (#374) 2024-03-27 17:09:38 +01:00
accounts Fixing accounts on demand (#371) 2024-03-26 14:32:50 +01:00
accounts-on-demand reducing yellowstone dependencies (#389) 2024-04-17 15:11:51 +02:00
address-lookup-tables Implementing account on demand (#338) 2024-02-28 15:40:11 +01:00
bench Merge pull request #376 from blockworks-foundation/feature/benchrunner-tc1-tc2 2024-03-27 22:36:36 -05:00
benches Fix some typos (#260) 2024-01-02 20:52:46 +05:30
benchrunner-service add sql queries 2024-03-27 19:05:47 +01:00
blockstore use geyser blockmeta to progress finalizedslot (#367) 2024-03-22 19:22:38 +01:00
cd Fixing rpc account fly config 2024-03-26 15:37:20 +01:00
ci -D clippy (#252) 2023-12-08 03:26:41 +05:30
cluster-endpoints reducing yellowstone dependencies (#389) 2024-04-17 15:11:51 +02:00
core Bugfix,379 identity key pair loading must be optional (#381) 2024-04-02 15:52:06 +02:00
docs first impl for RPC get_vote_accounts 2024-01-03 10:20:18 +01:00
examples/custom-tpu-send-transactions Adding custom tpu send transaction example (#380) 2024-04-02 14:26:54 +02:00
lite-rpc reducing yellowstone dependencies (#389) 2024-04-17 15:11:51 +02:00
migrations wire up confirmation_rate + bench1 2024-03-27 18:54:14 +01:00
prioritization_fees Merge branch 'production' 2024-03-08 07:08:05 +01:00
quic-forward-proxy Bugfix,379 identity key pair loading must be optional (#381) 2024-04-02 15:52:06 +02:00
quic-forward-proxy-integration-test Adding custom tpu send transaction example (#380) 2024-04-02 14:26:54 +02:00
services experiment: reduce number of source endpoints to 1 (#386) 2024-04-03 21:06:29 +02:00
stake_vote reducing yellowstone dependencies (#389) 2024-04-17 15:11:51 +02:00
tests add stake and schedule bootstrap 2024-01-03 10:20:18 +01:00
util cleanup: histogram 2024-03-27 12:23:42 +01:00
.dockerignore Add docker build, fly config 2023-01-13 19:23:53 +00:00
.env.example validate LITE_RPC_HTTP_ADDR in config (#331) 2024-02-21 14:17:14 +01:00
.gitignore optimized create_n_users bench and ignore out.json 2023-03-27 17:20:59 +05:30
CHANGELOG.md Main into production 01/02/2024 (#312) 2024-02-01 15:08:47 +01:00
Cargo.lock reducing yellowstone dependencies (#389) 2024-04-17 15:11:51 +02:00
Cargo.toml reducing yellowstone dependencies (#389) 2024-04-17 15:11:51 +02:00
Dockerfile fix postgres ssl algo issue - RC2-40-CBC (#373) 2024-03-27 12:12:00 +01:00
Dockerfile-benchrunner benchrunner service (#363) 2024-03-26 13:41:46 +01:00
LICENSE switch to AGPL 2023-03-25 15:47:44 +04:00
README.md Use CLI instead of binaries for configuring benchmarks (#357) 2024-03-14 17:49:34 +01:00
config.example.json reducing yellowstone dependencies (#389) 2024-04-17 15:11:51 +02:00
jest.config.js typescript tests 2023-01-04 19:16:43 +05:30
openssl-legacy.cnf benchrunner service (#363) 2024-03-26 13:41:46 +01:00
package-lock.json add MAX_RECENT_BLOCKHASSHES and some logs (#49) 2023-02-10 17:01:23 +01:00
package.json random string 2023-03-26 15:59:15 +05:30
run_clippy_fmt.sh Merge production main 2024 03 27 (#374) 2024-03-27 17:09:38 +01:00
rust-toolchain.toml Updating rust version to 1.75.0 2024-03-08 11:33:39 +01:00
test.bash minor fixed in test.bash 2023-09-19 13:50:05 +02:00
tsconfig.json add MAX_RECENT_BLOCKHASSHES and some logs (#49) 2023-02-10 17:01:23 +01:00
yarn.lock first impl for RPC get_vote_accounts 2024-01-03 10:20:18 +01:00

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)
  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
$ RUST_LOG=info cargo run -- --help

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_ADDR2
GRPC_ADDR3
GRPC_ADDR4
gRPC address(es); will be multiplexed Replaces default if set http://127.0.0.0:10000 (from DEFAULT_GRPC_ADDR)
GRPC_X_TOKEN
GRPC_X_TOKEN2
GRPC_X_TOKEN3
GRPC_X_TOKEN4
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