Skip to content

Commit

Permalink
Merge pull request #241 from graft-project/rta-mining-rc
Browse files Browse the repository at this point in the history
RTA mining, release v1.7.0
  • Loading branch information
mbg033 authored Mar 14, 2019
2 parents fec3ac9 + 1de0f64 commit 4637bae
Show file tree
Hide file tree
Showing 122 changed files with 9,509 additions and 3,256 deletions.
49 changes: 47 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ cmake_minimum_required(VERSION 2.8.7)

project(graftnetwork)

set(DISABLE_SUPERNODE ${APPLE})

function (die msg)
if (NOT WIN32)
string(ASCII 27 Esc)
Expand All @@ -54,6 +52,38 @@ if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type" FORCE)
message(STATUS "Setting default build type: ${CMAKE_BUILD_TYPE}")
endif()

if(CMAKE_BUILD_TYPE MATCHES RelWithDebInfo)
message("==> The configuration is ${CMAKE_BUILD_TYPE}. Debug info will be extracted into separate files.")

function (add_executable _name)
_add_executable(${ARGV})

if (TARGET ${_name})
add_custom_command(TARGET ${_name} POST_BUILD
COMMAND echo "$<TARGET_FILE_NAME:${_name}>: extracting debug info"
COMMAND ${CMAKE_COMMAND} -E chdir $<TARGET_FILE_DIR:${_name}> objcopy --only-keep-debug "$<TARGET_FILE_NAME:${_name}>" "$<TARGET_FILE_NAME:${_name}>.debug"
COMMAND ${CMAKE_COMMAND} -E chdir $<TARGET_FILE_DIR:${_name}> strip --strip-debug --strip-unneeded "$<TARGET_FILE_NAME:${_name}>"
COMMAND ${CMAKE_COMMAND} -E chdir $<TARGET_FILE_DIR:${_name}> objcopy --add-gnu-debuglink="$<TARGET_FILE_NAME:${_name}>.debug" "$<TARGET_FILE_NAME:${_name}>"
)
endif()
endfunction()

function (add_library _name _type)
_add_library(${ARGV})

if (TARGET ${_name} AND ${_type} STREQUAL SHARED)
add_custom_command(TARGET ${_name} POST_BUILD
COMMAND echo "$<TARGET_FILE_NAME:${_name}>: extracting debug info"
COMMAND ${CMAKE_COMMAND} -E chdir $<TARGET_FILE_DIR:${_name}> objcopy --only-keep-debug "$<TARGET_FILE_NAME:${_name}>" "$<TARGET_FILE_NAME:${_name}>.debug"
COMMAND ${CMAKE_COMMAND} -E chdir $<TARGET_FILE_DIR:${_name}> strip --strip-debug --strip-unneeded "$<TARGET_FILE_NAME:${_name}>"
COMMAND ${CMAKE_COMMAND} -E chdir $<TARGET_FILE_DIR:${_name}> objcopy --add-gnu-debuglink="$<TARGET_FILE_NAME:${_name}>.debug" "$<TARGET_FILE_NAME:${_name}>"
)
endif()
endfunction()

endif(CMAKE_BUILD_TYPE MATCHES RelWithDebInfo)

string(TOLOWER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_LOWER)

# ARCH defines the target architecture, either by an explicit identifier or
Expand Down Expand Up @@ -109,6 +139,21 @@ endif()
set(CMAKE_C_FLAGS_RELEASE "-DNDEBUG ${OPT_FLAGS_RELEASE}")
set(CMAKE_CXX_FLAGS_RELEASE "-DNDEBUG ${OPT_FLAGS_RELEASE}")

if(NOT DEFINED CMAKE_ROOT_SOURCE_DIR)
# CMAKE_ROOT_SOURCE_DIR variable is required, because CMAKE_SOURCE_DIR works well for include like commands and does not for external projects
set(CMAKE_ROOT_SOURCE_DIR "${CMAKE_SOURCE_DIR}")
endif()

add_definitions(-DMONERO_DEFAULT_LOG_CATEGORY="cryptonode" -DCMAKE_ROOT_SOURCE_DIR="${CMAKE_ROOT_SOURCE_DIR}")

if(NOT DEFINED ENABLE_SYSLOG)
option(ENABLE_SYSLOG "SYSLOG support. It can be compiled for UNIX-like platforms only." OFF)
endif()

if(ENABLE_SYSLOG)
add_definitions(-DELPP_SYSLOG)
endif()

# set this to 0 if per-block checkpoint needs to be disabled
set(PER_BLOCK_CHECKPOINT 0)

Expand Down
18 changes: 16 additions & 2 deletions CMakeLists_IOS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,23 @@ set (CMAKE_C_OSX_CURRENT_VERSION_FLAG "-current_version ")
set (CMAKE_CXX_OSX_COMPATIBILITY_VERSION_FLAG "${CMAKE_C_OSX_COMPATIBILITY_VERSION_FLAG}")
set (CMAKE_CXX_OSX_CURRENT_VERSION_FLAG "${CMAKE_C_OSX_CURRENT_VERSION_FLAG}")

