Rename lc_proxy to nimbus_verified_proxy (#1321)

* Change Light client proxy naming to verified proxy naming in code

* Rename the lc_proxy files to the verified proxy naming

* Update to the verified proxy name in the docs
This commit is contained in:
Kim De Mey 2022-11-23 17:11:38 +01:00 committed by GitHub
parent 7381ee8ff9
commit 99769cc0e1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 112 additions and 104 deletions

View File

@ -1,8 +1,10 @@
name: CI name: Nimbus CI
on: on:
push: push:
paths-ignore: ['doc/**', 'docs/**', '**/*.md', 'hive_integration/**', paths-ignore: ['doc/**', 'docs/**', '**/*.md', 'hive_integration/**',
'fluffy/**', '.github/workflows/fluffy.yml'] 'fluffy/**', '.github/workflows/fluffy.yml',
'nimbus_verified_proxy/**', '.github/workflows/nimbus_verified_proxy.yml',
]
# Disable `pull_request`. Experimenting with using only `push` for PRs. # Disable `pull_request`. Experimenting with using only `push` for PRs.
#pull_request: #pull_request:
# paths-ignore: ['doc/**', 'docs/**', '**/*.md', 'hive_integration/**'] # paths-ignore: ['doc/**', 'docs/**', '**/*.md', 'hive_integration/**']

View File

@ -1,19 +1,21 @@
name: Light client proxy CI name: Nimbus verified proxy CI
on: on:
push: push:
paths: paths:
- '.github/workflows/lc_proxy.yml' - '.github/workflows/nimbus_verified_proxy.yml'
- 'lc_proxy/**' - 'nimbus_verified_proxy/**'
- '!lc_proxy/**.md' - '!nimbus_verified_proxy/**.md'
- '!nimbus_verified_proxy/docs/**'
- 'vendor/**' - 'vendor/**'
- 'Makefile' - 'Makefile'
- 'nimbus.nimble' - 'nimbus.nimble'
pull_request: pull_request:
paths: paths:
- '.github/workflows/lc_proxy.yml' - '.github/workflows/nimbus_verified_proxy.yml'
- 'lc_proxy/**' - 'nimbus_verified_proxy/**'
- '!lc_proxy/**.md' - '!nimbus_verified_proxy/**.md'
- '!nimbus_verified_proxy/docs/**'
- 'vendor/**' - 'vendor/**'
- 'Makefile' - 'Makefile'
- 'nimbus.nimble' - 'nimbus.nimble'
@ -141,7 +143,7 @@ jobs:
uses: actions/cache@v2 uses: actions/cache@v2
with: with:
path: external/dlls-${{ matrix.target.cpu }} path: external/dlls-${{ matrix.target.cpu }}
key: 'dlls-${{ matrix.target.cpu }}-lc-proxy' key: 'dlls-${{ matrix.target.cpu }}-verified-proxy'
- name: Install DLLs dependencies (Windows) - name: Install DLLs dependencies (Windows)
if: > if: >
@ -173,36 +175,36 @@ jobs:
uses: actions/cache@v2 uses: actions/cache@v2
with: with:
path: NimBinaries path: NimBinaries
key: 'nim-${{ matrix.target.os }}-${{ matrix.target.cpu }}-${{ steps.versions.outputs.nimbus_build_system }}-lc-proxy' key: 'nim-${{ matrix.target.os }}-${{ matrix.target.cpu }}-${{ steps.versions.outputs.nimbus_build_system }}-verified-proxy'
- name: Build Nim and Nimbus-eth1 dependencies - name: Build Nim and Nimbus-eth1 dependencies
run: | run: |
make -j${ncpu} ARCH_OVERRIDE=${PLATFORM} CI_CACHE=NimBinaries update make -j${ncpu} ARCH_OVERRIDE=${PLATFORM} CI_CACHE=NimBinaries update
- name: Run lc proxy tests (Windows) - name: Run verified proxy tests (Windows)
if: runner.os == 'Windows' if: runner.os == 'Windows'
run: | run: |
gcc --version gcc --version
DEFAULT_MAKE_FLAGS="-j${ncpu}" DEFAULT_MAKE_FLAGS="-j${ncpu}"
mingw32-make ${DEFAULT_MAKE_FLAGS} lc-proxy mingw32-make ${DEFAULT_MAKE_FLAGS} nimbus_verified_proxy
build/lc_proxy.exe --help build/nimbus_verified_proxy.exe --help
mingw32-make ${DEFAULT_MAKE_FLAGS} lc-proxy-test mingw32-make ${DEFAULT_MAKE_FLAGS} nimbus-verified-proxy-test
- name: Run lc proxy tests (Linux) - name: Run verified proxy tests (Linux)
if: runner.os == 'Linux' if: runner.os == 'Linux'
run: | run: |
export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:/usr/local/lib" export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:/usr/local/lib"
DEFAULT_MAKE_FLAGS="-j${ncpu}" DEFAULT_MAKE_FLAGS="-j${ncpu}"
env CC=gcc make ${DEFAULT_MAKE_FLAGS} lc-proxy env CC=gcc make ${DEFAULT_MAKE_FLAGS} nimbus_verified_proxy
build/lc_proxy --help build/nimbus_verified_proxy --help
# CC is needed to select correct compiler 32/64 bit # CC is needed to select correct compiler 32/64 bit
env CC=gcc CXX=g++ make ${DEFAULT_MAKE_FLAGS} lc-proxy-test env CC=gcc CXX=g++ make ${DEFAULT_MAKE_FLAGS} nimbus-verified-proxy-test
- name: Run lc proxy tests (Macos) - name: Run verified proxy tests (Macos)
if: runner.os == 'Macos' if: runner.os == 'Macos'
run: | run: |
DEFAULT_MAKE_FLAGS="-j${ncpu}" DEFAULT_MAKE_FLAGS="-j${ncpu}"
make ${DEFAULT_MAKE_FLAGS} lc-proxy make ${DEFAULT_MAKE_FLAGS} nimbus_verified_proxy
build/lc_proxy --help build/nimbus_verified_proxy --help
# "-static" option will not work for osx unless static system libraries are provided # "-static" option will not work for osx unless static system libraries are provided
make ${DEFAULT_MAKE_FLAGS} lc-proxy-test make ${DEFAULT_MAKE_FLAGS} nimbus-verified-proxy-test

View File

@ -69,7 +69,7 @@ TOOLS_CSV := $(subst $(SPACE),$(COMMA),$(TOOLS))
update \ update \
nimbus \ nimbus \
fluffy \ fluffy \
lc_proxy \ nimbus_verified_proxy \
test \ test \
test-reproducibility \ test-reproducibility \
clean \ clean \
@ -230,16 +230,16 @@ utp-test: | build deps
fluffy-test-portal-testnet: | build deps fluffy-test-portal-testnet: | build deps
$(ENV_SCRIPT) nim fluffy_test_portal_testnet $(NIM_PARAMS) nimbus.nims $(ENV_SCRIPT) nim fluffy_test_portal_testnet $(NIM_PARAMS) nimbus.nims
# Light Client Proxy related targets # Nimbus Verified Proxy related targets
# Builds the lc proxy client # Builds the nimbus_verified_proxy
lc-proxy: | build deps nimbus_verified_proxy: | build deps
echo -e $(BUILD_MSG) "build/$@" && \ echo -e $(BUILD_MSG) "build/$@" && \
$(ENV_SCRIPT) nim lc_proxy $(NIM_PARAMS) nimbus.nims $(ENV_SCRIPT) nim nimbus_verified_proxy $(NIM_PARAMS) nimbus.nims
# builds and runs the lc proxy test suite # builds and runs the nimbus_verified_proxy test suite
lc-proxy-test: | build deps nimbus-verified-proxy-test: | build deps
$(ENV_SCRIPT) nim lc_proxy_test $(NIM_PARAMS) nimbus.nims $(ENV_SCRIPT) nim nimbus_verified_proxy_test $(NIM_PARAMS) nimbus.nims
# builds transition tool # builds transition tool
t8n: | build deps t8n: | build deps
@ -259,7 +259,7 @@ evmstate_test: | build deps evmstate
# usual cleaning # usual cleaning
clean: | clean-common clean: | clean-common
rm -rf build/{nimbus,fluffy,lc_proxy,$(TOOLS_CSV),all_tests,test_kvstore_rocksdb,test_rpc,all_fluffy_tests,all_fluffy_portal_spec_tests,test_portal_testnet,portalcli,blockwalk,eth_data_exporter,utp_test_app,utp_test,*.dSYM} rm -rf build/{nimbus,fluffy,nimbus_verified_proxy,$(TOOLS_CSV),all_tests,test_kvstore_rocksdb,test_rpc,all_fluffy_tests,all_fluffy_portal_spec_tests,test_portal_testnet,portalcli,blockwalk,eth_data_exporter,utp_test_app,utp_test,*.dSYM}
rm -rf tools/t8n/{t8n,t8n_test} rm -rf tools/t8n/{t8n,t8n_test}
rm -rf tools/evmstate/{evmstate,evmstate_test} rm -rf tools/evmstate/{evmstate,evmstate_test}
ifneq ($(USE_LIBBACKTRACE), 0) ifneq ($(USE_LIBBACKTRACE), 0)

View File

@ -97,10 +97,10 @@ task utp_test, "Run uTP integration tests":
task fluffy_test_portal_testnet, "Build test_portal_testnet": task fluffy_test_portal_testnet, "Build test_portal_testnet":
buildBinary "test_portal_testnet", "fluffy/scripts/", "-d:chronicles_log_level=DEBUG -d:chronosStrictException -d:unittest2DisableParamFiltering -d:PREFER_BLST_SHA256=false" buildBinary "test_portal_testnet", "fluffy/scripts/", "-d:chronicles_log_level=DEBUG -d:chronosStrictException -d:unittest2DisableParamFiltering -d:PREFER_BLST_SHA256=false"
## Light Client Proxy tasks ## Nimbus Verified Proxy tasks
task lc_proxy, "Build light client proxy": task nimbus_verified_proxy, "Build Nimbus verified proxy":
buildBinary "lc_proxy", "lc_proxy/", "-d:chronicles_log_level=TRACE -d:chronosStrictException -d:PREFER_BLST_SHA256=false -d:libp2p_pki_schemes=secp256k1" buildBinary "nimbus_verified_proxy", "nimbus_verified_proxy/", "-d:chronicles_log_level=TRACE -d:chronosStrictException -d:PREFER_BLST_SHA256=false -d:libp2p_pki_schemes=secp256k1"
task lc_proxy_test, "Run light proxy tests": task nimbus_verified_proxy_test, "Run Nimbus verified proxy tests":
test "lc_proxy/tests", "test_proof_validation", "-d:chronicles_log_level=ERROR -d:chronosStrictException -d:nimbus_db_backend=sqlite -d:PREFER_BLST_SHA256=false" test "nimbus_verified_proxy/tests", "test_proof_validation", "-d:chronicles_log_level=ERROR -d:chronosStrictException -d:nimbus_db_backend=sqlite -d:PREFER_BLST_SHA256=false"

View File

@ -1,6 +1,6 @@
# Nimbus Light Client Proxy # Nimbus Verified Proxy
[![Nimbus Light Client Proxy CI](https://github.com/status-im/nimbus-eth1/actions/workflows/lc_proxy.yml/badge.svg)](https://github.com/status-im/nimbus-eth1/actions/workflows/lc_proxy.yml) [![Nimbus Verified Proxy CI](https://github.com/status-im/nimbus-eth1/actions/workflows/nimbus_verified_proxy.yml/badge.svg)](https://github.com/status-im/nimbus-eth1/actions/workflows/nimbus_verified_proxy.yml)
![Stability: experimental](https://img.shields.io/badge/stability-experimental-orange.svg) ![Stability: experimental](https://img.shields.io/badge/stability-experimental-orange.svg)
[![License: Apache](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) [![License: Apache](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://opensource.org/licenses/MIT) [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://opensource.org/licenses/MIT)
@ -8,7 +8,7 @@
[![Discord: Nimbus](https://img.shields.io/badge/Discord-Nimbus-blue.svg)](https://discord.gg/XRxWahP) [![Discord: Nimbus](https://img.shields.io/badge/Discord-Nimbus-blue.svg)](https://discord.gg/XRxWahP)
[![Status: #nimbus-general](https://img.shields.io/badge/Status-nimbus--general-blue.svg)](https://join.status.im/nimbus-general) [![Status: #nimbus-general](https://img.shields.io/badge/Status-nimbus--general-blue.svg)](https://join.status.im/nimbus-general)
The Nimbus Light Client Proxy is a very efficient light client for the Ethereum The Nimbus Verified Proxy is a very efficient light client for the Ethereum
PoS network. PoS network.
It exposes the standard [Ethereum JSON RPC Execution API](https://github.com/ethereum/execution-apis) It exposes the standard [Ethereum JSON RPC Execution API](https://github.com/ethereum/execution-apis)
@ -20,30 +20,30 @@ The [consensus p2p light client](https://github.com/ethereum/consensus-specs/tre
is used to efficiently follow the tip of the consensus chain and is used to efficiently follow the tip of the consensus chain and
have access to the latest state hash. have access to the latest state hash.
As such the Nimbus Light Client Proxy turns the untrusted web3 data provider As such the Nimbus Verified Proxy turns the untrusted web3 data provider
into a verified data source, and it can be directly used by any wallet that into a verified data source, and it can be directly used by any wallet that
relies on the Ethereum JSON RPC Execution API. relies on the Ethereum JSON RPC Execution API.
### Build the Nimbus Light Client Proxy from source ### Build the Nimbus Verified Proxy from source
```bash ```bash
# Clone the nimbus-eth1 repository # Clone the nimbus-eth1 repository
git clone git@github.com:status-im/nimbus-eth1.git git clone git@github.com:status-im/nimbus-eth1.git
cd nimbus-eth1 cd nimbus-eth1
# Run the build process # Run the build process
make lc-proxy make nimbus_verified_proxy
# See available command line options # See available command line options
./build/lc_proxy --help ./build/nimbus_verified_proxy --help
``` ```
### Run the Nimbus Light Client Proxy ### Run the Nimbus Verified Proxy
Two options need to be explicitly configured by the user: Two options need to be explicitly configured by the user:
* `--trusted-block-root`: The consensus light client starts syncing from a trusted block. This trusted block should be somewhat recent ([~1-2 weeks](https://github.com/ethereum/consensus-specs/blob/dev/specs/phase0/weak-subjectivity.md)) and needs to be configured each time when starting the Nimbus Light Client Proxy. * `--trusted-block-root`: The consensus light client starts syncing from a trusted block. This trusted block should be somewhat recent ([~1-2 weeks](https://github.com/ethereum/consensus-specs/blob/dev/specs/phase0/weak-subjectivity.md)) and needs to be configured each time when starting the Nimbus Verified Proxy.
* `--web3-url` - As the proxy does not use any storage, it needs access to an Ethereum JSON RPC endpoint to provide the requested data. This can be a regular full node, or an external web3 data provider like * `--web3-url` - As the proxy does not use any storage, it needs access to an Ethereum JSON RPC endpoint to provide the requested data. This can be a regular full node, or an external web3 data provider like
[Alchemy](https://www.alchemy.com/). [Alchemy](https://www.alchemy.com/).
@ -52,10 +52,9 @@ Two options need to be explicitly configured by the user:
The latter is necessary to validate the provided data against the light client. The latter is necessary to validate the provided data against the light client.
A second requirement is that data served from provider needs to match with A second requirement is that data served from provider needs to match with
the ```--network``` option configured for the Nimbus Light Client Proxy. By default the light client proxy is configured to work on mainnet. Thus, the configured provider needs to serve mainnet data. the ```--network``` option configured for the Nimbus Verified Proxy. By default the proxy is configured to work on mainnet. Thus, the configured provider needs to serve mainnet data.
This is verified on start-up by querying the provider its `eth_chainId` endpoint, and comparing the This is verified on start-up by querying the provider its `eth_chainId` endpoint, and comparing the
received chain id with the one configured locally. If this validation fails, the Nimbus Light received chain id with the one configured locally. If this validation fails, the Nimbus Verified Proxy will quit.
Client Proxy will quit.
> Note: Infura currently does not support the `eth_getProof` call. > Note: Infura currently does not support the `eth_getProof` call.
@ -82,42 +81,42 @@ To start the proxy for the Goerli network, run the following command (inserting
```bash ```bash
# From the nimbus-eth1 repository # From the nimbus-eth1 repository
TRUSTED_BLOCK_ROOT=0x1234567890123456789012345678901234567890123456789012345678901234 # Replace this TRUSTED_BLOCK_ROOT=0x1234567890123456789012345678901234567890123456789012345678901234 # Replace this
./build/lc_proxy \ ./build/nimbus_verified_proxy \
--network=goerli \ --network=goerli \
--trusted-block-root=${TRUSTED_BLOCK_ROOT} \ --trusted-block-root=${TRUSTED_BLOCK_ROOT} \
--web3-url="wss://eth-goerli.g.alchemy.com/v2/<ApiKey>" --web3-url="wss://eth-goerli.g.alchemy.com/v2/<ApiKey>"
``` ```
### Using the Nimbus Light Client Proxy with existing Wallets ### Using the Nimbus Verified Proxy with existing Wallets
The Nimbus Light Client Proxy exposes the standard Ethereum JSON RPC Execution API and can thus be used The Nimbus Verified Proxy exposes the standard Ethereum JSON RPC Execution API and can thus be used
as drop-in replacement for any Wallet that relies on this API. as drop-in replacement for any Wallet that relies on this API.
By doing so, it turns an untrusted web3 data provider into a verified data source. By doing so, it turns an untrusted web3 data provider into a verified data source.
The Nimbus Light Client Proxy has been tested in combination with MetaMask. The Nimbus Verified Proxy has been tested in combination with MetaMask.
The [MetaMask configuration page](./docs/metamask_configuration.md) explains how to configure the proxy, and how to configure MetaMask to make use of the proxy. The [MetaMask configuration page](./docs/metamask_configuration.md) explains how to configure the proxy, and how to configure MetaMask to make use of the proxy.
### Update and rebuild the Nimbus Light Client Proxy ### Update and rebuild the Nimbus Verified Proxy
```bash ```bash
# From the nimbus-eth1 repository # From the nimbus-eth1 repository
git pull git pull
# To bring the git submodules up to date # To bring the git submodules up to date
make update make update
make lc-proxy make nimbus_verified_proxy
``` ```
### Run the Nimbus Light Client Proxy test suite ### Run the Nimbus Verified Proxy test suite
```bash ```bash
# From the nimbus-eth1 repository # From the nimbus-eth1 repository
make lc-proxy-test make nimbus-verified-proxy-test
``` ```
### Windows support ### Windows support
Follow the steps outlined [here](../README.md#windows) to build light client proxy on Windows. Follow the steps outlined [here](../README.md#windows) to build Nimbus Verified Proxy on Windows.
## For Developers ## For Developers

View File

@ -1,4 +1,4 @@
# light client proxy # nimbus_verified_proxy
# Copyright (c) 2022 Status Research & Development GmbH # Copyright (c) 2022 Status Research & Development GmbH
# Licensed and distributed under either of # Licensed and distributed under either of
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT). # * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
@ -13,9 +13,10 @@ import
stew/[results, keyed_queue] stew/[results, keyed_queue]
## payloads received through block gossip (and validated by light client). ## Cache for payloads received through block gossip and validated by the
## Payloads are stored in order of arrival. When cache is full the oldest ## consensus light client.
## payload is deleted first. ## The payloads are stored in order of arrival. When the cache is full, the
## oldest payload is deleted first.
type BlockCache* = ref object type BlockCache* = ref object
max: int max: int
blocks: KeyedQueue[BlockHash, ExecutionPayloadV1] blocks: KeyedQueue[BlockHash, ExecutionPayloadV1]

View File

@ -3,11 +3,11 @@
This document explains how to configure the proxy, and how to configure MetaMask This document explains how to configure the proxy, and how to configure MetaMask
to make use of the proxy. to make use of the proxy.
### 1. Building the Nimbus Light Client Proxy ### 1. Building the Nimbus Verified Proxy
First build the Nimbus Light Client Proxy as explained [here](../README.md#Build-light-client-proxy). First build the Nimbus Verified Proxy as explained [here](../README.md#Build-light-client-proxy).
### 2. Configuring and running the Nimbus Light Client Proxy ### 2. Configuring and running the Nimbus Verified Proxy
To start the proxy for the Goerli network, run the following command (inserting your own `TRUSTED_BLOCK_ROOT` and Alchemy `API_KEY`): To start the proxy for the Goerli network, run the following command (inserting your own `TRUSTED_BLOCK_ROOT` and Alchemy `API_KEY`):
@ -16,14 +16,14 @@ To start the proxy for the Goerli network, run the following command (inserting
# From the nimbus-eth1 repository # From the nimbus-eth1 repository
TRUSTED_BLOCK_ROOT=0x1234567890123456789012345678901234567890123456789012345678901234 # Replace this TRUSTED_BLOCK_ROOT=0x1234567890123456789012345678901234567890123456789012345678901234 # Replace this
API_KEY=abcd # Replace this API_KEY=abcd # Replace this
./build/lc_proxy \ ./build/nimbus_verified_proxy \
--network=goerli \ --network=goerli \
--trusted-block-root=${TRUSTED_BLOCK_ROOT} \ --trusted-block-root=${TRUSTED_BLOCK_ROOT} \
--web3-url="wss://eth-goerli.g.alchemy.com/v2/${API_KEY}" --web3-url="wss://eth-goerli.g.alchemy.com/v2/${API_KEY}"
``` ```
After startup, the Nimbus Light Client Proxy will start looking for suitable peers in the network, After startup, the Nimbus Verified Proxy will start looking for suitable peers in the network,
i.e peers which serve consensus light client data, and will then start syncing. i.e peers which serve consensus light client data, and will then start syncing.
During syncing most of the RPC endpoints will be inactive During syncing most of the RPC endpoints will be inactive
and will fail to respond to queries. This happens because the proxy cannot verify responses and will fail to respond to queries. This happens because the proxy cannot verify responses

View File

@ -1,13 +1,10 @@
# light client proxy # nimbus_verified_proxy
# Copyright (c) 2022 Status Research & Development GmbH # Copyright (c) 2022 Status Research & Development GmbH
# Licensed and distributed under either of # Licensed and distributed under either of
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT). # * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0). # * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
# at your option. This file may not be copied, modified, or distributed except according to those terms. # at your option. This file may not be copied, modified, or distributed except according to those terms.
# This implements the pre-release proposal of the libp2p based light client sync
# protocol. See https://github.com/ethereum/consensus-specs/pull/2802
{.push raises: [Defect].} {.push raises: [Defect].}
import import
@ -22,8 +19,8 @@ import
beacon_chain/spec/datatypes/[phase0, altair, bellatrix], beacon_chain/spec/datatypes/[phase0, altair, bellatrix],
beacon_chain/[light_client, nimbus_binary_common, version], beacon_chain/[light_client, nimbus_binary_common, version],
../nimbus/rpc/cors, ../nimbus/rpc/cors,
./rpc/rpc_eth_lc_api, ./rpc/rpc_eth_api,
./lc_proxy_conf, ./nimbus_verified_proxy_conf,
./block_cache ./block_cache
from beacon_chain/gossip_processing/block_processor import newExecutionPayload from beacon_chain/gossip_processing/block_processor import newExecutionPayload
@ -47,7 +44,7 @@ func getConfiguredChainId(networkMetadata: Eth2NetworkMetadata): Quantity =
proc run() {.raises: [Exception, Defect].} = proc run() {.raises: [Exception, Defect].} =
{.pop.} {.pop.}
var config = makeBannerAndConfig( var config = makeBannerAndConfig(
"Nimbus light client " & fullVersionStr, LcProxyConf) "Nimbus verified proxy " & fullVersionStr, VerifiedProxyConf)
{.push raises: [Defect].} {.push raises: [Defect].}
# Required as both Eth2Node and LightClient requires correct config type # Required as both Eth2Node and LightClient requires correct config type
@ -55,7 +52,7 @@ proc run() {.raises: [Exception, Defect].} =
setupLogging(config.logLevel, config.logStdout, config.logFile) setupLogging(config.logLevel, config.logStdout, config.logFile)
notice "Launching light client proxy", notice "Launching Nimbus verified proxy",
version = fullVersionStr, cmdParams = commandLineParams(), config version = fullVersionStr, cmdParams = commandLineParams(), config
let let
@ -108,7 +105,7 @@ proc run() {.raises: [Exception, Defect].} =
authHooks authHooks
) )
lcProxy = LightClientRpcProxy.new(rpcProxy, blockCache, chainId) verifiedProxy = VerifiedRpcProxy.new(rpcProxy, blockCache, chainId)
optimisticHandler = proc(signedBlock: ForkedMsgTrustedSignedBeaconBlock): optimisticHandler = proc(signedBlock: ForkedMsgTrustedSignedBeaconBlock):
Future[void] {.async.} = Future[void] {.async.} =
@ -130,7 +127,7 @@ proc run() {.raises: [Exception, Defect].} =
network, rng, lcConfig, cfg, forkDigests, getBeaconTime, network, rng, lcConfig, cfg, forkDigests, getBeaconTime,
genesis_validators_root, LightClientFinalizationMode.Optimistic) genesis_validators_root, LightClientFinalizationMode.Optimistic)
lcProxy.installEthApiHandlers() verifiedProxy.installEthApiHandlers()
info "Listening to incoming network requests" info "Listening to incoming network requests"
network.initBeaconSync(cfg, forkDigests, genesisBlockRoot, getBeaconTime) network.initBeaconSync(cfg, forkDigests, genesisBlockRoot, getBeaconTime)
@ -154,7 +151,7 @@ proc run() {.raises: [Exception, Defect].} =
waitFor network.startListening() waitFor network.startListening()
waitFor network.start() waitFor network.start()
waitFor rpcProxy.start() waitFor rpcProxy.start()
waitFor lcProxy.verifyChaindId() waitFor verifiedProxy.verifyChaindId()
proc onFinalizedHeader( proc onFinalizedHeader(
lightClient: LightClient, finalizedHeader: BeaconBlockHeader) = lightClient: LightClient, finalizedHeader: BeaconBlockHeader) =

View File

@ -1,4 +1,4 @@
# beacon_chain # nimbus_verified_proxy
# Copyright (c) 2022 Status Research & Development GmbH # Copyright (c) 2022 Status Research & Development GmbH
# Licensed and distributed under either of # Licensed and distributed under either of
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT). # * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
@ -21,11 +21,11 @@ export net, conf
proc defaultLCPDataDir*(): string = proc defaultLCPDataDir*(): string =
let dataDir = when defined(windows): let dataDir = when defined(windows):
"AppData" / "Roaming" / "LightClientProxy" "AppData" / "Roaming" / "NimbusVerifiedProxy"
elif defined(macosx): elif defined(macosx):
"Library" / "Application Support" / "LightClientProxy" "Library" / "Application Support" / "NimbusVerifiedProxy"
else: else:
".cache" / "lightclientproxy" ".cache" / "nimbus-verified-proxy"
getHomeDir() / dataDir getHomeDir() / dataDir
@ -40,7 +40,7 @@ type
kind*: Web3UrlKind kind*: Web3UrlKind
web3Url*: string web3Url*: string
type LcProxyConf* = object type VerifiedProxyConf* = object
# Config # Config
configFile* {. configFile* {.
desc: "Loads the configuration from a TOML file" desc: "Loads the configuration from a TOML file"
@ -147,11 +147,6 @@ type LcProxyConf* = object
"Peering agreements are established out of band and must be reciprocal." "Peering agreements are established out of band and must be reciprocal."
name: "direct-peer" .}: seq[string] name: "direct-peer" .}: seq[string]
# Light client
trustedBlockRoot* {.
desc: "Recent trusted finalized block root to initialize light client from"
name: "trusted-block-root" .}: Eth2Digest
rpcPort* {. rpcPort* {.
desc: "HTTP port for the JSON-RPC server" desc: "HTTP port for the JSON-RPC server"
defaultValue: 8545 defaultValue: 8545
@ -163,7 +158,12 @@ type LcProxyConf* = object
defaultValueDesc: $defaultAdminListenAddressDesc defaultValueDesc: $defaultAdminListenAddressDesc
name: "rpc-address" .}: ValidIpAddress name: "rpc-address" .}: ValidIpAddress
# There is no default as its need to be provided by the user # No default - Needs to be provided by the user
trustedBlockRoot* {.
desc: "Recent trusted finalized block root to initialize the consensus light client from"
name: "trusted-block-root" .}: Eth2Digest
# No default - Needs to be provided by the user
web3url* {. web3url* {.
desc: "url of web3 data provider" desc: "url of web3 data provider"
name: "web3-url" .}: ValidatedWeb3Url name: "web3-url" .}: ValidatedWeb3Url
@ -184,7 +184,7 @@ proc parseCmdArg*(T: type ValidatedWeb3Url, p: TaintedString): T
proc completeCmdArg*(T: type ValidatedWeb3Url, val: TaintedString): seq[string] = proc completeCmdArg*(T: type ValidatedWeb3Url, val: TaintedString): seq[string] =
return @[] return @[]
func asLightClientConf*(pc: LcProxyConf): LightClientConf = func asLightClientConf*(pc: VerifiedProxyConf): LightClientConf =
return LightClientConf( return LightClientConf(
configFile: pc.configFile, configFile: pc.configFile,
logLevel: pc.logLevel, logLevel: pc.logLevel,
@ -210,7 +210,7 @@ func asLightClientConf*(pc: LcProxyConf): LightClientConf =
stopAtEpoch: 0 stopAtEpoch: 0
) )
# TODO: Cannot use ClientConfig in LcProxyConf due to the fact that # TODO: Cannot use ClientConfig in VerifiedProxyConf due to the fact that
# it contain `set[TLSFlags]` which does not have proper toml serialization # it contain `set[TLSFlags]` which does not have proper toml serialization
func asClientConfig*(url: ValidatedWeb3Url): ClientConfig = func asClientConfig*(url: ValidatedWeb3Url): ClientConfig =
case url.kind case url.kind

View File

@ -1,4 +1,4 @@
# ligh client proxy # nimbus_verified_proxy
# Copyright (c) 2022 Status Research & Development GmbH # Copyright (c) 2022 Status Research & Development GmbH
# Licensed and distributed under either of # Licensed and distributed under either of
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT). # * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
@ -26,7 +26,7 @@ import
export forks export forks
logScope: logScope:
topics = "light_proxy" topics = "verified_proxy"
proc `==`(x, y: Quantity): bool {.borrow, noSideEffect.} proc `==`(x, y: Quantity): bool {.borrow, noSideEffect.}
@ -43,7 +43,7 @@ template encodeQuantity(value: Quantity): HexQuantityStr =
hexQuantityStr(encodeQuantity(value.uint64)) hexQuantityStr(encodeQuantity(value.uint64))
type type
LightClientRpcProxy* = ref object VerifiedRpcProxy* = ref object
proxy: RpcProxy proxy: RpcProxy
blockCache: BlockCache blockCache: BlockCache
chainId: Quantity chainId: Quantity
@ -81,14 +81,14 @@ func parseQuantityTag(blockTag: string): Result[QuantityTag, string] =
let quantity = ? parseHexQuantity(tag) let quantity = ? parseHexQuantity(tag)
return ok(QuantityTag(kind: BlockNumber, blockNumber: quantity)) return ok(QuantityTag(kind: BlockNumber, blockNumber: quantity))
template checkPreconditions(proxy: LightClientRpcProxy) = template checkPreconditions(proxy: VerifiedRpcProxy) =
if proxy.blockCache.isEmpty(): if proxy.blockCache.isEmpty():
raise newException(ValueError, "Syncing") raise newException(ValueError, "Syncing")
template rpcClient(lcProxy: LightClientRpcProxy): RpcClient = lcProxy.proxy.getClient() template rpcClient(lcProxy: VerifiedRpcProxy): RpcClient = lcProxy.proxy.getClient()
proc getPayloadByTag( proc getPayloadByTag(
proxy: LightClientRpcProxy, proxy: VerifiedRpcProxy,
quantityTag: string): results.Opt[ExecutionPayloadV1] {.raises: [ValueError, Defect].} = quantityTag: string): results.Opt[ExecutionPayloadV1] {.raises: [ValueError, Defect].} =
checkPreconditions(proxy) checkPreconditions(proxy)
@ -107,7 +107,7 @@ proc getPayloadByTag(
return proxy.blockCache.getByNumber(tag.blockNumber) return proxy.blockCache.getByNumber(tag.blockNumber)
proc getPayloadByTagOrThrow( proc getPayloadByTagOrThrow(
proxy: LightClientRpcProxy, proxy: VerifiedRpcProxy,
quantityTag: string): ExecutionPayloadV1 {.raises: [ValueError, Defect].} = quantityTag: string): ExecutionPayloadV1 {.raises: [ValueError, Defect].} =
let tagResult = getPayloadByTag(proxy, quantityTag) let tagResult = getPayloadByTag(proxy, quantityTag)
@ -117,7 +117,7 @@ proc getPayloadByTagOrThrow(
return tagResult.get() return tagResult.get()
proc installEthApiHandlers*(lcProxy: LightClientRpcProxy) = proc installEthApiHandlers*(lcProxy: VerifiedRpcProxy) =
lcProxy.proxy.rpc("eth_chainId") do() -> HexQuantityStr: lcProxy.proxy.rpc("eth_chainId") do() -> HexQuantityStr:
return encodeQuantity(lcProxy.chainId) return encodeQuantity(lcProxy.chainId)
@ -259,18 +259,18 @@ proc installEthApiHandlers*(lcProxy: LightClientRpcProxy) =
return some(asBlockObject(executionPayload.get())) return some(asBlockObject(executionPayload.get()))
proc new*( proc new*(
T: type LightClientRpcProxy, T: type VerifiedRpcProxy,
proxy: RpcProxy, proxy: RpcProxy,
blockCache: BlockCache, blockCache: BlockCache,
chainId: Quantity): T = chainId: Quantity): T =
return LightClientRpcProxy( return VerifiedRpcProxy(
proxy: proxy, proxy: proxy,
blockCache: blockCache, blockCache: blockCache,
chainId: chainId chainId: chainId
) )
proc verifyChaindId*(p: LightClientRpcProxy): Future[void] {.async.} = proc verifyChaindId*(p: VerifiedRpcProxy): Future[void] {.async.} =
let localId = p.chainId let localId = p.chainId
# retry 2 times, if the data provider will fail despite re-tries, propagate # retry 2 times, if the data provider will fail despite re-tries, propagate

View File

@ -1,3 +1,10 @@
# nimbus_verified_proxy
# Copyright (c) 2022 Status Research & Development GmbH
# Licensed and distributed under either of
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
# at your option. This file may not be copied, modified, or distributed except according to those terms.
import import
std/typetraits, std/typetraits,
eth/common/eth_types as etypes, eth/common/eth_types as etypes,

View File

@ -1,4 +1,4 @@
# light client proxy # nimbus_verified_proxy
# Copyright (c) 2022 Status Research & Development GmbH # Copyright (c) 2022 Status Research & Development GmbH
# Licensed and distributed under either of # Licensed and distributed under either of
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT). # * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).

View File

@ -1,4 +1,4 @@
# light client proxy # nimbus_verified_proxy
# Copyright (c) 2022 Status Research & Development GmbH # Copyright (c) 2022 Status Research & Development GmbH
# Licensed and distributed under either of # Licensed and distributed under either of
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT). # * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).