Skip to main content
Version: 1.39.1

Lodestar Prover

Discord ETH Beacon APIs Spec v3.1.0 ES Version Node Version

This package is part of ChainSafe's Lodestar project

A set of tools allowing to verify EL client JSON-RPC calls.

Usageโ€‹

You can use the @lodestar/prover in two ways, as a Web3 Provider and as proxy. For prover use case see below example.

import {Web3} from "web3";
import {createVerifiedExecutionProvider, LCTransport} from "@lodestar/prover";

const httpProvider = new Web3.providers.HttpProvider("https://lodestar-sepoliarpc.chainsafe.io");

const {provider, proofProvider} = createVerifiedExecutionProvider(httpProvider, {
transport: LCTransport.Rest,
urls: ["https://lodestar-sepolia.chainsafe.io"],
network: "sepolia",
wsCheckpoint: "trusted-checkpoint",
});

const web3 = new Web3(provider);

const address = "0xf97e180c050e5Ab072211Ad2C213Eb5AEE4DF134";
const balance = await web3.eth.getBalance(address, "latest");
console.log({balance, address});

In this scenario the actual provider is mutated to handle the RPC requests and verify those. So here if you use provider or httpProvider both are the same objects. This behavior is useful when you already have an application and usage of any provider across the code space and don't want to change the code. So you mutate the provider during startup.

For some scenarios when you don't want to mutate the provider you can pass an option mutateProvider as false. In this scenario the object httpProvider is not mutated and you get a new object provider. This is useful when your provider object does not allow mutation, e.g. Metamask provider accessible through window.ethereum. If not provided mutateProvider is considered as true by default. In coming releases we will switch its default behavior to false.

import {Web3} from "web3";
import {createVerifiedExecutionProvider, LCTransport} from "@lodestar/prover";

const httpProvider = new Web3.providers.HttpProvider("https://lodestar-sepoliarpc.chainsafe.io");

const {provider, proofProvider} = createVerifiedExecutionProvider(httpProvider, {
transport: LCTransport.Rest,
urls: ["https://lodestar-sepolia.chainsafe.io"],
network: "sepolia",
wsCheckpoint: "trusted-checkpoint",
mutateProvider: false,
});

const web3 = new Web3(httpProvider);

const address = "0xf97e180c050e5Ab072211Ad2C213Eb5AEE4DF134";
const balance = await web3.eth.getBalance(address, "latest");
console.log({balance, address});

You can also invoke the package as binary.

npm i -g @lodestar/prover

lodestar-prover proxy \
--network sepolia \
--executionRpcUrl https://lodestar-sepoliarpc.chainsafe.io \
--beaconUrls https://lodestar-sepolia.chainsafe.io \
--port 8080

How to detect a web3 providerโ€‹

There can be different implementations of the web3 providers and each can handle the RPC request differently. We call those different provider types. We had provided builtin support for common providers e.g. web3.js, ethers or any eip1193 compatible providers. We inspect given provider instance at runtime to detect the correct provider type.

If your project is using some provider type which is not among above list, you have the option to register a custom provider type with the createVerifiedExecutionProvider with the option providerTypes which will be an array of your supported provider types. Your custom provider types will have higher priority than default provider types. Please see existing provide types implementations to know how to implement your own if needed.

Supported Web3 Methodsโ€‹

โœ… - Completed

โŒ› - Todo

โžก๏ธ - Request will be forward to EL without any intermediary manipulations. You can limit these by providing unverifiedWhitelist option for provider or --unverifiedWhitelist from the cli. If not set then all methods will be forwarded.

โ‡๏ธ - Always forwarded to EL.

GroupMethodStatusVersion
Blocketh_getBlockByHashโœ…v0
eth_getBlockByNumberโœ…v0
eth_getBlockTransactionCountByHashโŒ›v2
eth_getBlockTransactionCountByNumberโŒ›v2
eth_getUncleCountByBlockHashโŒ›v2
eth_getUncleCountByBlockNumberโŒ›v2
Chain/Networketh_chainIdโžก๏ธ
eth_syncingโŒ›v1
eth_coinbaseโŒ›v2
eth_accountsโžก๏ธ
eth_blockNumberโžก๏ธ
Call and Estimateeth_callโœ…v0
eth_estimateGasโœ…v0
eth_createAccessListโŒ›v2
eth_gasPriceโŒ›v1
eth_maxPriorityFeePerGasโŒ›v1
eth_feeHistoryโŒ›v2
Filterseth_newFilterโŒ›v2
eth_newBlockFilterโŒ›v2
eth_newPendingTransactionFilterโŒ›v2
eth_uninstallFilterโŒ›v2
eth_getFilterChangesโŒ›v2
eth_getFilterLogsโŒ›v2
eth_getLogsโŒ›v1
Miningeth_miningโžก๏ธ
eth_hashrateโžก๏ธ
eth_getWorkโžก๏ธ
eth_submitWorkโžก๏ธ
eth_submitHashrateโžก๏ธ
Signingeth_signโžก๏ธ
eth_signTransactionโžก๏ธ
Stateeth_getBalanceโœ…v0
eth_getStorageAtโŒ›v1
eth_getTransactionCountโŒ›v2
eth_getCodeโœ…v0
eth_getProofโ‡๏ธv0
Transactionseth_sendTransactionโžก๏ธ
eth_sendRawTransactionโžก๏ธ
eth_getTransactionByHashโŒ›v2
eth_getTransactionByBlockHashAndIndexโŒ›v2
eth_getTransactionByBlockNumberAndIndexโŒ›v2
eth_getTransactionReceiptโŒ›v2
Eventseth_subscribeโ‡๏ธv0
eth_unsubscribeโ‡๏ธv0

Non-supported featuresโ€‹

  • Currently does not support batch requests.

Warningsโ€‹

  • To use this prover the ethereum provider must support the eth_getProof method. Unfortunately, Infura does not currently support this endpoint. As an alternative, we suggest using Alchemy.

Prerequisitesโ€‹

What you needโ€‹

You will need to go over the specification. You will also need to have a basic understanding of lightclient.

Getting startedโ€‹

Contributorsโ€‹

Read our contributors document, submit an issue or talk to us on our discord!

Licenseโ€‹

Apache-2.0 ChainSafe Systems