Skip to content

C++ implementation of Ethereum JSON RPC daemon within Thorax architecture

License

Notifications You must be signed in to change notification settings

yarkinwho/silkrpc

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SilkRPC Daemon

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

CircleCI Codecov master version License 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

  • C++20 compiler: GCC >= 10.2.0 or Clang >= 10.0.0
  • Build system: CMake >= 3.18.4
  • GNU Multiple Precision arithmetic library: GMP >= 6.2.0
    • sudo apt-get install libgmp3-dev or brew install gmp
  • Microsoft mimalloc library: mimalloc >= 1.7.0
    git clone https://github.com/microsoft/mimalloc
    cd mimalloc
    mkdir -p out/release
    cd out/release
    cmake ../..
    make
    sudo make install
    
  • Python 3.x interpreter >= 3.8.2
    • sudo apt-get install python3
  • some additional Python modules
    • pip install -r requirements.txt from project folder

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:

# Complete rebuild
./rebuild_gcc_debug.sh
./rebuild_gcc_release.sh
# Incremental build
./build_gcc_debug.sh
./build_gcc_release.sh
# Complete rebuild
./rebuild_clang_debug.sh
./rebuild_clang_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

  • Install Visual Studio 2019. Community edition is fine.
  • Make sure your setup includes CMake support and Windows 10 SDK.
  • Install vcpkg.
  • .\vcpkg\vcpkg install mpir:x64-windows
  • Add <VCPKG_ROOT>\installed\x64-windows\include to your INCLUDE environment variable.
  • Add <VCPKG_ROOT>\installed\x64-windows\bin to your PATH environment variable.
  • Open Visual Studio and select File -> CMake...
  • Browse the folder where you have cloned this repository and select the file CMakeLists.txt
  • Let CMake cache generation complete (it may take several minutes)
  • Solution explorer shows the project tree.
  • To build simply CTRL+Shift+B
  • Binaries are written to %USERPROFILE%\CMakeBuilds\silkrpc\build If you want to change this path simply edit CMakeSettings.json file.

Code style

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

  • snake_case for function names.
  • .cpp & .hpp file extensions are used for C++; .cc are used just for gRPC generated C++; .c & .h are reserved for C.
  • using namespace foo is allowed inside .cpp files, but not inside headers.
  • Exceptions are allowed.
  • User-defined literals are allowed.
  • Maximum line length is 190, indentation is 4 spaces – see .clang-format.

Activation

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

$ silkrpc/silkrpcdaemon --target <erigon_core_host_address>:9090

where <erigon_core_host_address> is the hostname or IP address of the Erigon Core to connect to.

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

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

  Flags from main.cpp:
    --chaindata (chain data path as string); default: "";
    --eth1_local (Ethereum JSON RPC API local binding as string <address>:<port>); default: "localhost:8545";
    --eth2_local (Engine JSON RPC API local binding as string <address>:<port>); default: "localhost:8550";
    --logLevel (logging level); default: c;
    --numContexts (number of running I/O contexts as 32-bit integer); default: number of hardware thread contexts / 2;
    --numWorkers (number of worker threads as 32-bit integer); default: number of hardware thread contexts;
    --target (Erigon Core gRPC service location as string <address>:<port>); default: "localhost:9090";
    --timeout (gRPC call timeout as 32-bit integer); default: 10000;

You can also check the Silkrpc executable version by:

$ silkrpc/silkrpcdaemon --version
silkrpcdaemon 0.0.7

About

C++ implementation of Ethereum JSON RPC daemon within Thorax architecture

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C++ 96.6%
  • Python 2.1%
  • CMake 1.1%
  • Shell 0.2%