Skip to content
/ silkrpc Public
forked from erigontech/silkrpc

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

License

Notifications You must be signed in to change notification settings

37ng/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

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

  • 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:

$ 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 Erigon1 stable version: last integration and performance test sessions has been performed using Erigon1 at 363d9fc. In order to run Silkrpc with Erigon1, you must install and build Erigon1 following the usage instructions here.

Please note the following caveats:

  • Erigon1 stable is not Merge ready
  • Erigon1 stable does not start an internal RPCDaemon so you don't need to worry about conflicts on JSON RPC HTTP port
  • if you launch Silkrpc and Erigon1 using the default settings on the same machine, you won't need to customize gRPC client/server addresses/ports; otherwise, you need to make sure that Silkrpc target setting matches Erigon1 private.api.addr setting
  • just the flags described above in the Command-line parameters section are actually supported by Silkrpc (other flags may be present in the help description but should be ignored)

About

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

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 97.0%
  • Python 2.0%
  • Other 1.0%