From e74c0e3e269cd8c0e80ba5f9028a45f6de774da1 Mon Sep 17 00:00:00 2001 From: anonimal Date: Tue, 5 Mar 2019 02:34:44 +0000 Subject: [PATCH 1/8] Makefile: add static and GUI targets, refactor --- Makefile | 49 +++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 41 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 7eff3b9e..b6183bed 100644 --- a/Makefile +++ b/Makefile @@ -13,7 +13,14 @@ cmake = cmake $(cmake_gen) cmake_debug = $(cmake) -D CMAKE_BUILD_TYPE=Debug cmake_release = $(cmake) -D CMAKE_BUILD_TYPE=Release -cmake_tests = $(cmake) -D BUILD_TESTS=ON + +cmake_gui = -D BUILD_GUI=ON +cmake_static = -D STATIC=ON +cmake_tests = -D BUILD_TESTS=ON + +gui: + $(eval command += $(cmake_release) $(cmake_gui)) + $(call CMAKE,$(dir_release),$(command)) && $(MAKE) # Helper macro define CMAKE @@ -30,16 +37,42 @@ release: $(eval command += $(cmake_release)) $(call CMAKE,$(dir_release),$(command)) && $(MAKE) -test-release: - $(eval command += $(cmake_release) $(cmake_tests)) - $(call CMAKE,$(dir_release),$(command)) && $(MAKE) && $(MAKE) test - -test: test-release - debug: $(eval command += $(cmake_debug)) $(call CMAKE,$(dir_debug),$(command)) && $(MAKE) +static: static-release +static-release: + $(eval command += $(cmake_release) $(cmake_static)) + $(call CMAKE,$(dir_release),$(command)) && $(MAKE) + +# +# GUI +# + +gui: gui-release +gui-release: + $(eval command += $(cmake_release) $(cmake_gui)) + $(call CMAKE,$(dir_release),$(command)) && $(MAKE) + +gui-debug: + $(eval command += $(cmake_debug) $(cmake_gui)) + $(call CMAKE,$(dir_debug),$(command)) && $(MAKE) + +gui-static: gui-release-static +gui-release-static: + $(eval command += $(cmake_release) $(cmake_gui) $(cmake_static)) + $(call CMAKE,$(dir_release),$(command)) && $(MAKE) + +# +# Tests +# + +test: test-release +test-release: + $(eval command += $(cmake_release) $(cmake_tests)) + $(call CMAKE,$(dir_release),$(command)) && $(MAKE) && $(MAKE) test + test-debug: $(eval command += $(cmake_debug) $(cmake_tests)) $(call CMAKE,$(dir_debug),$(command)) && $(MAKE) && $(MAKE) test @@ -50,4 +83,4 @@ clean: tags: ctags -R --sort=1 --c++-kinds=+p --fields=+iaS --extra=+q --language-force=C++ src contrib tests/gtest -.PHONY: all release test-release test all-debug debug test-debug clean tags +.PHONY: all release debug static static-release gui gui-release gui-static gui-release-static gui-debug test test-release test-debug clean tags From e9b1f78c45d36ea0f3a06a90fed39d8f4e8f7af2 Mon Sep 17 00:00:00 2001 From: anonimal Date: Tue, 5 Mar 2019 02:51:40 +0000 Subject: [PATCH 2/8] CMake: finish removal of OpenCL Officially removed in c6f1fb3b67bc143d2a035d14a1b19949dcb31bfe --- src/CMakeLists.txt | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 1da141da..7bfac1a6 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -98,9 +98,6 @@ endif() add_library(crypto ${CRYPTO}) -MESSAGE( STATUS "INCLUDING OpenCL_INCLUDE_DIRS: " ${OpenCL_INCLUDE_DIRS} ) -include_directories( ${OpenCL_INCLUDE_DIRS} ) - add_library(currency_core ${CURRENCY_CORE}) add_dependencies(currency_core version rpc ${PCH_LIB_NAME}) ENABLE_SHARED_PCH(CURRENCY_CORE) From be790c37775a67ac4d44114a6c718d141e659642 Mon Sep 17 00:00:00 2001 From: anonimal Date: Tue, 5 Mar 2019 03:20:28 +0000 Subject: [PATCH 3/8] README: updated Linux build deps/directions A preliminary cleanup for the Linux build. The GUI build still needs clarification so others can successfully build on their systems (in other words, these new directions aren't 100% full-proof yet). Note: build-essential should not be needed: "If you do not plan to build Debian packages, you don't need this package. Starting with dpkg (>= 1.14.18) this package is required for building Debian packages" --- README.md | 10 +++++----- utils/Zano.sh | 0 2 files changed, 5 insertions(+), 5 deletions(-) mode change 100644 => 100755 utils/Zano.sh diff --git a/README.md b/README.md index 8d8c7a58..07adf327 100644 --- a/README.md +++ b/README.md @@ -13,12 +13,12 @@ Building | [Qt](https://download.qt.io/archive/qt/) (only for GUI) | 5.8.0 | 5.9.1 | 5.10.1 | ### Linux + Recommended OS version: Ubuntu 17.04 LTS. - 1. Install dependencies: `sudo apt-get install build-essential git cmake unzip libicu-dev ocl-icd-opencl-dev mesa-common-dev libglu1-mesa-dev` - 2. Install Qt and Boost - 3. Set `BOOST_ROOT` and `QT_PREFIX_PATH` environment variables - 4. `mkdir build`
`cd build`
`cmake -DBUILD_GUI=FALSE -DSTATIC=TRUE ..`
`make` -5. In order to build GUI, revise and run script at `/utils/build_script_linux.sh` + +1. `$ sudo apt install git g++ cmake unzip libicu-dev mesa-common-dev libglu1-mesa-dev qt5-default qtwebengine5-dev` +2. `$ cd zano/ && make -j$(nproc) gui` +3. Look for the binaries, including the `Zano` GUI, in the build directory ### Windows Recommended OS version: Windows 7 x64. diff --git a/utils/Zano.sh b/utils/Zano.sh old mode 100644 new mode 100755 From 87dfca56a363557f89aec8f8cd667d267c6d1af4 Mon Sep 17 00:00:00 2001 From: "crypro.zoidberg" Date: Sat, 9 Mar 2019 02:12:10 +0100 Subject: [PATCH 4/8] extended limitations on NOTIFY_REQUEST_GET_OBJECTS --- src/currency_core/currency_config.h | 4 ++-- src/currency_protocol/currency_protocol_handler.inl | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/currency_core/currency_config.h b/src/currency_core/currency_config.h index 3f6684aa..71608c76 100644 --- a/src/currency_core/currency_config.h +++ b/src/currency_core/currency_config.h @@ -1,5 +1,4 @@ // Copyright (c) 2014-2018 Zano Project -// Copyright (c) 2014-2018 Zano Project // Copyright (c) 2014-2018 The Louisdor Project // Copyright (c) 2012-2013 The Cryptonote developers // Distributed under the MIT/X11 software license, see the accompanying @@ -98,7 +97,8 @@ #define BLOCKS_IDS_SYNCHRONIZING_DEFAULT_COUNT 2000 //by default, blocks ids count in synchronizing #define BLOCKS_SYNCHRONIZING_DEFAULT_COUNT 200 //by default, blocks count in blocks downloading #define BLOCKS_SYNCHRONIZING_DEFAULT_SIZE 2000000 //by default keep synchronizing packets not bigger then 2MB -#define CURRENCY_PROTOCOL_MAX_BLOCKS_REQUEST_COUNT 500 +#define CURRENCY_PROTOCOL_MAX_BLOCKS_REQUEST_COUNT 500 +#define CURRENCY_PROTOCOL_MAX_TXS_REQUEST_COUNT 500 #define CURRENCY_ALT_BLOCK_LIVETIME_COUNT (CURRENCY_BLOCKS_PER_DAY*7)//one week diff --git a/src/currency_protocol/currency_protocol_handler.inl b/src/currency_protocol/currency_protocol_handler.inl index 617fb862..0485525f 100644 --- a/src/currency_protocol/currency_protocol_handler.inl +++ b/src/currency_protocol/currency_protocol_handler.inl @@ -361,7 +361,8 @@ namespace currency LOG_PRINT_L2("[HANDLE]NOTIFY_REQUEST_GET_OBJECTS: arg.blocks.size() = " << arg.blocks.size() << ", arg.txs.size()="<< arg.txs.size()); LOG_PRINT_L3("[HANDLE]NOTIFY_REQUEST_GET_OBJECTS: " << ENDL << currency::print_kv_structure(arg)); - if (arg.blocks.size() > CURRENCY_PROTOCOL_MAX_BLOCKS_REQUEST_COUNT) + if (arg.blocks.size() > CURRENCY_PROTOCOL_MAX_BLOCKS_REQUEST_COUNT || + arg.txs.size() > CURRENCY_PROTOCOL_MAX_TXS_REQUEST_COUNT) { LOG_ERROR_CCONTEXT("Requested objects count is to big (" << arg.blocks.size() <<")expected not more then " << CURRENCY_PROTOCOL_MAX_BLOCKS_REQUEST_COUNT); m_p2p->drop_connection(context); From 26fa51e4c7e59429ca1020308f9f98f9b2864343 Mon Sep 17 00:00:00 2001 From: niXman Date: Sat, 9 Mar 2019 11:48:16 +0200 Subject: [PATCH 5/8] fix ZANO-74 bug fix ZANO-74 bug --- utils/setup_32.iss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/setup_32.iss b/utils/setup_32.iss index 9ed52239..e57a6838 100644 --- a/utils/setup_32.iss +++ b/utils/setup_32.iss @@ -31,7 +31,7 @@ WizardImageFile=../resources/installer_bg_164x313.bmp PrivilegesRequired=poweruser ;SetupIconFile=../resources/app.ico AppMutex=Zano_instance - +UninstallDisplayIcon={app}\{#MyAppExeName} [Languages] From 518bccc8564ba63d53ac2c4582a7148d504dc24f Mon Sep 17 00:00:00 2001 From: niXman Date: Sat, 9 Mar 2019 11:48:57 +0200 Subject: [PATCH 6/8] fix ZANO-74 bug fix ZANO-74 bug --- utils/setup_64.iss | 1 + 1 file changed, 1 insertion(+) diff --git a/utils/setup_64.iss b/utils/setup_64.iss index da27e26e..ff06e817 100644 --- a/utils/setup_64.iss +++ b/utils/setup_64.iss @@ -32,6 +32,7 @@ PrivilegesRequired=poweruser ArchitecturesAllowed=x64 ;SetupIconFile=../resources/app.ico AppMutex=Zano_instance +UninstallDisplayIcon={app}\{#MyAppExeName} [Languages] From db3fd44db7fadf74c81e9f2d7733faa5e8fc8061 Mon Sep 17 00:00:00 2001 From: "crypro.zoidberg" Date: Mon, 11 Mar 2019 19:37:46 +0100 Subject: [PATCH 7/8] added command line by default --- src/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7bfac1a6..ac57925c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -162,6 +162,8 @@ if(BUILD_GUI) set_property(TARGET Zano PROPERTY FOLDER "prog") set_target_properties(Zano PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/gui/qt-daemon/Info.plist.in) + set_target_properties(Zano PROPERTIES VS_DEBUGGER_COMMAND_ARGUMENTS "--html-path=${CMAKE_CURRENT_SOURCE_DIR}/gui/qt-daemon/html") + set(CMAKE_AUTOMOC OFF) endif() From 8ecde75e0d693b13773450e4a9e07772ef948d1d Mon Sep 17 00:00:00 2001 From: "crypro.zoidberg" Date: Mon, 11 Mar 2019 22:03:21 +0100 Subject: [PATCH 8/8] cleared up code --- src/crypto/wild_keccak.cpp | 55 +------------ src/crypto/wild_keccak.h | 154 +------------------------------------ 2 files changed, 3 insertions(+), 206 deletions(-) diff --git a/src/crypto/wild_keccak.cpp b/src/crypto/wild_keccak.cpp index c34216ee..fa49c539 100644 --- a/src/crypto/wild_keccak.cpp +++ b/src/crypto/wild_keccak.cpp @@ -4,6 +4,7 @@ // Memory-hard extension of keccak for PoW // Copyright (c) 2014 The Boolberry developers +// Copyright (c) 2019 The Hyle Team // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. @@ -77,46 +78,6 @@ namespace crypto } } - void mul_f::keccakf(uint64_t st[25], int rounds) - { - int i, j, round; - uint64_t t, bc[5]; - - for (round = 0; round < rounds; round++) { - - // Theta - for (i = 0; i < 5; i++) - { - bc[i] = st[i] ^ st[i + 5] ^ st[i + 10] * st[i + 15] * st[i + 20];//surprise - } - - for (i = 0; i < 5; i++) { - t = bc[(i + 4) % 5] ^ ROTL64(bc[(i + 1) % 5], 1); - for (j = 0; j < 25; j += 5) - st[j + i] ^= t; - } - - // Rho Pi - t = st[1]; - for (i = 0; i < 24; i++) { - j = keccakf_piln[i]; - bc[0] = st[j]; - st[j] = ROTL64(t, keccakf_rotc[i]); - t = bc[0]; - } - - // Chi - for (j = 0; j < 25; j += 5) { - for (i = 0; i < 5; i++) - bc[i] = st[j + i]; - for (i = 0; i < 5; i++) - st[j + i] ^= (~bc[(i + 1) % 5]) & bc[(i + 2) % 5]; - } - - // Iota - st[0] ^= keccakf_rndc[round]; - } - } bool generate_scratchpad(const crypto::hash& seed_data, std::vector& result_data, uint64_t target_size) { result_data.resize(target_size); @@ -128,20 +89,6 @@ namespace crypto return true; } -#define WK2_COUNT 0 - - bool generate_scratchpad2(const crypto::hash& seed_data, std::vector& result_data, uint64_t target_size) - { - CHECK_AND_ASSERT_THROW_MES(target_size % 10 == 0, "wrong target_size = " << target_size); - result_data.resize(target_size); - result_data[0] = crypto::cn_fast_hash(&seed_data, sizeof(seed_data)); - for (size_t i = 1; i < target_size; i++) - { - result_data[i] = crypto::cn_fast_hash(&result_data[i - 1], sizeof(result_data[i - 1])); - } - return true; - } - bool generate_scratchpad_light(const crypto::hash& seed_data, std::vector& result_data, uint64_t target_size) { CHECK_AND_ASSERT_THROW_MES(target_size % 10 == 0, "wrong target_size = " << target_size); diff --git a/src/crypto/wild_keccak.h b/src/crypto/wild_keccak.h index cfef801f..6dbba3f2 100644 --- a/src/crypto/wild_keccak.h +++ b/src/crypto/wild_keccak.h @@ -2,6 +2,7 @@ // 19-Nov-11 Markku-Juhani O. Saarinen // Copyright (c) 2014 The Boolberry developers +// Copyright (c) 2019 The Hyle Team // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. @@ -29,124 +30,9 @@ extern "C" { namespace crypto { -#define CONCAT_IMPL(x, y) x##y -#define CONCAT(x, y) CONCAT_IMPL(x, y) -#define UNIQUE(x) CONCAT(x, __LINE__) - -#define OPT_XOR_4_RES(A_, B_, C_, D_, Res) \ - crypto::hash UNIQUE(A) = A_;crypto::hash UNIQUE(B) = B_;crypto::hash UNIQUE(C) = C_; crypto::hash UNIQUE(D) = D_; \ - ((uint64_t*)&Res)[0] = ((const uint64_t*)&UNIQUE(A))[0] ^ ((const uint64_t*)&UNIQUE(B))[0] ^ ((const uint64_t*)&UNIQUE(C))[0] ^ ((const uint64_t*)&UNIQUE(D))[0]; \ - ((uint64_t*)&Res)[1] = ((const uint64_t*)&UNIQUE(A))[1] ^ ((const uint64_t*)&UNIQUE(B))[1] ^ ((const uint64_t*)&UNIQUE(C))[1] ^ ((const uint64_t*)&UNIQUE(D))[1]; \ - ((uint64_t*)&Res)[2] = ((const uint64_t*)&UNIQUE(A))[2] ^ ((const uint64_t*)&UNIQUE(B))[2] ^ ((const uint64_t*)&UNIQUE(C))[2] ^ ((const uint64_t*)&UNIQUE(D))[2]; \ - ((uint64_t*)&Res)[3] = ((const uint64_t*)&UNIQUE(A))[3] ^ ((const uint64_t*)&UNIQUE(B))[3] ^ ((const uint64_t*)&UNIQUE(C))[3] ^ ((const uint64_t*)&UNIQUE(D))[3]; - typedef uint64_t state_t_m[25]; typedef uint64_t mixin_t[KK_MIXIN_SIZE]; - //with multiplication, for tests - template - int keccak_generic(const uint8_t *in, size_t inlen, uint8_t *md, size_t mdlen) - { - state_t_m st; - uint8_t temp[144]; - size_t i, rsiz, rsizw; - - rsiz = sizeof(state_t_m) == mdlen ? HASH_DATA_AREA : 200 - 2 * mdlen; - rsizw = rsiz / 8; - - memset(st, 0, sizeof(st)); - - for ( ; inlen >= rsiz; inlen -= rsiz, in += rsiz) { - for (i = 0; i < rsizw; i++) - st[i] ^= ((uint64_t *) in)[i]; - f_traits::keccakf(st, KECCAK_ROUNDS); - } - - - // last block and padding - memcpy(temp, in, inlen); - temp[inlen++] = 1; - memset(temp + inlen, 0, rsiz - inlen); - temp[rsiz - 1] |= 0x80; - - for (i = 0; i < rsizw; i++) - st[i] ^= ((uint64_t *) temp)[i]; - - f_traits::keccakf(st, KECCAK_ROUNDS); - - memcpy(md, st, mdlen); - - return 0; - } - /*inline - void print_state(UINT64* state, const char* comment, size_t rount) - { - printf("master_funct: %s round: %d\r\n", comment, rount); - int i; - for(i = 0; i != 25; i++) - { - printf("[%i]: %p\r\n", i, state[i]); - } - }*/ - - template - int wild_keccak(const uint8_t *in, size_t inlen, uint8_t *md, size_t mdlen, callback_t cb) - { - state_t_m st; - uint8_t temp[144]; - uint64_t rsiz, rsizw; - - rsiz = sizeof(state_t_m) == mdlen ? HASH_DATA_AREA : 200 - 2 * mdlen; - rsizw = rsiz / 8; - memset(&st[0], 0, 25*sizeof(st[0])); - - - for ( ; inlen >= rsiz; inlen -= rsiz, in += rsiz) - { - for (size_t i = 0; i < rsizw; i++) - st[i] ^= ((uint64_t *) in)[i]; - - for(size_t ll = 0; ll != KECCAK_ROUNDS; ll++) - { - if(ll != 0) - {//skip first round - mixin_t mix_in; - cb(st, mix_in); - for (size_t k = 0; k < KK_MIXIN_SIZE; k++) - st[k] ^= mix_in[k]; - } - //print_state(&st[0], "before_permut", ll); - f_traits::keccakf(st, 1); - //print_state(&st[0], "after_permut", ll); - } - } - - // last block and padding - memcpy(temp, in, inlen); - temp[inlen++] = 1; - memset(temp + inlen, 0, rsiz - inlen); - temp[rsiz - 1] |= 0x80; - - for (size_t i = 0; i < rsizw; i++) - st[i] ^= ((uint64_t *) temp)[i]; - - for(size_t ll = 0; ll != KECCAK_ROUNDS; ll++) - { - if(ll != 0) - {//skip first state with - mixin_t mix_in; - cb(st, mix_in); - for (size_t k = 0; k < KK_MIXIN_SIZE; k++) - st[k] ^= mix_in[k]; - } - f_traits::keccakf(st, 1); - } - - memcpy(md, st, mdlen); - - return 0; - } - template int wild_keccak2(const uint8_t *in, size_t inlen, uint8_t *md, size_t mdlen, callback_t cb) { @@ -191,15 +77,6 @@ namespace crypto return 0; } - template - int wild_keccak_dbl(const uint8_t *in, size_t inlen, uint8_t *md, size_t mdlen, callback_t cb) - { - //Satoshi's classic - wild_keccak(in, inlen, md, mdlen, cb); - wild_keccak(md, mdlen, md, mdlen, cb); - return 0; - } - template int wild_keccak2_dbl(const uint8_t *in, size_t inlen, uint8_t *md, size_t mdlen, callback_t cb) { @@ -215,11 +92,7 @@ namespace crypto static void keccakf(uint64_t st[25], int rounds); }; - class mul_f - { - public: - static void keccakf(uint64_t st[25], int rounds); - }; + //------------------------------------------------------------------ inline @@ -284,30 +157,7 @@ namespace crypto return get_wild_keccak2(bd, res, scratchpad, scratchpad.size()); } //------------------------------------------------------------------ - inline - bool get_wild_keccak(const std::string& bd, crypto::hash& res, uint64_t height, const std::vector& scratchpad, uint64_t sz) - { - crypto::wild_keccak_dbl(reinterpret_cast(bd.data()), bd.size(), reinterpret_cast(&res), sizeof(res), [&](crypto::state_t_m& st, crypto::mixin_t& mix) - { - if (!height) - { - memset(&mix, 0, sizeof(mix)); - return; - } - -#define OPT_GET_H(index) scratchpad[st[index]%sz] -#define OPT_GET_M(index) scratchpad[mix[index]%sz] - - for (size_t i = 0; i != 6; i++) - { - OPT_XOR_4_RES(OPT_GET_H(i * 4), OPT_GET_H(i * 4 + 1), OPT_GET_H(i * 4 + 2), OPT_GET_H(i * 4 + 3), (*(crypto::hash*)&mix[i * 4])); - } - }); - return true; - } - //------------------------------------------------------------------ bool generate_scratchpad(const crypto::hash& source_data, std::vector& result_data, uint64_t target_size); - bool generate_scratchpad2(const crypto::hash& source_data, std::vector& result_data, uint64_t target_size); bool generate_scratchpad_light(const crypto::hash& seed_data, std::vector& result_data, uint64_t target_size); }