erigontech / silkrpc

C++ implementation of Ethereum JSON RPC daemon within Thorax architecture
Apache License 2.0
45 stars 14 forks source link
cpp20 ethereum json rpc thorax

:no_entry_sign: SilkRPC Daemon has been moved into Silkworm :no_entry_sign:

C++ implementation of the daemon component exposing the Ethereum JSON RPC protocol within the Erigon architecture.

CircleCI Codecov master version

Total Alerts Code Quality: C/C++ Code Quality: Python

GitHub semver


Building the source

Clone the repository

git clone --recurse-submodules https://github.com/torquem-ch/silkrpc.git

To update the submodules later on run

git submodule update --init --recursive

Linux & MacOS

Building SilkRPC daemon requires

Please make your GCC or Clang compiler available as gcc and g++ or clang and clang++ at the command line prompt.

Once the prerequisites are installed, there are convenience bash scripts for complete rebuild and incremental build both in debug and release configurations:

# Incremental build
./build_gcc_debug.sh
./build_gcc_release.sh
# Incremental build
./build_clang_debug.sh
./build_clang_release.sh

The resulting build folders are build_[gcc, clang]_[debug, release] according to your choice.

To enable parallel compilation, set the CMAKE_BUILD_PARALLEL_LEVEL environment variable to the desired value as described here.

For example, in order to have 4 concurrent compile processes, insert in .bashrc file the following line

export CMAKE_BUILD_PARALLEL_LEVEL=4

You can also perform the build step-by-step manually: just bootstrap cmake by running

mkdir build_gcc_release
cd build_gcc_release
cmake ..

(you have to run cmake .. just the first time), then run the build itself

cmake --build .

Now you can run the unit tests

cmd/unit_test

and check the code style running

./run_linter.sh

You can clean the build using

cmake --build . --target clean

Windows

Code style

We use the standard C++20 programming language. We follow the Google's C++ Style Guide with the following differences:

Activation

From the build folder (build_[gcc, clang]_[debug, release] according to your choice) you typically activate Silkrpc using:

$ cmd/silkrpcdaemon --target <core_service_host_address>:9090

where <core_service_host_address> is the hostname or IP address of the Core services to connect to.

Command-line parameters

You can check all command-line parameters supported by Silkrpc using:

$ cmd/silkrpcdaemon --help
silkrpcdaemon: C++ implementation of ETH JSON Remote Procedure Call (RPC) daemon

  Flags from silkrpc_daemon.cpp:
    --http_port (Ethereum JSON RPC API local binding as string <address>:<port>); default: "localhost:8545";
    --log_verbosity (logging verbosity level); default: c;
    --num_contexts (number of running I/O contexts as integer); default: number of hardware thread contexts / 3;
    --num_workers (number of worker threads as integer); default: 16;
    --target (Core gRPC service location as string <address>:<port>); default: "localhost:9090";
    --wait_mode (I/O scheduler wait mode); default: blocking;

You can also check the Silkrpc executable version by:

$ cmd/silkrpcdaemon --version
silkrpcdaemon version: 0.0.7-109+commit.bfe634dd

Running Silkrpc with Erigon

Currently Silkrpc is compatible only with Erigon2 2022.09.01-alpha version: last integration and performance test sessions has been performed using Erigon1 at 4067b7c. In order to run Silkrpc with Erigon2, you must install and build Erigon2 following the usage instructions here.

Please note the following caveats: