From 29d8170709fb93fccf0fe78db416c20ce5d69793 Mon Sep 17 00:00:00 2001 From: alfredmox <> Date: Tue, 22 Jan 2019 03:34:09 -0800 Subject: [PATCH 1/8] concurrency tests --- tests/functional_tests/core_concurrency_test.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/functional_tests/core_concurrency_test.cpp b/tests/functional_tests/core_concurrency_test.cpp index 23bb8885..11594763 100644 --- a/tests/functional_tests/core_concurrency_test.cpp +++ b/tests/functional_tests/core_concurrency_test.cpp @@ -101,14 +101,17 @@ bool generate_events(currency::core& c, cct_events_t& events, const cct_wallets_ const currency::account_public_address& miner_addr = wallets[random_in_range(0, wallets.size() - 1)]->get_account().get_public_address(); currency::block b = AUTO_VAL_INIT(b); + currency::scratchpad_keeper sk; + crypto::hash seed = currency::null_hash; + sk.generate(seed, height); if (is_in_main_chain) { blobdata ex_nonce; wide_difficulty_type diff = 0; if (prev_block.height != 0) test_core_time::adjust(prev_block.bl.timestamp + DIFFICULTY_POW_TARGET); - r = bcs.create_block_template(b, miner_addr, diff, height, ex_nonce); + r = bcs.create_block_template(b, seed, miner_addr, diff, height, ex_nonce); CHECK_AND_ASSERT_MES(r, false, "create_block_template failed"); } else @@ -142,7 +145,7 @@ bool generate_events(currency::core& c, cct_events_t& events, const cct_wallets_ test_core_time::adjust(b.timestamp); currency::wide_difficulty_type diff = 0; - r = currency::miner::find_nonce_for_given_block(b, diff, height); + r = currency::miner::find_nonce_for_given_block(b, diff, height, seed, sk); CHECK_AND_ASSERT_MES(r, false, "find_nonce_for_given_block failed"); currency::block_verification_context bvc = AUTO_VAL_INIT(bvc); From 256ab7d0ed5f4ee5c98cc50247312ec177c85255 Mon Sep 17 00:00:00 2001 From: alfredmox <> Date: Tue, 22 Jan 2019 03:35:07 -0800 Subject: [PATCH 2/8] keccak tests --- src/crypto/wild_keccak.h | 10 ++++------ tests/performance_tests/keccak_test.h | 6 +++--- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/crypto/wild_keccak.h b/src/crypto/wild_keccak.h index eb017aef..f7abaf0c 100644 --- a/src/crypto/wild_keccak.h +++ b/src/crypto/wild_keccak.h @@ -30,12 +30,10 @@ extern "C" { namespace crypto { #define OPT_XOR_4_RES(A_, B_, C_, D_, Res) \ - crypto::hash A = A_;crypto::hash B = B_;crypto::hash C = C_; crypto::hash D = D_; \ - ((uint64_t*)&Res)[0] = ((const uint64_t*)&A)[0] ^ ((const uint64_t*)&B)[0] ^ ((const uint64_t*)&C)[0] ^ ((const uint64_t*)&D)[0]; \ - ((uint64_t*)&Res)[1] = ((const uint64_t*)&A)[1] ^ ((const uint64_t*)&B)[1] ^ ((const uint64_t*)&C)[1] ^ ((const uint64_t*)&D)[1]; \ - ((uint64_t*)&Res)[2] = ((const uint64_t*)&A)[2] ^ ((const uint64_t*)&B)[2] ^ ((const uint64_t*)&C)[2] ^ ((const uint64_t*)&D)[2]; \ - ((uint64_t*)&Res)[3] = ((const uint64_t*)&A)[3] ^ ((const uint64_t*)&B)[3] ^ ((const uint64_t*)&C)[3] ^ ((const uint64_t*)&D)[3]; - + ((uint64_t*)&Res)[0] = ((const uint64_t*)&A_)[0] ^ ((const uint64_t*)&B_)[0] ^ ((const uint64_t*)&C_)[0] ^ ((const uint64_t*)&D_)[0]; \ + ((uint64_t*)&Res)[1] = ((const uint64_t*)&A_)[1] ^ ((const uint64_t*)&B_)[1] ^ ((const uint64_t*)&C_)[1] ^ ((const uint64_t*)&D_)[1]; \ + ((uint64_t*)&Res)[2] = ((const uint64_t*)&A_)[2] ^ ((const uint64_t*)&B_)[2] ^ ((const uint64_t*)&C_)[2] ^ ((const uint64_t*)&D_)[2]; \ + ((uint64_t*)&Res)[3] = ((const uint64_t*)&A_)[3] ^ ((const uint64_t*)&B_)[3] ^ ((const uint64_t*)&C_)[3] ^ ((const uint64_t*)&D_)[3]; typedef uint64_t state_t_m[25]; typedef uint64_t mixin_t[KK_MIXIN_SIZE]; diff --git a/tests/performance_tests/keccak_test.h b/tests/performance_tests/keccak_test.h index 668a9873..14d0bdf3 100644 --- a/tests/performance_tests/keccak_test.h +++ b/tests/performance_tests/keccak_test.h @@ -111,7 +111,7 @@ public: #define SCR_I(i) m_scratchpad_vec[st[i]%m_scratchpad_vec.size()] for (size_t i = 0; i != 6; i++) { - *(crypto::hash*)&mix[i * 4] = XOR_4(SCR_I(i * 4), SCR_I(i * 4 + 1), SCR_I(i * 4 + 2), SCR_I(i * 4 + 3)); + OPT_XOR_4_RES(SCR_I(i * 4), SCR_I(i * 4 + 1), SCR_I(i * 4 + 2), SCR_I(i * 4 + 3), *(crypto::hash*)&mix[i * 4]); } }); @@ -177,7 +177,7 @@ void measure_keccak_over_scratchpad() crypto::hash res_to_test = { 0 }; crypto::hash res_etalon = { 0 }; OPT_XOR_4_RES(scratchpad_vec[0], scratchpad_vec[1], scratchpad_vec[2], scratchpad_vec[3], res_to_test); - res_etalon = XOR_4(scratchpad_vec[0], scratchpad_vec[1], scratchpad_vec[2], scratchpad_vec[3]); + OPT_XOR_4_RES(scratchpad_vec[0], scratchpad_vec[1], scratchpad_vec[2], scratchpad_vec[3], res_etalon); // @@ -222,7 +222,7 @@ void measure_keccak_over_scratchpad() uint64_t ticks_d = epee::misc_utils::get_tick_count(); for (size_t r = 0; r != measere_rounds; r++) { - crypto::get_wild_keccak2(has_str, res_h, 1, scratchpad_vec, i); + crypto::get_wild_keccak2(has_str, res_h, scratchpad_vec, i); } uint64_t ticks_e = epee::misc_utils::get_tick_count(); From f04536f54399713d3a2b55521773e0d7dd227daa Mon Sep 17 00:00:00 2001 From: "crypro.zoidberg" Date: Tue, 22 Jan 2019 20:34:18 +0300 Subject: [PATCH 3/8] renamed gui api --- src/gui/qt-daemon/application/mainwindow.cpp | 2 +- src/gui/qt-daemon/application/mainwindow.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/qt-daemon/application/mainwindow.cpp b/src/gui/qt-daemon/application/mainwindow.cpp index a724bcd5..9f7d8d12 100644 --- a/src/gui/qt-daemon/application/mainwindow.cpp +++ b/src/gui/qt-daemon/application/mainwindow.cpp @@ -1465,7 +1465,7 @@ QString MainWindow::stop_pos_mining(const QString& param) return MAKE_RESPONSE(default_ar); } -QString MainWindow::get_smart_safe_info(const QString& param) +QString MainWindow::get_smart_wallet_info(const QString& param) { LOG_API_TIMING(); PREPARE_ARG_FROM_JSON(view::wallet_id_obj, wo); diff --git a/src/gui/qt-daemon/application/mainwindow.h b/src/gui/qt-daemon/application/mainwindow.h index 432b8a40..85528d6e 100644 --- a/src/gui/qt-daemon/application/mainwindow.h +++ b/src/gui/qt-daemon/application/mainwindow.h @@ -126,7 +126,7 @@ public: QString get_log_level(const QString& param); // QString dump_all_offers(); QString webkit_launched_script(); - QString get_smart_safe_info(const QString& param); + QString get_smart_wallet_info(const QString& param); QString restore_wallet(const QString& param); QString is_pos_allowed(); QString store_to_file(const QString& path, const QString& buff); From e477762c14f2c43f1bbb10e81b95ebacb0cdf3ac Mon Sep 17 00:00:00 2001 From: alfredmox <> Date: Tue, 22 Jan 2019 12:43:38 -0800 Subject: [PATCH 4/8] unique name workaround --- src/crypto/wild_keccak.h | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/crypto/wild_keccak.h b/src/crypto/wild_keccak.h index f7abaf0c..f9fd7e32 100644 --- a/src/crypto/wild_keccak.h +++ b/src/crypto/wild_keccak.h @@ -29,11 +29,16 @@ 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) \ - ((uint64_t*)&Res)[0] = ((const uint64_t*)&A_)[0] ^ ((const uint64_t*)&B_)[0] ^ ((const uint64_t*)&C_)[0] ^ ((const uint64_t*)&D_)[0]; \ - ((uint64_t*)&Res)[1] = ((const uint64_t*)&A_)[1] ^ ((const uint64_t*)&B_)[1] ^ ((const uint64_t*)&C_)[1] ^ ((const uint64_t*)&D_)[1]; \ - ((uint64_t*)&Res)[2] = ((const uint64_t*)&A_)[2] ^ ((const uint64_t*)&B_)[2] ^ ((const uint64_t*)&C_)[2] ^ ((const uint64_t*)&D_)[2]; \ - ((uint64_t*)&Res)[3] = ((const uint64_t*)&A_)[3] ^ ((const uint64_t*)&B_)[3] ^ ((const uint64_t*)&C_)[3] ^ ((const uint64_t*)&D_)[3]; + 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]; From 29efec2bd6c96b89fe37b713b902e04e6eee6e97 Mon Sep 17 00:00:00 2001 From: "crypro.zoidberg" Date: Wed, 23 Jan 2019 13:16:48 +0300 Subject: [PATCH 5/8] parse time data --- tests/functional_tests/main.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/functional_tests/main.cpp b/tests/functional_tests/main.cpp index f0611901..b122205c 100644 --- a/tests/functional_tests/main.cpp +++ b/tests/functional_tests/main.cpp @@ -17,6 +17,7 @@ using namespace epee; #include "currency_core/currency_format_utils.h" #include "generate_test_genesis.h" #include "deadlock_guard_test.h" +#include "difficulty_analysis.h" namespace po = boost::program_options; @@ -51,6 +52,7 @@ namespace const command_line::arg_descriptor arg_blocks = {"blocks", "number of blocks to generate", 250}; const command_line::arg_descriptor arg_generate_test_genesis_json = { "generate-test-genesis-json", "generates test genesis json, specify amount of accounts", 0, true }; const command_line::arg_descriptor arg_deadlock_guard = { "test-deadlock-guard", "Do deadlock guard test", false, true }; + const command_line::arg_descriptor arg_difficulty_analysis = { "difficulty-analysis", "Do difficulty analysis", "", true }; } @@ -173,7 +175,12 @@ int main(int argc, char* argv[]) return 0; }else if(command_line::has_arg(vm, arg_generate_test_genesis_json)) { - generate_test_genesis(command_line::get_arg(vm, arg_generate_test_genesis_json)); + generate_test_genesis(command_line::get_arg(vm, arg_generate_test_genesis_json)); + return 0; + } + else if (command_line::has_arg(vm, arg_difficulty_analysis)) + { + run_difficulty_analysis(command_line::get_arg(vm, arg_difficulty_analysis)); return 0; } else if (command_line::get_arg(vm, arg_deadlock_guard) ) From 95e2e8ec343d5bc8c8ab0415f604748967f54a86 Mon Sep 17 00:00:00 2001 From: "crypro.zoidberg" Date: Wed, 23 Jan 2019 13:36:48 +0300 Subject: [PATCH 6/8] parse time data: added forgoten files --- .../functional_tests/difficulty_analysis.cpp | 44 +++++++++++++++++++ tests/functional_tests/difficulty_analysis.h | 9 ++++ 2 files changed, 53 insertions(+) create mode 100644 tests/functional_tests/difficulty_analysis.cpp create mode 100644 tests/functional_tests/difficulty_analysis.h diff --git a/tests/functional_tests/difficulty_analysis.cpp b/tests/functional_tests/difficulty_analysis.cpp new file mode 100644 index 00000000..2a6c2500 --- /dev/null +++ b/tests/functional_tests/difficulty_analysis.cpp @@ -0,0 +1,44 @@ +// Copyright (c) 2014-2018 Zano Project +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include +#include +#include +#include +#include + +#include "include_base_utils.h" +using namespace epee; +#include "wallet/wallet2.h" +#include "currency_core/blockchain_storage.h" + + +void run_difficulty_analysis(const std::string& path) +{ + std::istringstream fstr(path); + if (!fstr.good()) + { + LOG_ERROR("unable to open " << path); + return; + } + + LOG_PRINT_L0("Loading array..."); + std::string line; + std::vector> blocks; + blocks.reserve(140000); + while (std::getline(fstr, line)) + { + std::vector array_num; + boost::tokenizer<> tok(line); + std::transform(tok.begin(), tok.end(), std::back_inserter(array_num), + &boost::lexical_cast); + + blocks.push_back(array_num); + } + LOG_PRINT_L0("Loaded " << blocks.size() << " lines"); + + + return; +} + diff --git a/tests/functional_tests/difficulty_analysis.h b/tests/functional_tests/difficulty_analysis.h new file mode 100644 index 00000000..aeac7998 --- /dev/null +++ b/tests/functional_tests/difficulty_analysis.h @@ -0,0 +1,9 @@ +// Copyright (c) 2014-2018 Zano Project +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + + + +void run_difficulty_analysis(const std::string& path); + + From 699bee2cb12c37977ddca4ba5be1659916bc15ee Mon Sep 17 00:00:00 2001 From: "crypro.zoidberg" Date: Wed, 23 Jan 2019 18:35:59 +0300 Subject: [PATCH 7/8] fixed bug in parser --- tests/functional_tests/difficulty_analysis.cpp | 3 +-- tests/functional_tests/main.cpp | 2 ++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/functional_tests/difficulty_analysis.cpp b/tests/functional_tests/difficulty_analysis.cpp index 2a6c2500..c089c113 100644 --- a/tests/functional_tests/difficulty_analysis.cpp +++ b/tests/functional_tests/difficulty_analysis.cpp @@ -16,7 +16,7 @@ using namespace epee; void run_difficulty_analysis(const std::string& path) { - std::istringstream fstr(path); + std::ifstream fstr(path); if (!fstr.good()) { LOG_ERROR("unable to open " << path); @@ -41,4 +41,3 @@ void run_difficulty_analysis(const std::string& path) return; } - diff --git a/tests/functional_tests/main.cpp b/tests/functional_tests/main.cpp index b122205c..d53e5f6c 100644 --- a/tests/functional_tests/main.cpp +++ b/tests/functional_tests/main.cpp @@ -103,6 +103,8 @@ int main(int argc, char* argv[]) command_line::add_arg(desc_options, arg_generate_test_genesis_json); command_line::add_arg(desc_options, arg_max_tx_in_pool); command_line::add_arg(desc_options, arg_deadlock_guard); + command_line::add_arg(desc_options, arg_difficulty_analysis); + From 7b7aa7442c882745e19b79ea7c697e0d58fec3df Mon Sep 17 00:00:00 2001 From: "crypro.zoidberg" Date: Wed, 23 Jan 2019 18:53:51 +0300 Subject: [PATCH 8/8] Incremented version --- src/version.h.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/version.h.in b/src/version.h.in index c4dc2e23..82dd369d 100644 --- a/src/version.h.in +++ b/src/version.h.in @@ -2,6 +2,6 @@ #define BUILD_COMMIT_ID "@VERSION@" #define PROJECT_VERSION "1.0" -#define PROJECT_VERSION_BUILD_NO 5 +#define PROJECT_VERSION_BUILD_NO 6 #define PROJECT_VERSION_BUILD_NO_STR STRINGIFY_EXPAND(PROJECT_VERSION_BUILD_NO) #define PROJECT_VERSION_LONG PROJECT_VERSION "." PROJECT_VERSION_BUILD_NO_STR "[" BUILD_COMMIT_ID "]"