Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/develop' into block_processor/…
Browse files Browse the repository at this point in the history
…unchecked_push_front
  • Loading branch information
SergiySW committed Feb 27, 2020
2 parents 0cce090 + e107012 commit 2b467ab
Show file tree
Hide file tree
Showing 200 changed files with 11,146 additions and 5,884 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ qrc_resources.cpp
qt_system
resources.qrc.depends

# Autogenerated Flatbuffers source files
nano/ipc_flatbuffers_lib/generated/flatbuffers/nanoapi_generated.h

# CMake artifacts
_CPack_Packages
CPack*
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,6 @@
[submodule "nano-pow-server"]
path = nano-pow-server
url = https://github.com/nanocurrency/nano-pow-server.git
[submodule "flatbuffers"]
path = flatbuffers
url = https://github.com/google/flatbuffers.git
12 changes: 11 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ set (NANO_FUZZER_TEST OFF CACHE BOOL "")
option (NANO_STACKTRACE_BACKTRACE "Use BOOST_STACKTRACE_USE_BACKTRACE in stacktraces, for POSIX" OFF)
if (NANO_STACKTRACE_BACKTRACE)
add_definitions(-DNANO_STACKTRACE_BACKTRACE=1)
if (BACKTRACE_INCLUDE)
add_definitions(-DBOOST_STACKTRACE_BACKTRACE_INCLUDE_FILE=${BACKTRACE_INCLUDE})
endif()
endif ()

if (${NANO_TIMED_LOCKS} GREATER 0)
Expand Down Expand Up @@ -167,7 +170,11 @@ set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED ON)
#set(CMAKE_C_EXTENSIONS OFF)

set(CMAKE_CXX_STANDARD 14)
set(NANO_SUPPORTED_CPP_STANDARD "17" CACHE STRING "Supported C++ standard (14 or 17)")
if (CI_BUILD OR CI_TEST)
set(NANO_SUPPORTED_CPP_STANDARD "14")
endif()
set(CMAKE_CXX_STANDARD ${NANO_SUPPORTED_CPP_STANDARD})
set(CMAKE_CXX_STANDARD_REQUIRED ON)
#set(CMAKE_CXX_EXTENSIONS OFF)

Expand Down Expand Up @@ -235,6 +242,9 @@ endif ()
include_directories(cpptoml/include)
add_subdirectory(crypto/ed25519-donna)

add_subdirectory(nano/ipc_flatbuffers_lib)
add_subdirectory(nano/ipc_flatbuffers_test)

set (UPNPC_BUILD_SHARED OFF CACHE BOOL "")
add_subdirectory (miniupnp/miniupnpc EXCLUDE_FROM_ALL)
# FIXME: This fixes miniupnpc include directories without modifying miniupnpc's
Expand Down
256 changes: 256 additions & 0 deletions api/flatbuffers/nanoapi.fbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,256 @@
/*
Flatbuffer schema for the Nano IPC API.
Please see https://google.github.io/flatbuffers/md__schemas.html for recommended schema evolution practices.
*/
namespace nanoapi;

/** Returns the voting weight for the given account */
table AccountWeight {
/** A nano_ address */
account: string (required);
}

/** Response to AccountWeight */
table AccountWeightResponse {
/** Voting weight as a decimal number*/
voting_weight: string (required);
}

/**
* Block subtype for state blocks.
* Note that the node makes no distinction between open and receive subtypes.
*/
enum BlockSubType: byte {
invalid = 0,
receive,
send,
change,
epoch
}

/** Block union */
union Block {
BlockState,
BlockOpen,
BlockReceive,
BlockSend,
BlockChange
}

table BlockOpen {
/** Hash of this block */
hash: string;
/** Account being opened */
account: string;
/** Hash of send block */
source: string;
/** Representative address */
representative: string;
/** Signature as a hex string */
signature: string;
/** Work is a hex string representing work. This is a string as the work value may not fit in native numeric types. */
work: string;
}

table BlockReceive {
/** Hash of this block */
hash: string;
/** Hash of previous block */
previous: string;
/** Source hash */
source: string;
/** Signature as a hex string */
signature: string;
/** Work is a hex string representing work. This is a string as the work value may not fit in native numeric types. */
work: string;
}

