Ubuntu 18.04 build support

This commit is contained in:
serkixenos 2022-05-06 04:14:36 +02:00
parent 93b60efba5
commit e0d7a6314a
7 changed files with 350 additions and 18 deletions

View file

@ -22,6 +22,37 @@ endif()
list( APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules" ) 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 # function to help with cUrl
macro(FIND_CURL) macro(FIND_CURL)
if (NOT WIN32 AND NOT APPLE AND CURL_STATICLIB) if (NOT WIN32 AND NOT APPLE AND CURL_STATICLIB)

View file

@ -1,5 +1,5 @@
FROM ubuntu:20.04 FROM ubuntu:20.04
MAINTAINER PeerPlays Blockchain Standards Association MAINTAINER Peerplays Blockchain Standards Association
#=============================================================================== #===============================================================================
# Ubuntu setup # Ubuntu setup
@ -28,8 +28,8 @@ RUN \
libssl-dev \ libssl-dev \
libtool \ libtool \
libzip-dev \ libzip-dev \
libzmq3-dev \
locales \ locales \
lsb-release \
mc \ mc \
nano \ nano \
net-tools \ net-tools \
@ -40,6 +40,7 @@ RUN \
python3 \ python3 \
python3-jinja2 \ python3-jinja2 \
sudo \ sudo \
systemd-coredump \
wget wget
ENV HOME /home/peerplays ENV HOME /home/peerplays
@ -53,6 +54,38 @@ RUN echo 'peerplays:peerplays' | chpasswd
# SSH # SSH
EXPOSE 22 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 # Peerplays setup
#=============================================================================== #===============================================================================

160
Dockerfile.18.04 Normal file
View file

@ -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"]

130
README.md
View file

@ -6,24 +6,125 @@ This is a quick introduction to get new developers and witnesses up to speed on
# Building and Installation Instructions # 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: Following dependencies are needed for a clean install of Ubuntu 20.04:
``` ```
sudo apt-get install \ 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 \ dnsutils doxygen expect git graphviz libboost-all-dev libbz2-dev \
libcurl4-openssl-dev libncurses-dev libreadline-dev libsnappy-dev \ libcurl4-openssl-dev libncurses-dev libreadline-dev libsnappy-dev \
libssl-dev libtool libzip-dev libzmq3-dev locales mc nano net-tools ntp \ libssl-dev libtool libzip-dev locales lsb-release mc nano net-tools ntp \
openssh-server pkg-config perl python3 python3-jinja2 sudo wget openssh-server pkg-config perl python3 python3-jinja2 sudo \
systemd-coredump wget
``` ```
Install libzmq from source:
## Building Peerplays ```
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 git clone https://gitlab.com/PBSA/peerplays.git
cd peerplays cd peerplays
git submodule update --init --recursive git submodule update --init --recursive
@ -62,10 +163,15 @@ sudo usermod -a -G docker $USER
docker pull datasecuritynode/peerplays:latest 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) # Execute from the project root, must be a docker group member
docker build -t peerplays .
# 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 ### Start docker image

View file

@ -18,7 +18,7 @@ namespace graphene { namespace chain {
static const uint8_t type_id = son_wallet_deposit_object_type; static const uint8_t type_id = son_wallet_deposit_object_type;
time_point_sec timestamp; time_point_sec timestamp;
uint32_t block_num; uint32_t block_num = 0;
sidechain_type sidechain = sidechain_type::unknown; sidechain_type sidechain = sidechain_type::unknown;
std::string sidechain_uid; std::string sidechain_uid;
std::string sidechain_transaction_id; std::string sidechain_transaction_id;

View file

@ -18,7 +18,7 @@ namespace graphene { namespace chain {
static const uint8_t type_id = son_wallet_withdraw_object_type; static const uint8_t type_id = son_wallet_withdraw_object_type;
time_point_sec timestamp; time_point_sec timestamp;
uint32_t block_num; uint32_t block_num = 0;
sidechain_type sidechain = sidechain_type::unknown; sidechain_type sidechain = sidechain_type::unknown;
std::string peerplays_uid; std::string peerplays_uid;
std::string peerplays_transaction_id; std::string peerplays_transaction_id;

View file

@ -1079,8 +1079,10 @@ std::vector<zmq::message_t> zmq_listener::receive_multipart() {
void zmq_listener::handle_zmq() { void zmq_listener::handle_zmq() {
int linger = 0; int linger = 0;
socket.setsockopt(ZMQ_SUBSCRIBE, "hashblock", 9); auto rc = zmq_setsockopt(socket, ZMQ_SUBSCRIBE, "hashblock", 9);
socket.setsockopt(ZMQ_LINGER, &linger, sizeof(linger)); 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, "hashtx", 6 );
//socket.setsockopt( ZMQ_SUBSCRIBE, "rawblock", 8 ); //socket.setsockopt( ZMQ_SUBSCRIBE, "rawblock", 8 );
//socket.setsockopt( ZMQ_SUBSCRIBE, "rawtx", 5 ); //socket.setsockopt( ZMQ_SUBSCRIBE, "rawtx", 5 );