How Lava Works — the protocol for multi-chain, reliable RPC

KagemniKarimu
Lava Network
Published in
7 min readMar 31, 2023

Introduction

Lava Network is a decentralized platform that aims to create an open, multi-chain standard for blockchain Remote Procedure Calls (RPC). It provides a protocol that allows for reliable access to RPC data across all chains, by incentivizing RPC providers to join the network. This eliminates the need for users of RPC to maintain their own nodes or depend on trusted third parties. The platform ensures high uptime, data integrity, scalability, privacy, and censorship-resistance. As a Cosmos project, Lava operates on an appchain built using the Cosmos Software Development Kit (SDK), Ignite, and Tendermint Byzantine Fault Tolerance (BFT) consensus.

Lava exists as a protocol, a network, and a standard to solve the Web3 RPC problem. Today, there is no decentralized, usable and reliable standard for accessing blockchains. Developers rely on centralized providers for the most popular chains, but developers in smaller or newer ecosystems are forced to use less practical methods for accessing blockchain data.

For a general overview of ‘What Lava is?’ check out our explanation in this article here.

Let’s get into some specifics of how Lava works! We’ll examine each of these features in depth in the sections that follows:

  • RPC Consumer-Provider Pairing, per Epoch
  • Open Source RPC and Rich API Specifications
  • Quality of Service Assurances across latency, freshness and availability
  • Data Reliability Checks
  • Scalability Features and Enhancements

Dynamic Pairing by Epoch

Lava works by establishing and distributing a Pairing List to all RPC Consumers. Consumers request a list of eligible Providers for their requested chain and geography by making an RPC call or sending a transaction. They submit an API call Pairing() to the Lava Blockchain to receive the most recent Pairing List. This list contains Providers that will service their API requests for that period or epoch, based upon at least four factors*:* 1) provider stake, 2) epoch blockhash, 3) geolocation, and 4) consumer address. In the future, more complicated considerations, such as consistent quality of service excellence per cluster of providers in a geolocation will be implemented.

Epochs are multiple blocks in length. A new pairing list is calculable each epoch. Epochs are used instead of blocks to lessen overhead, optimize efficiency, and reduce the Lava blockchain’s storage size. For scalability and maximal efficiency, the number of blocks within a given epoch can be changed via on-chain governance. Therefore the Lava community can mediate how often new Pairing Lists will be issued.

Providers become eligible for inclusion on a Pairing List by staking LAVA tokens. Once a provider completes setup, they can begin servicing requests. Their verified requests will be included in the Pairing List from the next Epoch. Although tokens are used for payment, Compute units (CUs) are assigned to each service API to measure a provider’s workload, which determines their rewards.

On Lava, increasing the number of Consumer pairings a Provider receives does not require new nodes or addresses. Consumers can access RPC through our Gateway, SDK, or Server Kit, streamlining their workflow and abstracting away the Pairing List.

Lava Pairing Diagram
How Consumers fetch a pairing list and interact with Providers to get RPC

Open-Source RPC and Rich API Specifications

Lava works by empowering its users to add additional configuration sets through the use of custom specifications. A specification (affectionately referred to as a ‘spec’) establishes the APIs provided by Providers for Consumers through JSON. Lava already has numerous specs, which are modified and added in modular fashion through governance proposals.

When adding a new blockchain, the JSON (spec file) must specify that chain’s available RPC APIs, its minimum stake, and a few other base configurations. Using this very same method, a consumer can even add specs for Rich APIs to Lava by simply specifying the accepted calls to the node(s) in their spec! After that, the spec is submitted to the chain with a simple command: lavad tx gov submit-proposal spec-add [path-to-JSON]. Those staked on the network are given a chance to vote on the proposal. Once the vote is passed - a spec becomes the standard by which users of the network agree to use the APIs of a chain.

An excerpt of an example ‘spec’

Incentives for high Quality of Service — Latency, Freshness, Availability

Lava keeps Providers accountable using rewards and disincentives: Providers are subject to scoring, burning, slashing, and jailing. However, the true goal of Quality of Service (QoS) in blockchain technology is to incentivize providers to deliver good service by offering rewards in the form of more clients and higher payments.

On Lava, QoS is measured using three metrics: availability, latency, and freshness, with a cumulative score ranging between 0 and 1. We define each of these terms for clarity; availability is measured by the number of messages a provider is able to answer, latency tracks the time it takes for provider to respond to a client, and freshness measures how up-to-date the provider is with the blockchain.

