From e0d7a6314a7ab6f17fec3e704370007c00896704 Mon Sep 17 00:00:00 2001 From: serkixenos Date: Fri, 6 May 2022 04:14:36 +0200 Subject: [PATCH] Ubuntu 18.04 build support --- CMakeLists.txt | 31 ++++ Dockerfile | 37 +++- Dockerfile.18.04 | 160 ++++++++++++++++++ README.md | 130 ++++++++++++-- .../chain/son_wallet_deposit_object.hpp | 2 +- .../chain/son_wallet_withdraw_object.hpp | 2 +- .../sidechain_net_handler_bitcoin.cpp | 6 +- 7 files changed, 350 insertions(+), 18 deletions(-) create mode 100644 Dockerfile.18.04 diff --git a/CMakeLists.txt b/CMakeLists.txt index 27c29861..695881be 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,6 +22,37 @@ endif() list( APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules" ) +function(get_linux_lsb_release_information) + find_program(LSB_RELEASE_EXEC lsb_release) + if(NOT LSB_RELEASE_EXEC) + message(FATAL_ERROR "Could not detect lsb_release executable, can not gather required information") + endif() + + execute_process(COMMAND "${LSB_RELEASE_EXEC}" --short --id OUTPUT_VARIABLE LSB_RELEASE_ID_SHORT OUTPUT_STRIP_TRAILING_WHITESPACE) + execute_process(COMMAND "${LSB_RELEASE_EXEC}" --short --release OUTPUT_VARIABLE LSB_RELEASE_VERSION_SHORT OUTPUT_STRIP_TRAILING_WHITESPACE) + execute_process(COMMAND "${LSB_RELEASE_EXEC}" --short --codename OUTPUT_VARIABLE LSB_RELEASE_CODENAME_SHORT OUTPUT_STRIP_TRAILING_WHITESPACE) + + set(LSB_RELEASE_ID_SHORT "${LSB_RELEASE_ID_SHORT}" PARENT_SCOPE) + set(LSB_RELEASE_VERSION_SHORT "${LSB_RELEASE_VERSION_SHORT}" PARENT_SCOPE) + set(LSB_RELEASE_CODENAME_SHORT "${LSB_RELEASE_CODENAME_SHORT}" PARENT_SCOPE) +endfunction() + +if(CMAKE_SYSTEM_NAME MATCHES "Linux") + find_package(cppzmq) + target_link_libraries(cppzmq) + + get_linux_lsb_release_information() + message(STATUS "Linux ${LSB_RELEASE_ID_SHORT} ${LSB_RELEASE_VERSION_SHORT} ${LSB_RELEASE_CODENAME_SHORT}") + string(REGEX MATCHALL "([0-9]+)" arg_list ${LSB_RELEASE_VERSION_SHORT}) + list( LENGTH arg_list listlen ) + if (NOT listlen) + message(FATAL_ERROR "Could not detect Ubuntu version") + endif() + list(GET arg_list 0 output) + message("Ubuntu version is: ${output}") + add_definitions(-DPEERPLAYS_UBUNTU_VERSION=${output}) +endif() + # function to help with cUrl macro(FIND_CURL) if (NOT WIN32 AND NOT APPLE AND CURL_STATICLIB) diff --git a/Dockerfile b/Dockerfile index 38c96a3c..e90e5380 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ FROM ubuntu:20.04 -MAINTAINER PeerPlays Blockchain Standards Association +MAINTAINER Peerplays Blockchain Standards Association #=============================================================================== # Ubuntu setup @@ -28,8 +28,8 @@ RUN \ libssl-dev \ libtool \ libzip-dev \ - libzmq3-dev \ locales \ + lsb-release \ mc \ nano \ net-tools \ @@ -40,6 +40,7 @@ RUN \ python3 \ python3-jinja2 \ sudo \ + systemd-coredump \ wget ENV HOME /home/peerplays @@ -53,6 +54,38 @@ RUN echo 'peerplays:peerplays' | chpasswd # SSH EXPOSE 22 +#=============================================================================== +# libzmq setup +#=============================================================================== + +WORKDIR /home/peerplays/ + +RUN \ + wget https://github.com/zeromq/libzmq/archive/refs/tags/v4.3.4.zip && \ + unzip v4.3.4.zip && \ + cd libzmq-4.3.4 && \ + mkdir build && \ + cd build && \ + cmake .. && \ + make -j$(nproc) install && \ + ldconfig + +#=============================================================================== +# cppzmq setup +#=============================================================================== + +WORKDIR /home/peerplays/ + +RUN \ + wget https://github.com/zeromq/cppzmq/archive/refs/tags/v4.8.1.zip && \ + unzip v4.8.1.zip && \ + cd cppzmq-4.8.1 && \ + mkdir build && \ + cd build && \ + cmake .. && \ + make -j$(nproc) install && \ + ldconfig + #=============================================================================== # Peerplays setup #=============================================================================== diff --git a/Dockerfile.18.04 b/Dockerfile.18.04 new file mode 100644 index 00000000..5e928263 --- /dev/null +++ b/Dockerfile.18.04 @@ -0,0 +1,160 @@ +FROM ubuntu:18.04 +MAINTAINER Peerplays Blockchain Standards Association + +#=============================================================================== +# Ubuntu setup +#=============================================================================== + +RUN \ + apt-get update -y && \ + DEBIAN_FRONTEND=noninteractive apt-get install -y \ + apt-utils \ + autoconf \ + bash \ + build-essential \ + ca-certificates \ + dnsutils \ + doxygen \ + expect \ + git \ + graphviz \ + libbz2-dev \ + libcurl4-openssl-dev \ + libncurses-dev \ + libreadline-dev \ + libsnappy-dev \ + libssl-dev \ + libtool \ + libzip-dev \ + locales \ + lsb-release \ + mc \ + nano \ + net-tools \ + ntp \ + openssh-server \ + pkg-config \ + perl \ + python3 \ + python3-jinja2 \ + sudo \ + systemd-coredump \ + wget + +ENV HOME /home/peerplays +RUN useradd -rm -d /home/peerplays -s /bin/bash -g root -G sudo -u 1000 peerplays +RUN echo "peerplays ALL=(ALL) NOPASSWD:ALL" | sudo tee /etc/sudoers.d/peerplays +RUN chmod 440 /etc/sudoers.d/peerplays + +RUN service ssh start +RUN echo 'peerplays:peerplays' | chpasswd + +# SSH +EXPOSE 22 + +#=============================================================================== +# Boost setup +#=============================================================================== + +WORKDIR /home/peerplays/ + +RUN \ + wget -c 'http://sourceforge.net/projects/boost/files/boost/1.67.0/boost_1_67_0.tar.bz2/download' -O boost_1_67_0.tar.bz2 && \ + tar xjf boost_1_67_0.tar.bz2 && \ + cd boost_1_67_0/ && \ + ./bootstrap.sh && \ + ./b2 install + +#=============================================================================== +# cmake setup +#=============================================================================== + +WORKDIR /home/peerplays/ + +RUN \ + wget -c 'https://cmake.org/files/v3.23/cmake-3.23.1-linux-x86_64.sh' -O cmake-3.23.1-linux-x86_64.sh && \ + chmod 755 ./cmake-3.23.1-linux-x86_64.sh && \ + ./cmake-3.23.1-linux-x86_64.sh --prefix=/usr/ --skip-license && \ + cmake --version + +#=============================================================================== +# libzmq setup +#=============================================================================== + +WORKDIR /home/peerplays/ + +RUN \ + wget https://github.com/zeromq/libzmq/archive/refs/tags/v4.3.4.zip && \ + unzip v4.3.4.zip && \ + cd libzmq-4.3.4 && \ + mkdir build && \ + cd build && \ + cmake .. && \ + make -j$(nproc) install && \ + ldconfig + +#=============================================================================== +# cppzmq setup +#=============================================================================== + +WORKDIR /home/peerplays/ + +RUN \ + wget https://github.com/zeromq/cppzmq/archive/refs/tags/v4.8.1.zip && \ + unzip v4.8.1.zip && \ + cd cppzmq-4.8.1 && \ + mkdir build && \ + cd build && \ + cmake .. && \ + make -j$(nproc) install && \ + ldconfig + +#=============================================================================== +# Peerplays setup +#=============================================================================== + +WORKDIR /home/peerplays/ + +## Clone Peerplays +#RUN \ +# git clone https://gitlab.com/PBSA/peerplays.git && \ +# cd peerplays && \ +# git checkout develop && \ +# git submodule update --init --recursive && \ +# git branch --show-current && \ +# git log --oneline -n 5 + +# Add local source +ADD . peerplays + +# Configure Peerplays +RUN \ + cd peerplays && \ + mkdir build && \ + cd build && \ + cmake -DCMAKE_BUILD_TYPE=Release .. + +# Build Peerplays +RUN \ + cd peerplays/build && \ + make -j$(nproc) cli_wallet witness_node + +WORKDIR /home/peerplays/peerplays-network + +# Setup Peerplays runimage +RUN \ + ln -s /home/peerplays/peerplays/build/programs/cli_wallet/cli_wallet ./ && \ + ln -s /home/peerplays/peerplays/build/programs/witness_node/witness_node ./ + +RUN ./witness_node --create-genesis-json genesis.json && \ + rm genesis.json + +RUN chown peerplays:root -R /home/peerplays/peerplays-network + +# Peerplays RPC +EXPOSE 8090 +# Peerplays P2P: +EXPOSE 9777 + +# Peerplays +CMD ["./witness_node", "-d", "./witness_node_data_dir"] diff --git a/README.md b/README.md index 391218b7..b1333d8e 100644 --- a/README.md +++ b/README.md @@ -6,24 +6,125 @@ This is a quick introduction to get new developers and witnesses up to speed on # Building and Installation Instructions -Officially supported OS is Ubuntu 20.04. +Officially supported OS are Ubuntu 20.04 and Ubuntu 18.04. + +## Ubuntu 20.04 Following dependencies are needed for a clean install of Ubuntu 20.04: ``` sudo apt-get install \ - apt-utils autoconf bash build-essential ca-certificates clang-format cmake + apt-utils autoconf bash build-essential ca-certificates clang-format cmake \ dnsutils doxygen expect git graphviz libboost-all-dev libbz2-dev \ libcurl4-openssl-dev libncurses-dev libreadline-dev libsnappy-dev \ - libssl-dev libtool libzip-dev libzmq3-dev locales mc nano net-tools ntp \ - openssh-server pkg-config perl python3 python3-jinja2 sudo wget + libssl-dev libtool libzip-dev locales lsb-release mc nano net-tools ntp \ + openssh-server pkg-config perl python3 python3-jinja2 sudo \ + systemd-coredump wget ``` - -## Building Peerplays - +Install libzmq from source: +``` +wget https://github.com/zeromq/libzmq/archive/refs/tags/v4.3.4.zip +unzip v4.3.4.zip +cd libzmq-4.3.4 +mkdir build +cd build +cmake .. +make -j$(nproc) +sudo make install +sudo ldconfig +``` + +Install cppzmq from source: +``` +wget https://github.com/zeromq/cppzmq/archive/refs/tags/v4.8.1.zip +unzip v4.8.1.zip +cd cppzmq-4.8.1 +mkdir build +cd build +cmake .. +make -j$(nproc) +sudo make install +sudo ldconfig +``` + +Building Peerplays +``` +git clone https://gitlab.com/PBSA/peerplays.git +cd peerplays +git submodule update --init --recursive + +# If you want to build Mainnet node +cmake -DCMAKE_BUILD_TYPE=Release + +# If you want to build Testnet node +cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_PEERPLAYS_TESTNET=1 + +# Update -j flag depending on your current system specs; +# Recommended 4GB of RAM per 1 CPU core +# make -j2 for 8GB RAM +# make -j4 for 16GB RAM +# make -j8 for 32GB RAM +make -j$(nproc) + +make install # this can install the executable files under /usr/local +``` + +## Ubuntu 18.04 + +Following dependencies are needed for a clean install of Ubuntu 18.04: +``` +sudo apt-get install \ + apt-utils autoconf bash build-essential ca-certificates dnsutils doxygen \ + expect git graphviz libbz2-dev libcurl4-openssl-dev libncurses-dev \ + libreadline-dev libsnappy-dev libssl-dev libtool libzip-dev locales \ + lsb-release mc nano net-tools ntp openssh-server pkg-config perl \ + python3 python3-jinja2 sudo systemd-coredump wget +``` + +Install Boost libraries from source +``` +wget -c 'http://sourceforge.net/projects/boost/files/boost/1.67.0/boost_1_67_0.tar.bz2/download' -O boost_1_67_0.tar.bz2 +tar xjf boost_1_67_0.tar.bz2 +cd boost_1_67_0/ +./bootstrap.sh +sudo ./b2 install +``` + +Install cmake +``` +wget -c 'https://cmake.org/files/v3.23/cmake-3.23.1-linux-x86_64.sh' -O cmake-3.23.1-linux-x86_64.sh +chmod 755 ./cmake-3.23.1-linux-x86_64.sh +sudo ./cmake-3.23.1-linux-x86_64.sh --prefix=/usr/ --skip-license +``` + +Install libzmq from source: +``` +wget https://github.com/zeromq/libzmq/archive/refs/tags/v4.3.4.zip +unzip v4.3.4.zip +cd libzmq-4.3.4 +mkdir build +cd build +cmake .. +make -j$(nproc) +sudo make install +sudo ldconfig +``` + +Install cppzmq from source: +``` +wget https://github.com/zeromq/cppzmq/archive/refs/tags/v4.8.1.zip +unzip v4.8.1.zip +cd cppzmq-4.8.1 +mkdir build +cd build +cmake .. +make -j$(nproc) +sudo make install +sudo ldconfig +``` + +Building Peerplays ``` -mkdir $HOME/src -cd $HOME/src git clone https://gitlab.com/PBSA/peerplays.git cd peerplays git submodule update --init --recursive @@ -62,10 +163,15 @@ sudo usermod -a -G docker $USER docker pull datasecuritynode/peerplays:latest ``` -### Building docker image manually +### Building docker images manually ``` -# Build docker image (from the project root, must be a docker group member) -docker build -t peerplays . +# Execute from the project root, must be a docker group member + +# Build docker image, using Ubuntu 20.04 base +docker build --no-cache -f Dockerfile -t peerplays . + +# Build docker image, using Ubuntu 18.04 base +docker build --no-cache -f Dockerfile.18.04 -t peerplays-18-04 . ``` ### Start docker image diff --git a/libraries/chain/include/graphene/chain/son_wallet_deposit_object.hpp b/libraries/chain/include/graphene/chain/son_wallet_deposit_object.hpp index ae68a64f..2a741743 100644 --- a/libraries/chain/include/graphene/chain/son_wallet_deposit_object.hpp +++ b/libraries/chain/include/graphene/chain/son_wallet_deposit_object.hpp @@ -18,7 +18,7 @@ namespace graphene { namespace chain { static const uint8_t type_id = son_wallet_deposit_object_type; time_point_sec timestamp; - uint32_t block_num; + uint32_t block_num = 0; sidechain_type sidechain = sidechain_type::unknown; std::string sidechain_uid; std::string sidechain_transaction_id; diff --git a/libraries/chain/include/graphene/chain/son_wallet_withdraw_object.hpp b/libraries/chain/include/graphene/chain/son_wallet_withdraw_object.hpp index d65f5cab..2e4380ba 100644 --- a/libraries/chain/include/graphene/chain/son_wallet_withdraw_object.hpp +++ b/libraries/chain/include/graphene/chain/son_wallet_withdraw_object.hpp @@ -18,7 +18,7 @@ namespace graphene { namespace chain { static const uint8_t type_id = son_wallet_withdraw_object_type; time_point_sec timestamp; - uint32_t block_num; + uint32_t block_num = 0; sidechain_type sidechain = sidechain_type::unknown; std::string peerplays_uid; std::string peerplays_transaction_id; diff --git a/libraries/plugins/peerplays_sidechain/sidechain_net_handler_bitcoin.cpp b/libraries/plugins/peerplays_sidechain/sidechain_net_handler_bitcoin.cpp index 583effde..bc7989f7 100644 --- a/libraries/plugins/peerplays_sidechain/sidechain_net_handler_bitcoin.cpp +++ b/libraries/plugins/peerplays_sidechain/sidechain_net_handler_bitcoin.cpp @@ -1079,8 +1079,10 @@ std::vector zmq_listener::receive_multipart() { void zmq_listener::handle_zmq() { int linger = 0; - socket.setsockopt(ZMQ_SUBSCRIBE, "hashblock", 9); - socket.setsockopt(ZMQ_LINGER, &linger, sizeof(linger)); + auto rc = zmq_setsockopt(socket, ZMQ_SUBSCRIBE, "hashblock", 9); + FC_ASSERT(rc); + rc = zmq_setsockopt(socket, ZMQ_LINGER, &linger, sizeof(linger)); + FC_ASSERT(rc); //socket.setsockopt( ZMQ_SUBSCRIBE, "hashtx", 6 ); //socket.setsockopt( ZMQ_SUBSCRIBE, "rawblock", 8 ); //socket.setsockopt( ZMQ_SUBSCRIBE, "rawtx", 5 );