set(IOS_BITCODE 1)
set(IOS_BITCODE_MARKER 0)
set(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE ${IOS_BITCODE})
if(IOS_BITCODE)
set(CMAKE_XCODE_ATTRIBUTE_BITCODE_GENERATION_MODE "bitcode") # Without this, Xcode adds -fembed-bitcode-marker compile options instead of -fembed-bitcode set(CMAKE_C_FLAGS "-fembed-bitcode ${CMAKE_C_FLAGS}")
endif()
# ld: '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/arc/libarclite_iphonesimulator.a(arclite.o)' does not contain bitcode. You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE), obtain an updated library from the vendor, or disable bitcode for this target. for architecture x86_64

if(IOS_BITCODE)
set(BITCODE_FLAGS "-fembed-bitcode")
elseif(IOS_BITCODE_MARKER)
set(BITCODE_FLAGS "-fembed-bitcode-marker")
endif()

# Hidden visibilty is required for cxx on iOS
set (CMAKE_C_FLAGS_INIT "")
set (CMAKE_CXX_FLAGS_INIT "-fvisibility=hidden -fvisibility-inlines-hidden")
set (CMAKE_C_FLAGS_INIT "${BITCODE_FLAGS}")
set (CMAKE_CXX_FLAGS_INIT "${BITCODE_FLAGS} -fvisibility=hidden -fvisibility-inlines-hidden")

set (CMAKE_C_LINK_FLAGS "-Wl,-search_paths_first ${CMAKE_C_LINK_FLAGS}")
set (CMAKE_CXX_LINK_FLAGS "-Wl,-search_paths_first ${CMAKE_CXX_LINK_FLAGS}")
Expand Down
22 changes: 22 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,23 @@ cmake-release:
mkdir -p build/release
cd build/release && cmake -D CMAKE_BUILD_TYPE=Release ../..

cmake-release-syslog:
mkdir -p build/release
cd build/release && cmake -D CMAKE_BUILD_TYPE=Release -D ENABLE_SYSLOG=ON ../..

cmake-release-syslog-static:
mkdir -p build/release
cd build/release && cmake -D CMAKE_BUILD_TYPE=Release -D ENABLE_SYSLOG=ON -D STATIC=ON ../..

release: cmake-release
cd build/release && $(MAKE)

release-syslog: cmake-release-syslog
cd build/release && $(MAKE)

release-syslog-static: cmake-release-syslog-static
cd build/release && $(MAKE)

release-test:
mkdir -p build/release
cd build/release && cmake -D BUILD_TESTS=ON -D CMAKE_BUILD_TYPE=release ../.. && $(MAKE) && $(MAKE) test
Expand All @@ -66,6 +80,10 @@ release-static:
mkdir -p build/release
cd build/release && cmake -D STATIC=ON -D ARCH="x86-64" -D BUILD_64=ON -D CMAKE_BUILD_TYPE=release ../.. && $(MAKE)

release-static-locking:
mkdir -p build/release
cd build/release && cmake -D STATIC=ON -D ARCH="x86-64" -D BUILD_64=ON -D CMAKE_BUILD_TYPE=release ../.. && $(MAKE) CXX_FLAGS=-DLOCK_RTA_SENDING

coverage:
mkdir -p build/debug
cd build/debug && cmake -D BUILD_TESTS=ON -D CMAKE_BUILD_TYPE=Debug -D COVERAGE=ON ../.. && $(MAKE) && $(MAKE) test
Expand All @@ -92,6 +110,10 @@ release-static-linux-x86_64:
mkdir -p build/release
cd build/release && cmake -D STATIC=ON -D ARCH="x86-64" -D BUILD_64=ON -D CMAKE_BUILD_TYPE=release -D BUILD_TAG="linux-x64" ../.. && $(MAKE)

release-static-linux-x86_64-debug-info:
mkdir -p build/release
cd build/release && cmake -D STATIC=ON -D ARCH="x86-64" -D BUILD_64=ON -D CMAKE_BUILD_TYPE=RelWithDebInfo -D BUILD_TAG="linux-x64" ../.. && $(MAKE)

release-static-freebsd-x86_64:
mkdir -p build/release
cd build/release && cmake -D STATIC=ON -D ARCH="x86-64" -D BUILD_64=ON -D CMAKE_BUILD_TYPE=release -D BUILD_TAG="freebsd-x64" ../.. && $(MAKE)
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ Dates are provided in the format YYYY-MM-DD.
| 2018-09-17 | v10 | 1.4.4 | 1.4.5 | Block reward halved |
| 2018-10-31 | v11 | 1.5.0 | 1.5.1 | PoW algorithm from Monero v8 (CN v2), enabled checkpoints for mainnet |
| 2019-03-07 | v12 | 1.6.0 | 1.6.0 | Own PoW algorithm - CryptoNight V8 ReverseWaltz - tweaked from CryptoNight Monero v8 (CN v2) |
| 2019-03-18 | v13 | 1.7.0 | 1.7.0 | RTA Mining |

