From 9f91b217009b454befde9d0649b70809f3199e75 Mon Sep 17 00:00:00 2001 From: Srdjan Obucina Date: Tue, 10 Sep 2019 17:12:01 +0200 Subject: [PATCH 1/3] Peerplays SON plugin skeleton --- libraries/plugins/CMakeLists.txt | 1 + .../peerplays_sidechain/CMakeLists.txt | 19 ++++++ .../peerplays_sidechain_plugin.hpp | 34 +++++++++++ .../peerplays_sidechain_plugin.cpp | 59 +++++++++++++++++++ programs/witness_node/CMakeLists.txt | 2 +- programs/witness_node/main.cpp | 2 + 6 files changed, 116 insertions(+), 1 deletion(-) create mode 100644 libraries/plugins/peerplays_sidechain/CMakeLists.txt create mode 100644 libraries/plugins/peerplays_sidechain/include/graphene/peerplays_sidechain/peerplays_sidechain_plugin.hpp create mode 100644 libraries/plugins/peerplays_sidechain/peerplays_sidechain_plugin.cpp diff --git a/libraries/plugins/CMakeLists.txt b/libraries/plugins/CMakeLists.txt index 01079fe29..fb944627d 100644 --- a/libraries/plugins/CMakeLists.txt +++ b/libraries/plugins/CMakeLists.txt @@ -9,3 +9,4 @@ add_subdirectory( generate_genesis ) add_subdirectory( generate_uia_sharedrop_genesis ) add_subdirectory( debug_witness ) add_subdirectory( snapshot ) +add_subdirectory( peerplays_sidechain ) diff --git a/libraries/plugins/peerplays_sidechain/CMakeLists.txt b/libraries/plugins/peerplays_sidechain/CMakeLists.txt new file mode 100644 index 000000000..916487e3c --- /dev/null +++ b/libraries/plugins/peerplays_sidechain/CMakeLists.txt @@ -0,0 +1,19 @@ +file(GLOB HEADERS "include/graphene/peerplays_sidechain_history/*.hpp") + +add_library( peerplays_sidechain + peerplays_sidechain_plugin.cpp + ) + +target_link_libraries( peerplays_sidechain graphene_chain graphene_app ) +target_include_directories( peerplays_sidechain + PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" ) + +install( TARGETS + peerplays_sidechain + + RUNTIME DESTINATION bin + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib +) +INSTALL( FILES ${HEADERS} DESTINATION "include/graphene/peerplays_sidechain" ) + diff --git a/libraries/plugins/peerplays_sidechain/include/graphene/peerplays_sidechain/peerplays_sidechain_plugin.hpp b/libraries/plugins/peerplays_sidechain/include/graphene/peerplays_sidechain/peerplays_sidechain_plugin.hpp new file mode 100644 index 000000000..d32fb09d5 --- /dev/null +++ b/libraries/plugins/peerplays_sidechain/include/graphene/peerplays_sidechain/peerplays_sidechain_plugin.hpp @@ -0,0 +1,34 @@ +#pragma once + +#include +#include +#include + +#include + +namespace graphene { namespace peerplays_sidechain { +using namespace chain; + +namespace detail +{ + class peerplays_sidechain_plugin_impl; +} + +class peerplays_sidechain_plugin : public graphene::app::plugin +{ + public: + peerplays_sidechain_plugin(); + virtual ~peerplays_sidechain_plugin(); + + std::string plugin_name()const override; + virtual void plugin_set_program_options( + boost::program_options::options_description& cli, + boost::program_options::options_description& cfg) override; + virtual void plugin_initialize(const boost::program_options::variables_map& options) override; + virtual void plugin_startup() override; + + std::unique_ptr my; +}; + +} } //graphene::peerplays_sidechain_plugin + diff --git a/libraries/plugins/peerplays_sidechain/peerplays_sidechain_plugin.cpp b/libraries/plugins/peerplays_sidechain/peerplays_sidechain_plugin.cpp new file mode 100644 index 000000000..071905ece --- /dev/null +++ b/libraries/plugins/peerplays_sidechain/peerplays_sidechain_plugin.cpp @@ -0,0 +1,59 @@ +#include + +namespace graphene { namespace peerplays_sidechain { + +namespace detail +{ + + +class peerplays_sidechain_plugin_impl +{ + public: + peerplays_sidechain_plugin_impl(peerplays_sidechain_plugin& _plugin) + : _self( _plugin ) + { } + virtual ~peerplays_sidechain_plugin_impl(); + + peerplays_sidechain_plugin& _self; +}; + +peerplays_sidechain_plugin_impl::~peerplays_sidechain_plugin_impl() +{ + return; +} + +} // end namespace detail + +peerplays_sidechain_plugin::peerplays_sidechain_plugin() : + my( new detail::peerplays_sidechain_plugin_impl(*this) ) +{ +} + +peerplays_sidechain_plugin::~peerplays_sidechain_plugin() +{ + return; +} + +std::string peerplays_sidechain_plugin::plugin_name()const +{ + return "peerplays_sidechain"; +} + +void peerplays_sidechain_plugin::plugin_set_program_options( + boost::program_options::options_description& /*cli*/, + boost::program_options::options_description& /*cfg*/ + ) +{ +} + +void peerplays_sidechain_plugin::plugin_initialize(const boost::program_options::variables_map& /*options*/) +{ + ilog("peerplays sidechain plugin: plugin_initialize()"); +} + +void peerplays_sidechain_plugin::plugin_startup() +{ + ilog("peerplays sidechain plugin: plugin_startup()"); +} + +} } diff --git a/programs/witness_node/CMakeLists.txt b/programs/witness_node/CMakeLists.txt index 3d03253b3..e43172a0f 100644 --- a/programs/witness_node/CMakeLists.txt +++ b/programs/witness_node/CMakeLists.txt @@ -11,7 +11,7 @@ endif() # We have to link against graphene_debug_witness because deficiency in our API infrastructure doesn't allow plugins to be fully abstracted #246 target_link_libraries( witness_node - PRIVATE graphene_app graphene_account_history graphene_affiliate_stats graphene_market_history graphene_witness graphene_chain graphene_debug_witness graphene_bookie graphene_egenesis_full fc ${CMAKE_DL_LIBS} ${PLATFORM_SPECIFIC_LIBS} ) + PRIVATE graphene_app graphene_account_history graphene_affiliate_stats graphene_market_history graphene_witness graphene_chain graphene_debug_witness graphene_bookie graphene_egenesis_full fc peerplays_sidechain ${CMAKE_DL_LIBS} ${PLATFORM_SPECIFIC_LIBS} ) # also add dependencies to graphene_generate_genesis graphene_generate_uia_sharedrop_genesis if you want those plugins install( TARGETS diff --git a/programs/witness_node/main.cpp b/programs/witness_node/main.cpp index 34b22a2fd..c9a09ca39 100644 --- a/programs/witness_node/main.cpp +++ b/programs/witness_node/main.cpp @@ -31,6 +31,7 @@ //#include #include #include +#include #include //#include @@ -91,6 +92,7 @@ int main(int argc, char** argv) { auto list_plug = node->register_plugin(); auto affiliate_stats_plug = node->register_plugin(); auto bookie_plug = node->register_plugin(); + auto peerplays_sidechain = node->register_plugin(); // auto snapshot_plug = node->register_plugin(); try From 8f317e93d661d8256864a8316dd7a4f209829cc2 Mon Sep 17 00:00:00 2001 From: S Date: Wed, 11 Sep 2019 15:37:44 +0200 Subject: [PATCH 2/3] Fix building on Ubuntu 18.04 with GCC 7 --- .dockerignore | 2 + CMakeLists.txt | 6 +- Dockerfile | 59 ++++++++++++------- README.md | 38 ++++++++++-- .../graphene/chain/vesting_balance_object.hpp | 4 +- libraries/net/CMakeLists.txt | 2 +- libraries/wallet/CMakeLists.txt | 2 +- 7 files changed, 83 insertions(+), 30 deletions(-) create mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000000000..9ef96044f --- /dev/null +++ b/.dockerignore @@ -0,0 +1,2 @@ +build + diff --git a/CMakeLists.txt b/CMakeLists.txt index 20d96a9a2..595e1cc03 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -119,7 +119,11 @@ else( WIN32 ) # Apple AND Linux message( STATUS "Configuring BitShares on Linux" ) set( CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -std=c++11 -Wall" ) set( rt_library rt ) - set( pthread_library pthread) + #set( pthread_library pthread) + set(CMAKE_LINKER_FLAGS "-pthread" CACHE STRING "Linker Flags" FORCE) + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_LINKER_FLAGS}" CACHE STRING "" FORCE) + set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_LINKER_FLAGS}" CACHE STRING "" FORCE) + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_LINKER_FLAGS}" CACHE STRING "" FORCE) if ( NOT DEFINED crypto_library ) # I'm not sure why this is here, I guess someone has openssl and can't detect it with find_package()? # if you have a normal install, you can define crypto_library to the empty string to avoid a build error diff --git a/Dockerfile b/Dockerfile index a3cc326af..8a970e39e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,44 +1,63 @@ -FROM phusion/baseimage:0.9.19 +FROM ubuntu:18.04 MAINTAINER PeerPlays Blockchain Standards Association -ENV LANG=en_US.UTF-8 +ENV LANG en_US.UTF-8 +ENV LANGUAGE en_US.UTF-8 +ENV LC_ALL en_US.UTF-8 + RUN \ apt-get update -y && \ - apt-get install -y \ - g++ \ + DEBIAN_FRONTEND=noninteractive apt-get install -y \ autoconf \ + bash \ + build-essential \ + ca-certificates \ cmake \ + doxygen \ git \ + graphviz \ libbz2-dev \ - libreadline-dev \ - libboost-all-dev \ libcurl4-openssl-dev \ - libssl-dev \ libncurses-dev \ - doxygen \ - ca-certificates \ + libreadline-dev \ + libssl-dev \ + libtool \ + locales \ + ntp \ + pkg-config \ + wget \ && \ - apt-get update -y && \ - apt-get install -y fish && \ apt-get clean && \ rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* +RUN \ + sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen && \ + locale-gen + +# Compile Boost +RUN \ + BOOST_ROOT=$HOME/boost_1_67_0 && \ + wget -c 'http://sourceforge.net/projects/boost/files/boost/1.67.0/boost_1_67_0.tar.gz/download' -O boost_1_67_0.tar.gz &&\ + tar -zxvf boost_1_67_0.tar.gz && \ + cd boost_1_67_0/ && \ + ./bootstrap.sh "--prefix=$BOOST_ROOT" && \ + ./b2 install && \ + cd .. + ADD . /peerplays-core WORKDIR /peerplays-core -# Compile +# Compile Peerplays RUN \ - ( git submodule sync --recursive || \ - find `pwd` -type f -name .git | \ - while read f; do \ - rel="$(echo "${f#$PWD/}" | sed 's=[^/]*/=../=g')"; \ - sed -i "s=: .*/.git/=: $rel/=" "$f"; \ - done && \ - git submodule sync --recursive ) && \ + BOOST_ROOT=$HOME/boost_1_67_0 && \ git submodule update --init --recursive && \ + mkdir build && \ + mkdir build/release && \ + cd build/release && \ cmake \ + -DBOOST_ROOT="$BOOST_ROOT" \ -DCMAKE_BUILD_TYPE=Release \ - . && \ + ../.. && \ make witness_node cli_wallet && \ install -s programs/witness_node/witness_node programs/cli_wallet/cli_wallet /usr/local/bin && \ # diff --git a/README.md b/README.md index a6f9cf265..8207bb299 100644 --- a/README.md +++ b/README.md @@ -32,16 +32,44 @@ cd boost_1_67_0/ ## Building Peerplays ``` -export BOOST_ROOT=/root/boost_1_67_0 -export CC=gcc-5 ; export CXX=g++-5 cd $HOME/src +export BOOST_ROOT=$HOME/src/boost_1_67_0 git clone https://github.com/peerplays-network/peerplays.git -mkdir $HOME/peerplays/build; cd $HOME/src/peerplays/build +cd peerplays git submodule update --init --recursive -cmake -DBOOST_ROOT="$BOOST_ROOT" -DCMAKE_BUILD_TYPE=Release .. +cmake -DBOOST_ROOT="$BOOST_ROOT" -DCMAKE_BUILD_TYPE=Release make -j$(nproc) -ake install # this can install the executable files under /usr/local +make install # this can install the executable files under /usr/local +``` + +docker build -t peerplays . + +## Docker image + +``` +# Install docker +sudo apt install docker.io + + +# Add current user to docker group +sudo usermod -a -G docker $USER +# You need to restart your shell session, to apply group membership +# Type 'groups' to verify that you are a member of a docker group + + +# Build docker image (from the project root, must be a docker group member) +docker build -t peerplays . + + +# Start docker image +docker start peerplays + +# Exposed ports +# # rpc service: +# EXPOSE 8090 +# # p2p service: +# EXPOSE 1776 ``` Rest of the instructions on starting the chain remains same. diff --git a/libraries/chain/include/graphene/chain/vesting_balance_object.hpp b/libraries/chain/include/graphene/chain/vesting_balance_object.hpp index 6e0bd689a..b2b2e7a29 100644 --- a/libraries/chain/include/graphene/chain/vesting_balance_object.hpp +++ b/libraries/chain/include/graphene/chain/vesting_balance_object.hpp @@ -189,9 +189,9 @@ namespace graphene { namespace chain { ordered_non_unique< tag, composite_key< vesting_balance_object, - member_offset, + member_offset, member, - member_offset + member_offset //member //member_offset >, diff --git a/libraries/net/CMakeLists.txt b/libraries/net/CMakeLists.txt index 39f9cd05c..7aa617d77 100644 --- a/libraries/net/CMakeLists.txt +++ b/libraries/net/CMakeLists.txt @@ -13,7 +13,7 @@ target_link_libraries( graphene_net PUBLIC fc graphene_db ) target_include_directories( graphene_net PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" - PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../chain/include" + PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../chain/include" "${CMAKE_CURRENT_BINARY_DIR}/../chain/include" ) if(MSVC) diff --git a/libraries/wallet/CMakeLists.txt b/libraries/wallet/CMakeLists.txt index 74b9f7c55..8c9f87907 100644 --- a/libraries/wallet/CMakeLists.txt +++ b/libraries/wallet/CMakeLists.txt @@ -10,7 +10,7 @@ if( PERL_FOUND AND DOXYGEN_FOUND AND NOT "${CMAKE_GENERATOR}" STREQUAL "Ninja" ) COMMAND ${DOXYGEN_EXECUTABLE} DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile include/graphene/wallet/wallet.hpp ) add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/api_documentation.cpp - COMMAND PERLLIB=${CMAKE_CURRENT_SOURCE_DIR} ${PERL_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/generate_api_documentation.pl ${CMAKE_CURRENT_BINARY_DIR}/api_documentation.cpp.new + COMMAND PERLLIB=${CMAKE_CURRENT_BINARY_DIR} ${PERL_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/generate_api_documentation.pl ${CMAKE_CURRENT_BINARY_DIR}/api_documentation.cpp.new COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_BINARY_DIR}/api_documentation.cpp.new ${CMAKE_CURRENT_BINARY_DIR}/api_documentation.cpp COMMAND ${CMAKE_COMMAND} -E remove ${CMAKE_CURRENT_BINARY_DIR}/api_documentation.cpp.new From 60eb4272bfd1046770cf696a54cd0250a613797d Mon Sep 17 00:00:00 2001 From: Srdjan Obucina Date: Wed, 11 Sep 2019 19:59:32 +0200 Subject: [PATCH 3/3] SON tests skeleton --- tests/CMakeLists.txt | 4 ++++ .../peerplays_sidechain_tests.cpp | 20 +++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 tests/peerplays_sidechain/peerplays_sidechain_tests.cpp diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 57a451aa8..fef122b5d 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -33,6 +33,10 @@ file(GLOB BETTING_TESTS "betting/*.cpp") add_executable( betting_test ${BETTING_TESTS} ${COMMON_SOURCES} ) target_link_libraries( betting_test graphene_chain graphene_app graphene_account_history graphene_bookie graphene_egenesis_none fc graphene_wallet ${PLATFORM_SPECIFIC_LIBS} ) +file(GLOB PEERPLAYS_SIDECHAIN_TESTS "peerplays_sidechain/*.cpp") +add_executable( peerplays_sidechain_test ${PEERPLAYS_SIDECHAIN_TESTS} ${COMMON_SOURCES} ) +target_link_libraries( peerplays_sidechain_test graphene_chain graphene_app graphene_account_history graphene_bookie graphene_egenesis_none fc graphene_wallet ${PLATFORM_SPECIFIC_LIBS} ) + file(GLOB TOURNAMENT_TESTS "tournament/*.cpp") add_executable( tournament_test ${TOURNAMENT_TESTS} ${COMMON_SOURCES} ) target_link_libraries( tournament_test graphene_chain graphene_app graphene_account_history graphene_egenesis_none fc ${PLATFORM_SPECIFIC_LIBS} ) diff --git a/tests/peerplays_sidechain/peerplays_sidechain_tests.cpp b/tests/peerplays_sidechain/peerplays_sidechain_tests.cpp new file mode 100644 index 000000000..8c4db6df4 --- /dev/null +++ b/tests/peerplays_sidechain/peerplays_sidechain_tests.cpp @@ -0,0 +1,20 @@ +#include + +#define BOOST_TEST_MODULE Peerplays SON Tests + +BOOST_AUTO_TEST_CASE(peerplays_sidechain) +{ + +} + +#include +#include +#include + +boost::unit_test::test_suite* init_unit_test_suite(int argc, char* argv[]) { + std::srand(time(NULL)); + std::cout << "Random number generator seeded to " << time(NULL) << std::endl; + + return nullptr; +} +