Git Product home page Git Product logo

lite-rpc's Introduction

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 blockSubscribe
  2. Subscribing to signatures with pool of rpc servers. (Under development)
  3. Listening to gossip protocol. (Future roadmap)

Executing

make sure solana-validator is running in the background with --rpc-pubsub-enable-block-subscription

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

env purpose required?
RPC_URL HTTP URL for a full RPC node yes, for docker
WS_URL WS URL for a full RPC node yes, for docker
IDENTITY Staked validator identity keypair no
PG_ENABLED Set to anything but 'false' to enable Postgres no
PG_CONFIG Postgres Connection Config if postgres enabled
CA_PEM_B64 Base64 encoded ca.pem if postgres enabled
CLIENT_PKS_B64 Base64 encoded client.pks if postgres enabled
CLIENT_PKS_PASS Password to client.pks if postgres enabled
DISABLE_GSO Disable GSO completely no

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. Grafana dashboard coming soon!

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 -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

License & Copyright

Copyright (c) 2022 Blockworks Foundation

Licensed under the AGPL-3.0 license

lite-rpc's People

Contributors

godmodegalactus avatar aniketfuryrocks avatar grooviegermanikus avatar musitdev avatar mschneider avatar lioncat2002 avatar riordanp avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.