forked from lthn/blockchain
Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
b42bf9f6f0
9 changed files with 82 additions and 15 deletions
|
|
@ -29,13 +29,16 @@ extern "C" {
|
||||||
|
|
||||||
namespace crypto
|
namespace crypto
|
||||||
{
|
{
|
||||||
#define OPT_XOR_4_RES(A_, B_, C_, D_, Res) \
|
#define CONCAT_IMPL(x, y) x##y
|
||||||
crypto::hash A = A_;crypto::hash B = B_;crypto::hash C = C_; crypto::hash D = D_; \
|
#define CONCAT(x, y) CONCAT_IMPL(x, y)
|
||||||
((uint64_t*)&Res)[0] = ((const uint64_t*)&A)[0] ^ ((const uint64_t*)&B)[0] ^ ((const uint64_t*)&C)[0] ^ ((const uint64_t*)&D)[0]; \
|
#define UNIQUE(x) CONCAT(x, __LINE__)
|
||||||
((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];
|
|
||||||
|
|
||||||
|
#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 state_t_m[25];
|
||||||
typedef uint64_t mixin_t[KK_MIXIN_SIZE];
|
typedef uint64_t mixin_t[KK_MIXIN_SIZE];
|
||||||
|
|
|
||||||
|
|
@ -1465,7 +1465,7 @@ QString MainWindow::stop_pos_mining(const QString& param)
|
||||||
return MAKE_RESPONSE(default_ar);
|
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();
|
LOG_API_TIMING();
|
||||||
PREPARE_ARG_FROM_JSON(view::wallet_id_obj, wo);
|
PREPARE_ARG_FROM_JSON(view::wallet_id_obj, wo);
|
||||||
|
|
|
||||||
|
|
@ -126,7 +126,7 @@ public:
|
||||||
QString get_log_level(const QString& param);
|
QString get_log_level(const QString& param);
|
||||||
// QString dump_all_offers();
|
// QString dump_all_offers();
|
||||||
QString webkit_launched_script();
|
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 restore_wallet(const QString& param);
|
||||||
QString is_pos_allowed();
|
QString is_pos_allowed();
|
||||||
QString store_to_file(const QString& path, const QString& buff);
|
QString store_to_file(const QString& path, const QString& buff);
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,6 @@
|
||||||
|
|
||||||
#define BUILD_COMMIT_ID "@VERSION@"
|
#define BUILD_COMMIT_ID "@VERSION@"
|
||||||
#define PROJECT_VERSION "1.0"
|
#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_BUILD_NO_STR STRINGIFY_EXPAND(PROJECT_VERSION_BUILD_NO)
|
||||||
#define PROJECT_VERSION_LONG PROJECT_VERSION "." PROJECT_VERSION_BUILD_NO_STR "[" BUILD_COMMIT_ID "]"
|
#define PROJECT_VERSION_LONG PROJECT_VERSION "." PROJECT_VERSION_BUILD_NO_STR "[" BUILD_COMMIT_ID "]"
|
||||||
|
|
|
||||||
|
|
@ -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();
|
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::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)
|
if (is_in_main_chain)
|
||||||
{
|
{
|
||||||
blobdata ex_nonce;
|
blobdata ex_nonce;
|
||||||
wide_difficulty_type diff = 0;
|
wide_difficulty_type diff = 0;
|
||||||
if (prev_block.height != 0)
|
if (prev_block.height != 0)
|
||||||
test_core_time::adjust(prev_block.bl.timestamp + DIFFICULTY_POW_TARGET);
|
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");
|
CHECK_AND_ASSERT_MES(r, false, "create_block_template failed");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -142,7 +145,7 @@ bool generate_events(currency::core& c, cct_events_t& events, const cct_wallets_
|
||||||
test_core_time::adjust(b.timestamp);
|
test_core_time::adjust(b.timestamp);
|
||||||
|
|
||||||
currency::wide_difficulty_type diff = 0;
|
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");
|
CHECK_AND_ASSERT_MES(r, false, "find_nonce_for_given_block failed");
|
||||||
|
|
||||||
currency::block_verification_context bvc = AUTO_VAL_INIT(bvc);
|
currency::block_verification_context bvc = AUTO_VAL_INIT(bvc);
|
||||||
|
|
|
||||||
43
tests/functional_tests/difficulty_analysis.cpp
Normal file
43
tests/functional_tests/difficulty_analysis.cpp
Normal file
|
|
@ -0,0 +1,43 @@
|
||||||
|
// 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 <iostream>
|
||||||
|
#include <vector>
|
||||||
|
#include <algorithm>
|
||||||
|
#include <boost/algorithm/string.hpp>
|
||||||
|
#include <boost/tokenizer.hpp>
|
||||||
|
|
||||||
|
#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::ifstream fstr(path);
|
||||||
|
if (!fstr.good())
|
||||||
|
{
|
||||||
|
LOG_ERROR("unable to open " << path);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
LOG_PRINT_L0("Loading array...");
|
||||||
|
std::string line;
|
||||||
|
std::vector<std::vector<uint64_t>> blocks;
|
||||||
|
blocks.reserve(140000);
|
||||||
|
while (std::getline(fstr, line))
|
||||||
|
{
|
||||||
|
std::vector<uint64_t> array_num;
|
||||||
|
boost::tokenizer<> tok(line);
|
||||||
|
std::transform(tok.begin(), tok.end(), std::back_inserter(array_num),
|
||||||
|
&boost::lexical_cast<uint64_t, std::string>);
|
||||||
|
|
||||||
|
blocks.push_back(array_num);
|
||||||
|
}
|
||||||
|
LOG_PRINT_L0("Loaded " << blocks.size() << " lines");
|
||||||
|
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
9
tests/functional_tests/difficulty_analysis.h
Normal file
9
tests/functional_tests/difficulty_analysis.h
Normal file
|
|
@ -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);
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -17,6 +17,7 @@ using namespace epee;
|
||||||
#include "currency_core/currency_format_utils.h"
|
#include "currency_core/currency_format_utils.h"
|
||||||
#include "generate_test_genesis.h"
|
#include "generate_test_genesis.h"
|
||||||
#include "deadlock_guard_test.h"
|
#include "deadlock_guard_test.h"
|
||||||
|
#include "difficulty_analysis.h"
|
||||||
|
|
||||||
namespace po = boost::program_options;
|
namespace po = boost::program_options;
|
||||||
|
|
||||||
|
|
@ -51,6 +52,7 @@ namespace
|
||||||
const command_line::arg_descriptor<size_t> arg_blocks = {"blocks", "number of blocks to generate", 250};
|
const command_line::arg_descriptor<size_t> arg_blocks = {"blocks", "number of blocks to generate", 250};
|
||||||
const command_line::arg_descriptor<size_t> arg_generate_test_genesis_json = { "generate-test-genesis-json", "generates test genesis json, specify amount of accounts", 0, true };
|
const command_line::arg_descriptor<size_t> arg_generate_test_genesis_json = { "generate-test-genesis-json", "generates test genesis json, specify amount of accounts", 0, true };
|
||||||
const command_line::arg_descriptor<bool> arg_deadlock_guard = { "test-deadlock-guard", "Do deadlock guard test", false, true };
|
const command_line::arg_descriptor<bool> arg_deadlock_guard = { "test-deadlock-guard", "Do deadlock guard test", false, true };
|
||||||
|
const command_line::arg_descriptor<std::string> arg_difficulty_analysis = { "difficulty-analysis", "Do difficulty analysis", "", true };
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -101,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_generate_test_genesis_json);
|
||||||
command_line::add_arg(desc_options, arg_max_tx_in_pool);
|
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_deadlock_guard);
|
||||||
|
command_line::add_arg(desc_options, arg_difficulty_analysis);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -173,7 +177,12 @@ int main(int argc, char* argv[])
|
||||||
return 0;
|
return 0;
|
||||||
}else if(command_line::has_arg(vm, arg_generate_test_genesis_json))
|
}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;
|
return 0;
|
||||||
}
|
}
|
||||||
else if (command_line::get_arg(vm, arg_deadlock_guard) )
|
else if (command_line::get_arg(vm, arg_deadlock_guard) )
|
||||||
|
|
|
||||||
|
|
@ -111,7 +111,7 @@ public:
|
||||||
#define SCR_I(i) m_scratchpad_vec[st[i]%m_scratchpad_vec.size()]
|
#define SCR_I(i) m_scratchpad_vec[st[i]%m_scratchpad_vec.size()]
|
||||||
for (size_t i = 0; i != 6; i++)
|
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_to_test = { 0 };
|
||||||
crypto::hash res_etalon = { 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);
|
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();
|
uint64_t ticks_d = epee::misc_utils::get_tick_count();
|
||||||
for (size_t r = 0; r != measere_rounds; r++)
|
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();
|
uint64_t ticks_e = epee::misc_utils::get_tick_count();
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue