Skip to content

Latest commit

 

History

History
125 lines (86 loc) · 3.38 KB

File metadata and controls

125 lines (86 loc) · 3.38 KB

Build smartbchd

This document shows how to build smartbchd (the executable of smartBCH's full node client). We suggest to use ubuntu 20.04.

Step 0: install the basic tools.

We suggest to use GCC-9 because it's the default compiler of ubuntu 20.04. But you call as well use GCC-10 and GCC-11. Just replace the following g++ and gcc with your desired compilers (such as g++-10/gcc-10/g++-11/gcc-11).

sudo sed -i -e '$a* soft nofile 65536\n* hard nofile 65536' /etc/security/limits.conf ;# enlarge count of open files
sudo apt update
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
sudo apt install make cmake g++ gcc git

Then download and unpack golang (If you are using ARM Linux, please replace "amd64" with "arm64"):

wget https://go.dev/dl/go1.18.linux-amd64.tar.gz
tar zxvf go1.18.linux-amd64.tar.gz

And set some environment variables for golang:

export GOROOT=~/go
export PATH=$PATH:$GOROOT/bin
mkdir ~/godata
export GOPATH=~/godata

After installing golang, we need to patch it for larger cgo stack.

wget https://github.com/smartbch/patch-cgo-for-golang/archive/refs/tags/v0.1.2.tar.gz
tar zxvf v0.1.2.tar.gz
rm v0.1.2.tar.gz
cd patch-cgo-for-golang-0.1.2
cp *.c $GOROOT/src/runtime/cgo/

Step 1: install dependencies

firsrt, install rocksdb dependencies.

sudo apt install libgflags-dev

For some unknown reason, on some machines with ubuntu 20.04, the default libsnappy does not work well. So we suggest to build libsnappy from source:

mkdir $HOME/build
cd $HOME/build
wget https://github.com/google/snappy/archive/refs/tags/1.1.8.tar.gz
tar zxvf 1.1.8.tar.gz
cd snappy-1.1.8
mkdir build
cd build
CXX=g++ cmake -DBUILD_STATIC_LIBS=On ../
make CC=gcc CXX=g++
sudo make install

then install rocksdb

cd $HOME/build
wget https://github.com/facebook/rocksdb/archive/refs/tags/v5.18.4.tar.gz
tar zxvf v5.18.4.tar.gz
cd rocksdb-5.18.4
curl https://raw.githubusercontent.com/smartbch/artifacts/main/patches/rocksdb.gcc11.patch | git apply -v
CXXFLAGS=-Wno-range-loop-construct make CC=gcc CXX=g++ static_lib

more infos can refer to rocksdb install doc

Last, export library path. You should export ROCKSDB_PATH with rocksdb root directory downloaded from above

export ROCKSDB_PATH="$HOME/build/rocksdb-5.18.4" ;#this direct to rocksdb root dir

Step 2: create the smart_bch directory.

cd ~ ;# any directory can do. Here we use home directory for example
mkdir smart_bch
cd smart_bch

Step 3: clone the moeingevm repo, and build static linked library.

cd ~/smart_bch
git clone -b v0.4.4 --depth 1 https://github.com/smartbch/moeingevm
cd moeingevm/evmwrap
make
export CGO_CFLAGS="-I$ROCKSDB_PATH/include"
export CGO_LDFLAGS="-L$ROCKSDB_PATH -L$HOME/smart_bch/moeingevm/evmwrap/host_bridge/ -l:librocksdb.a -lstdc++ -lm -lsnappy "

After successfully executing the above commands, you'll get a ~/smart_bch/moeingevm/evmwrap/host_bridge/libevmwrap.a file.

Step 4: clone the source code of smartBCH and build the executable of smartbchd.

cd ~/smart_bch
git clone -b v0.4.7 --depth 1 https://github.com/smartbch/smartbch
cd smartbch
go build -tags cppbtree github.com/smartbch/smartbch/cmd/smartbchd

After successfully executing the above commands, you'll get a ~/smart_bch/smartbch/smartbchd file.