All three of these give a comprehensive picture of how a given RPC provider is performing in relation to the demands of the network. As such, Consumers assign scores per relay and those scores are used to deterministically rank providers per epoch— assuring that the most performant and reliable providers are consistently servicing relays.

QoS score = latency * sync * availability scores

Data Reliability Checks

Data reliability is also an explicit goal of the protocol. Primarily, its ensured through two means: provider-funded data reliability and client-funded data reliability. Although data and requests are handled off-chain, Lava uses cryptographic signatures, which means providers can be held liable for their inaccurate responses (should they exist)!

Provider-funded data reliability is achieved by sending two messages endorsed by a Verifiable Random Function (VRF). The client sends a duplicate message to a different provider, compares the finalized results and reports any discrepancies on-chain for fraud handling/slashing.

Client funded data reliability involves the client choosing how many messages to verify from finalized blocks and sending them to two or more providers. If a discrepancy is found, it’s reported on chain as fraudulent for conflict resolution. These client-funded data reliability checks can also be done in secret.

Lava resolves conflicts in data through an Honest Majority protocol. A stakeweighted vote of a majority of validators determines the data in the case of a discrepancy, as imaged below. It bears relaying here that — in the future — light clients can be used to communicate with other RPC nodes and verify state with lower trust assumptions around data integrity!

The Honest Majority Conflict Resolution Procedure

Scalability Features

Lava has several features aimed at improving scalability, including blockchain optimization techniques and specific features on the open-source lavad binary that enhance provider and validator performance. Some of these enhancements include:

  • Separate incentivization for Provider and Validator roles to increase Validator participation in the network.
  • Providers receive more work by increasing stake on the same node, rather than adding more nodes to the network. This reduces the votes needed for consensus during conflict detection.
  • Provider client automatically performs load balancing to handle variances in traffic.
  • Transactions are conducted off-chain and then uploaded on-chain aggregated. This grouping of multiple relay payments in one transaction increases throughput and reduces gas fees.
  • Compute units (CUs) are aggregated, streamlining the proof of reward process and forgoing the need for expensive, multi-step validation mechanisms.
  • Payment requests are spread over time to lower gas fees and increase their success rate, instead of concentrating them at the beginning of each epoch.

Conclusion

Lava aims to power the RPC layer for all blockchains, implementing various mechanisms to increase throughput, protect and incentivize participants, and make the addition of new blockchain APIs simple and accessible. With Lava, providers are incentivized to offer services across all blockchains, geographies, applications, and API specifications, providing reliable and scalable RPC to both providers and consumers. With the support of over 20 networks and a growing number of users, Lava is set to become a leading provider of RPC and API services in the Web3 space. If you’re interested in learning more about Lava, check out our website and documentation for more information!

FAQs

What is Lava?

Lava is a decentralized network of top RPC and API providers that developers can subscribe to for access to any blockchain. Providers are rewarded for their quality of service, meaning apps and users get maximum speed, data integrity and uptime. Session pairings are regularly changed according to quality of service, so anyone can query or send transactions without being profiled. Lava helps developers build multi-chain web3-native apps, while giving users the best possible experience.

Why is Lava different to other providers?

Lava aggregates providers into one side of the network, allowing developers to get reliable RPC with minimal downtime. Providers are partners on Lava, not competitors.

Lava is also completely open source with on-chain governance over new specifications. Specifications can be made for any chain RPC or API, meaning Lava offers a single place for blockchain access and can integrate chain support faster than any centralized provider. We already support over 15 networks and will support many hundreds more!

How does Lava ensure high performance in the decentralized network?

The network is designed to reward providers across latency, data freshness and availability.

RPC providers are slashed, burned, jailed, scored, and rewarded according to their performance in serving RPC consumers. Data and requests are off-chain and completely peer-to-peer, and enhancements are made constantly to ensure that RPC Provider and Consumer services are completely optimized.

How can I use Lava as a developer?

Try out our Gateway! You can sign up directly here or check out our helpful Getting Started guide in our Docs if you get stuck.

How can I learn more?

Visit our docs, read our litepaper at litepaper.lavanet.xyz, or join our discord https://discord.gg/lavanetxyz ! We’d love your feedback and participation!

--

--