table BlockSend {
/** Hash of this block */
hash: string;
/** Hash of previous block */
previous: string;
/** Destination account */
destination: string;
/** Balance in raw */
balance: string;
/** Signature as a hex string */
signature: string;
/** Work is a hex string representing work. This is a string as the work value may not fit in native numeric types. */
work: string;
}

table BlockChange {
/** Hash of this block */
hash: string;
/** Hash of previous block */
previous: string;
/** Representative address */
representative: string;
/** Signature as a hex string */
signature: string;
/** Work is a hex string representing work. This is a string as the work value may not fit in native numeric types. */
work: string;
}

table BlockState {
/** Hash of this block */
hash: string;
/** Account as nano_ string */
account: string;
/** Hash of previous block */
previous: string;
/** Representative as nano_ string */
representative: string;
/** Balance in raw */
balance: string;
/** Link as a hex string */
link: string;
/** Link interpreted as a nano_ address */
link_as_account: string;
/** Signature as a hex string */
signature: string;
/** Work is a hex string representing work. This is a string as the work value may not fit in native numeric types. */
work: string;
/** Subtype of this state block */
subtype: BlockSubType;
}

/** Information about a block */
table BlockInfo {
block: Block;
}

/** Called by a service (usually an external process) to register itself */
table ServiceRegister {
service_name: string;
}

/** Request the node to send an EventServiceStop event to the given service */
table ServiceStop {
/** Name of service to stop. */
service_name: string (required);
/** If true, restart the service */
restart: bool = false;
}

/**
* Subscribe or unsubscribe to EventServiceStop events.
* The service must first have registered itself on the same session.
*/
table TopicServiceStop {
/** Set to true to unsubscribe */
unsubscribe: bool;
}

/** Sent to a service to request it to stop itself */
table EventServiceStop {
}

/**
* All subscriptions are acknowledged. Use the envelope's correlation id
* if you need to match the ack with the subscription.
*/
table EventAck {
}

/** Requested confirmation type */
enum TopicConfirmationTypeFilter : byte { all, active, active_quorum, active_confirmation_height, inactive }

/** Type of block confirmation */
enum TopicConfirmationType : byte { active_quorum, active_confirmation_height, inactive }

/** Subscribe or unsubscribe to block confirmations of type EventConfirmation */
table TopicConfirmation {
/** Set to true to unsubscribe */
unsubscribe: bool;
options: TopicConfirmationOptions;
}

table TopicConfirmationOptions {
confirmation_type_filter: TopicConfirmationTypeFilter = all;
all_local_accounts: bool;
accounts: [string];
include_block: bool = true;
include_election_info: bool = true;
}

/** Notification of block confirmation. */
table EventConfirmation {
confirmation_type: TopicConfirmationType;
account: string;
amount: string;
hash: string;
block: Block;
election_info: ElectionInfo;
}

table ElectionInfo {
duration: uint64;
time: uint64;
tally: string;
request_count: uint64;
block_count: uint64;
voter_count: uint64;
}

/** Error response. All fields are optional */
table Error {
/** Error code. May be negative or positive. */
code: int;
/** Error category code */
category: int;
/** Error message */
message: string;
}

/**
* A general purpose success response for messages that don't return a message.
* The response includes an optional message text.
*/
table Success {
message: string;
}

/** IsAlive request and response. Any node issues will be reported through an error in the envelope. */
table IsAlive {
}

/**
* A union is the idiomatic way in Flatbuffers to transmit messages of multiple types.
* All top-level message types (including response types) must be listed here.
* @warning To ensure compatibility, only append and deprecate message types.
*/
union Message {
Error,
Success,
IsAlive,
EventAck,
BlockInfo,
AccountWeight,
AccountWeightResponse,
TopicConfirmation,
EventConfirmation,
ServiceRegister,
ServiceStop,
TopicServiceStop,
EventServiceStop
}

/**
* All messages are wrapped in an envelope which contains information such as
* message type, credentials and correlation id. For responses, the message may be an Error.
*/
table Envelope {
/** Milliseconds since epoch when the message was sent. */
time: uint64;
/** An optional and arbitrary string used for authentication. The corresponding http header for api keys is "nano-api-key" */
credentials: string;
/** Correlation id is an optional and arbitrary string. The corresponding http header is "nano-correlation-id" */
correlation_id: string;
/** The contained message. A 'message_type' property will be automatically added to JSON messages. */
message: Message;
}