## Installing Graft Network from a Package

Expand Down Expand Up @@ -121,6 +122,8 @@ If you already have a repo cloned, initialize and update:

cd GraftNetwork && git submodule init && git submodule update



### Build instructions

Graft Network uses the CMake build system and a top-level [Makefile](Makefile) that
Expand Down
151 changes: 151 additions & 0 deletions contrib/epee/include/async_state_machine.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
#ifndef ASYNC_STATE_MACHINE_H
#define ASYNC_STATE_MACHINE_H

#include <memory>
#include <set>
#include <chrono>
#include <thread>
#include <functional>
#include <boost/asio.hpp>
#include <boost/bind.hpp>
#include <boost/thread.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/weak_ptr.hpp>
#include <boost/pointer_cast.hpp>

namespace cblp {

struct async_callback_state_machine : public boost::enable_shared_from_this<async_callback_state_machine>
{
enum call_result_type {
succesed,
failed,
aborted,
timeouted
};

typedef boost::function<void (const call_result_type&)> callback_type;

struct i_task : public boost::enable_shared_from_this<i_task>
{
virtual void exec() = 0;
virtual ~i_task() {}

boost::weak_ptr<boost::asio::deadline_timer> timer;
};

virtual bool start() = 0;

/// \brief creates state machine, it should be shared_ptr
static boost::shared_ptr<async_callback_state_machine> create(boost::asio::io_service& io_service,
int64_t timeout,
async_callback_state_machine::callback_type finalizer);

virtual ~async_callback_state_machine();

protected:
async_callback_state_machine(boost::asio::io_service& io_service
, int64_t timeout
, async_callback_state_machine::callback_type finalizer);

static void deadline_handler(const boost::system::error_code& ec,
boost::shared_ptr<async_callback_state_machine>& machine);


boost::asio::io_service& io_service;
boost::asio::io_service::strand strand;
int64_t timeout_msec;

boost::shared_ptr<boost::asio::deadline_timer> deadline_timer;
std::set<boost::shared_ptr<i_task> > scheduled_tasks;
std::set<boost::shared_ptr<boost::asio::deadline_timer>> active_timers;
callback_type final_callback;
std::chrono::high_resolution_clock::time_point timestamp;

public:
/// \brief schedule task to be executed (immediatelly)
/// \param task to execute
void schedule_task(boost::shared_ptr<i_task> task);

/// \brief schedule task to be executed in "timeout" milliseconds
/// \param task to execute
/// \param time interval
void schedule_task(boost::shared_ptr<i_task> task, int timeout);

/// \brief deactivate already scheduled task
/// \param task to deactivate, could be outside the list
/// of allready scheduled tasks
void unschedule_task(boost::weak_ptr<i_task> task);

/// \brief stop machine, deactivate all tasks, stops all timers
void stop(call_result_type result = call_result_type::aborted);

private:
struct weak_binder final
{
weak_binder(boost::shared_ptr<i_task>& task
, boost::shared_ptr<async_callback_state_machine> machine
= boost::shared_ptr<async_callback_state_machine>() )
: data(task)
, machine(machine)
{}

void operator ()() {
if ( boost::shared_ptr<i_task> ptr = data.lock() ) {
ptr->exec();
if (boost::shared_ptr<async_callback_state_machine> tmp = machine.lock())
tmp->remove_scheduled_task(ptr);
}
}
boost::weak_ptr<i_task> data;
boost::weak_ptr<async_callback_state_machine> machine;
};

struct timer_binder final
{
timer_binder(boost::shared_ptr<i_task>& task,
boost::shared_ptr<async_callback_state_machine> machine,
int64_t timeout_msec)
: data(task)
, machine(machine)
, timer(new boost::asio::deadline_timer(machine->io_service,
boost::posix_time::milliseconds(timeout_msec)))
{
boost::shared_ptr<i_task> tmp = this->data.lock();
if (tmp)
tmp->timer = timer;
}

void operator ()() {
if ( boost::shared_ptr<i_task> ptr = data.lock() ) {
ptr->exec();
if (boost::shared_ptr<async_callback_state_machine> tmp = machine.lock())
tmp->remove_scheduled_task(ptr);
}
}

static void timeout_handler(const boost::system::error_code& ec,
boost::shared_ptr<timer_binder>& binder)
{
if ( ec == boost::asio::error::operation_aborted )
return;
(*binder)();
}

boost::weak_ptr<i_task> data;
boost::weak_ptr<async_callback_state_machine> machine;
boost::shared_ptr<boost::asio::deadline_timer> timer;
};

friend struct weak_binder;
friend struct timer_binder;

void remove_scheduled_task(boost::shared_ptr<i_task>& ptr);

boost::recursive_mutex _mutex;
};


} // namespace cblp

#endif // ASYNC_STATE_MACHINE_H
Loading

0 comments on commit 4637bae

Please sign in to comment.