/** The Envelope is the type marshalled over IPC, and also serves as the top-level JSON type */
root_type Envelope;
3 changes: 1 addition & 2 deletions ci/actions/windows/build.ps1
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# Stop immediately if any error happens
$ErrorActionPreference = "Stop"
$ErrorActionPreference = "Continue"

if (${env:artifact} -eq 1) {
if ( ${env:BETA} -eq 1 ) {
Expand Down
3 changes: 1 addition & 2 deletions ci/actions/windows/deploy.ps1
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# Stop immediately if any error happens
$ErrorActionPreference = "Stop"
$ErrorActionPreference = "Continue"

if ( ${env:BETA} -eq 1 ) {
$network_cfg="beta"
Expand Down
2 changes: 2 additions & 0 deletions ci/actions/windows/disable_windows_defender.ps1
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
$ErrorActionPreference = "Continue"

Set-MpPreference -DisableArchiveScanning $true
Set-MpPreference -DisableRealtimeMonitoring $true
Set-MpPreference -DisableBehaviorMonitoring $true
2 changes: 2 additions & 0 deletions ci/actions/windows/install_deps.ps1
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
$ErrorActionPreference = "Continue"

function Get-RedirectedUri {
<#
.SYNOPSIS
Expand Down
2 changes: 2 additions & 0 deletions ci/actions/windows/signing.ps1
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
$ErrorActionPreference = "Continue"

if (Test-Path env:CSC_LINK) {
$path = Join-Path -Path "$env:TMP" -ChildPath csc.p12
[IO.File]::WriteAllBytes($path, [Convert]::FromBase64String($env:CSC_LINK))
Expand Down
18 changes: 16 additions & 2 deletions ci/build-travis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,22 @@ OS=`uname`

# This is to prevent out of scope access in async_write from asio which is not picked up by static analysers
if [[ $(grep -rl --exclude="*asio.hpp" "asio::async_write" ./nano) ]]; then
echo "using boost::asio::async_write directly is not permitted (except in nano/lib/asio.hpp). Use nano::async_write instead"
echo "Using boost::asio::async_write directly is not permitted (except in nano/lib/asio.hpp). Use nano::async_write instead"
exit 1
fi

# prevent unsolicited use of std::lock_guard & std::unique_lock outside of allowed areas
if [[ $(grep -rl --exclude={"*random_pool.cpp","*random_pool.hpp","*random_pool_shuffle.hpp","*locks.hpp","*locks.cpp"} "std::unique_lock\|std::lock_guard\|std::condition_variable" ./nano) ]]; then
echo "using std::unique_lock, std::lock_guard or std::condition_variable is not permitted (except in nano/lib/locks.hpp and non-nano dependent libraries). Use the nano::* versions instead"
echo "Using std::unique_lock, std::lock_guard or std::condition_variable is not permitted (except in nano/lib/locks.hpp and non-nano dependent libraries). Use the nano::* versions instead"
exit 1
fi

if [[ $(grep -rlP "^\s*assert \(" ./nano) ]]; then
echo "Using assert is not permitted. Use debug_assert instead."
exit 1
fi

# prevent unsolicited use of std::lock_guard & std::unique_lock outside of allowed areas
mkdir build
pushd build

Expand All @@ -44,8 +50,15 @@ ulimit -S -n 8192
if [[ "$OS" == 'Linux' ]]; then
ROCKSDB="-DROCKSDB_LIBRARIES=/tmp/rocksdb/lib/librocksdb.a \
-DROCKSDB_INCLUDE_DIRS=/tmp/rocksdb/include"
if clang --version; then
BACKTRACE="-DNANO_STACKTRACE_BACKTRACE=ON \
-DBACKTRACE_INCLUDE=</tmp/backtrace.h>"
else
BACKTRACE="-DNANO_STACKTRACE_BACKTRACE=ON"
fi
else
ROCKSDB=""
BACKTRACE=""
fi

cmake \
Expand All @@ -61,6 +74,7 @@ cmake \
-DBOOST_ROOT=/tmp/boost/ \
-DQt5_DIR=${qt_dir} \
-DCI_TEST="1" \
${BACKTRACE} \
${SANITIZERS} \
..

Expand Down
Loading

0 comments on commit 2b467ab

Please sign in to comment.