1
0
Fork 0
forked from lthn/blockchain

Merge remote-tracking branch 'origin/frontend'

This commit is contained in:
wildkif 2019-03-14 16:28:48 +02:00
commit 5cbe1bafad
54 changed files with 529 additions and 615 deletions

View file

@ -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

View file

@ -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` <br> `cd build` <br> `cmake -DBUILD_GUI=FALSE -DSTATIC=TRUE ..` <br> `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.

View file

@ -78,7 +78,7 @@ namespace epee
{
t_object t;
std::recursive_mutex m;
mutable std::recursive_mutex m;
template<typename t_proxy_object, typename t_proxy_lock_time_watching_policy>
friend class locked_object_proxy;
public:
@ -106,6 +106,16 @@ namespace epee
return locked_object_proxy<t_object, lock_time_watching_policy>(t, m);
}
locked_object_proxy<const t_object, lock_time_watching_policy> operator->() const
{
return locked_object_proxy<const t_object, lock_time_watching_policy>(t, m);
}
locked_object_proxy<const t_object, lock_time_watching_policy> operator*() const
{
return locked_object_proxy<const t_object, lock_time_watching_policy>(t, m);
}
/*locked_object_proxy<t_object> operator()()
{
return locked_object_proxy<t_object>(t, m);

View file

@ -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)
@ -165,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()

View file

@ -4,11 +4,13 @@
// 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.
#include "wild_keccak.h"
#include "include_base_utils.h"
namespace crypto
{
@ -76,58 +78,59 @@ 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<crypto::hash>& result_data, uint64_t target_size)
{
//this is very basic implementation, not considered for production (possible to reduce memory by keeping only every x10 item and calc it instead of read)
//TODO: research safe way for scratchpad generation
result_data.resize(target_size);
result_data[0] = crypto::cn_fast_hash(&seed_data, sizeof(seed_data));
//crypto::hash = get_transaction_hash()
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<crypto::hash>& result_data, uint64_t target_size)
{
CHECK_AND_ASSERT_THROW_MES(target_size % 10 == 0, "wrong target_size = " << target_size);
result_data.reserve(target_size/10);
result_data.push_back(crypto::cn_fast_hash(&seed_data, sizeof(seed_data)));
crypto::hash prev_hash = result_data[0];
for (size_t i = 1; i < target_size; i++)
{
prev_hash = crypto::cn_fast_hash(&prev_hash, sizeof(prev_hash));
if (!(i % 10))
{
result_data.push_back(prev_hash);
}
}
return true;
}
bool get_wild_keccak_light(const std::string& bd, crypto::hash& res, const std::vector<crypto::hash>& scratchpad_light)
{
if (!scratchpad_light.size())
return false;
auto light_scr_accessor = [&](uint64_t i)
{
//get index of int64 item in scratchpad from i, where is is random number in whole uint64_t range
uint64_t int64_mod_index = i%(scratchpad_light.size() * 10 * 4);
//get related hash index
uint64_t hash_index = int64_mod_index / 4;
//get_in hash index (from 0 to 3)
uint64_t in_hash_index = int64_mod_index % 4;
//get index of primary hash in scratchpad_light
uint64_t primary_item_index = (hash_index - (hash_index % 10)) / 10;
uint64_t sha_count = hash_index % 10;
crypto::hash res = scratchpad_light[primary_item_index];
for (uint64_t i = 0; i != sha_count; i++)
{
res = cn_fast_hash(&res, sizeof(res));
}
return ((uint64_t*)&res)[in_hash_index];
};
return get_wild_keccak_light(bd, res, light_scr_accessor);
}
}

View file

@ -2,6 +2,7 @@
// 19-Nov-11 Markku-Juhani O. Saarinen <mjos@iki.fi>
// 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<class f_traits>
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<class f_traits, class callback_t>
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<class f_traits, class callback_t>
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<class f_traits, class callback_t>
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<f_traits>(in, inlen, md, mdlen, cb);
wild_keccak<f_traits>(md, mdlen, md, mdlen, cb);
return 0;
}
template<class f_traits, class callback_t>
int wild_keccak2_dbl(const uint8_t *in, size_t inlen, uint8_t *md, size_t mdlen, callback_t cb)
{
@ -215,18 +92,16 @@ 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
bool get_wild_keccak2(const std::string& bd, crypto::hash& res, const std::vector<crypto::hash>& scratchpad, uint64_t sz)
{
uint64_t count_access = 0;
crypto::wild_keccak2_dbl<crypto::regular_f>(reinterpret_cast<const uint8_t*>(bd.data()), bd.size(), reinterpret_cast<uint8_t*>(&res), sizeof(res), [&](crypto::state_t_m& st)
{
++count_access;
if (!sz)
{
return;
@ -248,9 +123,33 @@ namespace crypto
}
st[i] ^= int_array_ptr[ int_array_ptr[ int_array_ptr[st[depend_index] % int64_sz] % int64_sz] % int64_sz];
}
});
return true;
}
template<class t_items_accessor>
bool get_wild_keccak_light(const std::string& bd, crypto::hash& res, t_items_accessor cb_get_item)
{
crypto::wild_keccak2_dbl<crypto::regular_f>(reinterpret_cast<const uint8_t*>(bd.data()), bd.size(), reinterpret_cast<uint8_t*>(&res), sizeof(res), [&](crypto::state_t_m& st)
{
for (size_t i = 0; i != sizeof(st) / sizeof(st[0]); i++)
{
size_t depend_index = 0;
if (i == 0)
{
depend_index = sizeof(st) / sizeof(st[0]) - 1;
}
else
{
depend_index = i - 1;
}
st[i] ^= cb_get_item(cb_get_item(cb_get_item(st[depend_index])));
}
});
return true;
}
//------------------------------------------------------------------
bool get_wild_keccak_light(const std::string& bd, crypto::hash& res, const std::vector<crypto::hash>& scratchpad_light);
//------------------------------------------------------------------
inline
bool get_wild_keccak2(const std::string& bd, crypto::hash& res, const std::vector<crypto::hash>& scratchpad)
@ -258,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<crypto::hash>& scratchpad, uint64_t sz)
{
crypto::wild_keccak_dbl<crypto::mul_f>(reinterpret_cast<const uint8_t*>(bd.data()), bd.size(), reinterpret_cast<uint8_t*>(&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<crypto::hash>& result_data, uint64_t target_size);
bool generate_scratchpad_light(const crypto::hash& seed_data, std::vector<crypto::hash>& result_data, uint64_t target_size);
}

View file

@ -116,7 +116,7 @@ namespace currency
return true;
}
//-----------------------------------------------------------------
std::string account_base::get_public_address_str()
std::string account_base::get_public_address_str() const
{
//TODO: change this code into base 58
return get_account_address_as_str(m_keys.m_account_address);

View file

@ -50,7 +50,7 @@ namespace currency
void generate();
const account_keys& get_keys() const;
const account_public_address& get_public_address() const { return m_keys.m_account_address; };
std::string get_public_address_str();
std::string get_public_address_str() const;
std::string get_restore_data() const;
std::string get_restore_braindata() const;

View file

@ -25,7 +25,7 @@ namespace bc_services
, m_core_runtime_config(currency::get_default_core_runtime_config())
, m_last_seen_block_id(currency::null_hash)
, m_deinitialized(false)
, m_disabled(true)
, m_disabled(false)
{}
//------------------------------------------------------------------

View file

@ -67,6 +67,7 @@ namespace bc_services
crypto::hash get_last_seen_block_id();
void set_last_seen_block_id(const crypto::hash& h);
bool clear();
bool set_disabled(bool is_disabled) { m_disabled = is_disabled; return m_disabled; }
bool is_disabled(){ return m_disabled; }
static void init_options(boost::program_options::options_description& desc);
private:

View file

@ -100,7 +100,8 @@ blockchain_storage::blockchain_storage(tx_memory_pool& tx_pool) :m_db(std::share
m_current_fee_median_effective_index(0),
m_is_reorganize_in_process(false),
m_deinit_is_done(false),
m_current_scratchpad_seed(currency::null_hash)
m_current_scratchpad_seed(currency::null_hash),
m_current_scratchpad_seed_height(0)
{
@ -291,6 +292,7 @@ bool blockchain_storage::init(const std::string& config_folder, const boost::pro
initialize_db_solo_options_values();
get_seed_for_scratchpad(m_db_blocks.size(), m_current_scratchpad_seed);
m_current_scratchpad_seed_height = m_db_blocks.size();
m_services_mgr.init(config_folder, vm);
@ -4582,9 +4584,10 @@ void blockchain_storage::on_block_added(const block_extended_info& bei, const cr
//------------------------------------------------------------------
bool blockchain_storage::check_scratchpad()
{
if (get_scratchpad_size_for_height(m_db_blocks.size()) != m_scratchpad.size())
if(get_scratchpad_last_update_rebuild_height(m_db_blocks.size()) != m_current_scratchpad_seed_height)
{
get_seed_for_scratchpad(m_db_blocks.size(), m_current_scratchpad_seed);
m_current_scratchpad_seed_height = get_scratchpad_last_update_rebuild_height(m_db_blocks.size());
}
return true;
}

View file

@ -511,8 +511,9 @@ namespace currency
mutable uint64_t m_current_fee_median;
mutable uint64_t m_current_fee_median_effective_index;
bool m_is_reorganize_in_process;
mutable scratchpad_keeper m_scratchpad;
mutable scratchpad_light_pool m_scratchpad; //TODO: optimization for using full scratchpad in mainchain
crypto::hash m_current_scratchpad_seed;
uint64_t m_current_scratchpad_seed_height;
mutable std::atomic<bool> m_deinit_is_done;

View file

@ -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
@ -8,7 +7,7 @@
#pragma once
#define CURRENCY_FORMATION_VERSION 75
#define CURRENCY_FORMATION_VERSION 76
#define CURRENCY_MAX_BLOCK_NUMBER 500000000
@ -47,8 +46,7 @@
#define BASE_REWARD_DUST_THRESHOLD ((uint64_t)1000000) // pow(10, 6) - change this will cause hard-fork!
#define DEFAULT_DUST_THRESHOLD ((uint64_t)0)//((uint64_t)100000) // pow(10, 5)
//#define CURRENCY_SCRATCHPAD_BASE_SIZE 16777216 //count in crypto::hash, to get size in bytes x32
#define CURRENCY_SCRATCHPAD_BASE_SIZE 167 //count in crypto::hash, to get size in bytes x32
#define CURRENCY_SCRATCHPAD_BASE_SIZE 16777210 //count in crypto::hash, to get size in bytes x32
#define CURRENCY_SCRATCHPAD_REBUILD_INTERVAL 720 //once a day if block goes once in 2 minute
#define CURRENCY_SCRATCHPAD_BASE_INDEX_ID_OFFSET 20 //offset down from last rebuild height to block id, that used for indexing seed blocks in CURRENCY_SCRATCHPAD_SEED_BLOCKS_WINDOW
#define CURRENCY_SCRATCHPAD_SEED_BLOCKS_WINDOW 700 //window for addressing seed block ids
@ -99,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

View file

@ -2412,8 +2412,12 @@ namespace currency
//-----------------------------------------------------------------------------------------------
uint64_t get_scratchpad_size_for_height(uint64_t h)
{
//let's have ~256MB/year if block interval is 2 minutes
return CURRENCY_SCRATCHPAD_BASE_SIZE + get_scratchpad_last_update_rebuild_height(h)*32;
if (h < CURRENCY_BLOCKS_PER_DAY * 7)
{
return 100;
}
//let's have ~250MB/year if block interval is 2 minutes
return CURRENCY_SCRATCHPAD_BASE_SIZE + get_scratchpad_last_update_rebuild_height(h)*30;
}
//-----------------------------------------------------------------------------------------------
bool get_block_reward(bool is_pos, size_t median_size, size_t current_block_size, uint64_t already_generated_coins, uint64_t &reward, uint64_t height)

View file

@ -40,9 +40,9 @@ namespace currency {
static inline void mul(uint64_t a, uint64_t b, uint64_t &low, uint64_t &high) {
typedef unsigned __int128 uint128_t;
uint128_t res = (uint128_t) a * (uint128_t) b;
low = (uint64_t) res;
high = (uint64_t) (res >> 64);
uint128_t res = (uint128_t)a * (uint128_t)b;
low = (uint64_t)res;
high = (uint64_t)(res >> 64);
}
#endif
@ -52,21 +52,21 @@ namespace currency {
}
static inline bool cadc(uint64_t a, uint64_t b, bool c) {
return a + b < a || (c && a + b == (uint64_t) -1);
return a + b < a || (c && a + b == (uint64_t)-1);
}
bool check_hash_old(const crypto::hash &hash, difficulty_type difficulty) {
uint64_t low, high, top, cur;
// First check the highest word, this will most likely fail for a random hash.
mul(swap64le(((const uint64_t *) &hash)[3]), difficulty, top, high);
mul(swap64le(((const uint64_t *)&hash)[3]), difficulty, top, high);
if (high != 0) {
return false;
}
mul(swap64le(((const uint64_t *) &hash)[0]), difficulty, low, cur);
mul(swap64le(((const uint64_t *) &hash)[1]), difficulty, low, high);
mul(swap64le(((const uint64_t *)&hash)[0]), difficulty, low, cur);
mul(swap64le(((const uint64_t *)&hash)[1]), difficulty, low, high);
bool carry = cadd(cur, low);
cur = high;
mul(swap64le(((const uint64_t *) &hash)[2]), difficulty, low, high);
mul(swap64le(((const uint64_t *)&hash)[2]), difficulty, low, high);
carry = cadc(cur, low, carry);
carry = cadc(high, top, carry);
return !carry;
@ -81,14 +81,14 @@ namespace currency {
const wide_difficulty_type max64bit(std::numeric_limits<std::uint64_t>::max());
const boost::multiprecision::uint256_t max128bit(std::numeric_limits<boost::multiprecision::uint128_t>::max());
const boost::multiprecision::uint512_t max256bit(std::numeric_limits<boost::multiprecision::uint256_t>::max());
bool check_hash(const crypto::hash &hash_, wide_difficulty_type difficulty)
bool check_hash(const crypto::hash &hash_, wide_difficulty_type difficulty)
{
//revert byte order
crypto::hash h = {};
for (size_t i = 0; i != sizeof(h); i++)
{
*(((char*)&h) + (sizeof(h)-(i + 1))) = *(((char*)&hash_) +i );
*(((char*)&h) + (sizeof(h) - (i + 1))) = *(((char*)&hash_) + i);
}
PROFILE_FUNC("check_hash");
@ -97,26 +97,26 @@ namespace currency {
std::uint64_t dl = difficulty.convert_to<std::uint64_t>();
uint64_t low, high, top, cur;
// First check the highest word, this will most likely fail for a random hash.
mul(swap64le(((const uint64_t *) &h)[3]), dl, top, high);
if (high != 0)
mul(swap64le(((const uint64_t *)&h)[3]), dl, top, high);
if (high != 0)
return false;
mul(swap64le(((const uint64_t *) &h)[0]), dl, low, cur);
mul(swap64le(((const uint64_t *) &h)[1]), dl, low, high);
mul(swap64le(((const uint64_t *)&h)[0]), dl, low, cur);
mul(swap64le(((const uint64_t *)&h)[1]), dl, low, high);
bool carry = cadd(cur, low);
cur = high;
mul(swap64le(((const uint64_t *) &h)[2]), dl, low, high);
mul(swap64le(((const uint64_t *)&h)[2]), dl, low, high);
carry = cadc(cur, low, carry);
carry = cadc(high, top, carry);
return !carry;
}
// fast check
if (((const uint64_t *) &h)[3] > 0)
if (((const uint64_t *)&h)[3] > 0)
return false;
// usual slow check
boost::multiprecision::uint512_t hashVal = 0;
for(int i = 1; i < 4; i++)
for (int i = 1; i < 4; i++)
{ // highest word is zero
hashVal |= swap64le(((const uint64_t *) &h)[3 - i]);
hashVal |= swap64le(((const uint64_t *)&h)[3 - i]);
hashVal << 64;
}
return (hashVal * difficulty > max256bit);
@ -130,7 +130,7 @@ namespace currency {
return res;
}
void difficulty_to_boundary_long(wide_difficulty_type difficulty, crypto::hash& result)
void difficulty_to_boundary_long(wide_difficulty_type difficulty, crypto::hash& result)
{
boost::multiprecision::uint256_t nominal_hash = std::numeric_limits<boost::multiprecision::uint256_t>::max();
nominal_hash = nominal_hash / difficulty;
@ -145,7 +145,7 @@ namespace currency {
difficulty_type next_difficulty_old(vector<uint64_t> timestamps, vector<difficulty_type> cumulative_difficulties, size_t target_seconds) {
//cutoff DIFFICULTY_LAG
if(timestamps.size() > DIFFICULTY_WINDOW)
if (timestamps.size() > DIFFICULTY_WINDOW)
{
timestamps.resize(DIFFICULTY_WINDOW);
cumulative_difficulties.resize(DIFFICULTY_WINDOW);
@ -165,7 +165,8 @@ namespace currency {
if (length <= DIFFICULTY_WINDOW - 2 * DIFFICULTY_CUT) {
cut_begin = 0;
cut_end = length;
} else {
}
else {
cut_begin = (length - (DIFFICULTY_WINDOW - 2 * DIFFICULTY_CUT) + 1) / 2;
cut_end = cut_begin + (DIFFICULTY_WINDOW - 2 * DIFFICULTY_CUT);
}
@ -184,11 +185,62 @@ namespace currency {
return (low + time_span - 1) / time_span;
}
wide_difficulty_type next_difficulty(vector<uint64_t>& timestamps, vector<wide_difficulty_type>& cumulative_difficulties, size_t target_seconds)
void get_cut_location_from_len(size_t length, size_t& cut_begin, size_t& cut_end, size_t REDEF_DIFFICULTY_WINDOW, size_t REDEF_DIFFICULTY_CUT_OLD, size_t REDEF_DIFFICULTY_CUT_LAST)
{
if (length <= REDEF_DIFFICULTY_WINDOW)
{
cut_begin = 0;
cut_end = length;
}
else
{
cut_begin = REDEF_DIFFICULTY_WINDOW - REDEF_DIFFICULTY_CUT_LAST + 1;
cut_end = cut_begin + (REDEF_DIFFICULTY_WINDOW - (REDEF_DIFFICULTY_CUT_OLD + REDEF_DIFFICULTY_CUT_LAST));
}
}
void get_adjustment_zone(size_t length, size_t& cut_begin, size_t& cut_end, size_t REDEF_DIFFICULTY_WINDOW, size_t REDEF_DIFFICULTY_CUT_OLD, size_t REDEF_DIFFICULTY_CUT_LAST)
{
//cutoff DIFFICULTY_LAG
if (length <= REDEF_DIFFICULTY_WINDOW - (REDEF_DIFFICULTY_CUT_OLD + REDEF_DIFFICULTY_CUT_LAST))
{
cut_begin = 0;
cut_end = length;
}
else
{
cut_begin = REDEF_DIFFICULTY_CUT_LAST;
cut_end = cut_begin + (REDEF_DIFFICULTY_WINDOW - (REDEF_DIFFICULTY_CUT_OLD + REDEF_DIFFICULTY_CUT_LAST));
if (cut_end > length)
cut_end = length;
}
CHECK_AND_ASSERT_THROW_MES(/*cut_begin >= 0 &&*/ cut_begin + 2 <= cut_end && cut_end <= length, "validation in next_difficulty is failed");
}
wide_difficulty_type get_adjustment_for_zone(vector<uint64_t>& timestamps_sorted, vector<wide_difficulty_type>& cumulative_difficulties, size_t target_seconds, size_t REDEF_DIFFICULTY_WINDOW, size_t REDEF_DIFFICULTY_CUT_OLD, size_t REDEF_DIFFICULTY_CUT_LAST)
{
size_t length = timestamps_sorted.size();
size_t cut_begin = 0;
size_t cut_end = 0;
get_adjustment_zone(length, cut_begin, cut_end, REDEF_DIFFICULTY_WINDOW, REDEF_DIFFICULTY_CUT_OLD, REDEF_DIFFICULTY_CUT_LAST);
uint64_t time_span = timestamps_sorted[cut_begin] - timestamps_sorted[cut_end - 1];
if (time_span == 0)
{
time_span = 1;
}
wide_difficulty_type total_work = cumulative_difficulties[cut_begin] - cumulative_difficulties[cut_end - 1];
boost::multiprecision::uint256_t res = (boost::multiprecision::uint256_t(total_work) * target_seconds + time_span - 1) / time_span;
if (res > max128bit)
return 0; // to behave like previous implementation, may be better return max128bit?
return res.convert_to<wide_difficulty_type>();
}
wide_difficulty_type next_difficulty(vector<uint64_t>& timestamps, vector<wide_difficulty_type>& cumulative_difficulties, size_t target_seconds)
{
// timestamps - first is latest, back - is oldest timestamps
//cutoff DIFFICULTY_LAG
if(timestamps.size() > DIFFICULTY_WINDOW)
if (timestamps.size() > DIFFICULTY_WINDOW)
{
timestamps.resize(DIFFICULTY_WINDOW);
cumulative_difficulties.resize(DIFFICULTY_WINDOW);
@ -197,30 +249,32 @@ namespace currency {
size_t length = timestamps.size();
CHECK_AND_ASSERT_MES(length == cumulative_difficulties.size(), 0, "Check \"length == cumulative_difficulties.size()\" failed");
if (length <= 1) {
if (length <= 1)
{
return DIFFICULTY_STARTER;
}
static_assert(DIFFICULTY_WINDOW >= 2, "Window is too small");
CHECK_AND_ASSERT_MES(length <= DIFFICULTY_WINDOW, 0, "length <= DIFFICULTY_WINDOW check failed, length=" << length);
sort(timestamps.begin(), timestamps.end(), std::greater<uint64_t>());
size_t cut_begin, cut_end;
static_assert(2 * DIFFICULTY_CUT <= DIFFICULTY_WINDOW - 2, "Cut length is too large");
if (length <= DIFFICULTY_WINDOW - 2 * DIFFICULTY_CUT) {
cut_begin = 0;
cut_end = length;
} else {
cut_begin = (length - (DIFFICULTY_WINDOW - 2 * DIFFICULTY_CUT) + 1) / 2;
cut_end = cut_begin + (DIFFICULTY_WINDOW - 2 * DIFFICULTY_CUT);
wide_difficulty_type dif_slow = get_adjustment_for_zone(timestamps, cumulative_difficulties, target_seconds, DIFFICULTY_WINDOW, DIFFICULTY_CUT/2, DIFFICULTY_CUT/2);
wide_difficulty_type dif_medium = get_adjustment_for_zone(timestamps, cumulative_difficulties, target_seconds, DIFFICULTY_WINDOW/3, DIFFICULTY_CUT / 8, DIFFICULTY_CUT / 12);
wide_difficulty_type dif_fast = get_adjustment_for_zone(timestamps, cumulative_difficulties, target_seconds, DIFFICULTY_WINDOW/18, DIFFICULTY_CUT / 10, 2);
uint64_t devider = 1;
wide_difficulty_type summ = dif_slow;
if (dif_medium != 0)
{
summ += dif_medium;
++devider;
}
CHECK_AND_ASSERT_THROW_MES(/*cut_begin >= 0 &&*/ cut_begin + 2 <= cut_end && cut_end <= length, "validation in next_difficulty is failed");
uint64_t time_span = timestamps[cut_begin] - timestamps[cut_end - 1];
if (time_span == 0) {
time_span = 1;
if (dif_fast != 0)
{
summ += dif_fast;
++devider;
}
wide_difficulty_type total_work = cumulative_difficulties[cut_begin] - cumulative_difficulties[cut_end - 1];
boost::multiprecision::uint256_t res = (boost::multiprecision::uint256_t(total_work) * target_seconds + time_span - 1) / time_span;
if(res > max128bit)
return 0; // to behave like previous implementation, may be better return max128bit?
return res.convert_to<wide_difficulty_type>();
return summ / devider;
}
}

View file

@ -345,7 +345,7 @@ namespace currency
}
b.nonce = nonce;
access_nonce_in_block_blob(local_blob_data) = b.nonce;
crypto::hash h = m_scratchpad.get_pow_hash(local_blob_data, local_height, local_seed);
crypto::hash h = m_scratchpad.get_pow_hash_from_blob(local_blob_data, local_height, local_seed);
if(check_hash(h, local_diff))
{

View file

@ -73,7 +73,7 @@ namespace currency
{
nonce_ref = bl.nonce;
crypto::hash h = sk.get_pow_hash(bd, height, seed);
crypto::hash h = sk.get_pow_hash_from_blob(bd, height, seed);
if(check_hash(h, diffic))
{
LOG_PRINT_L0("Found nonce for block: " << get_block_hash(bl) << "[" << height << "]: PoW:" << h << "(diff:" << diffic << "), ts: " << bl.timestamp);

View file

@ -15,6 +15,7 @@ namespace currency
{
}
//------------------------------------------------------------------------------------
bool scratchpad_keeper::generate(const crypto::hash& scr_seed, uint64_t height)
{
bool r = false;
@ -25,7 +26,8 @@ namespace currency
CRITICAL_REGION_END();
return r;
}
crypto::hash scratchpad_keeper::get_pow_hash(const blobdata& bd, uint64_t height, const crypto::hash& scr_seed)
//------------------------------------------------------------------------------------
crypto::hash scratchpad_keeper::get_pow_hash_from_blob(const blobdata& bd, uint64_t height, const crypto::hash& scr_seed)
{
CRITICAL_REGION_LOCAL(m_lock);
crypto::hash res_hash = null_hash;
@ -41,13 +43,34 @@ namespace currency
CHECK_AND_ASSERT_THROW_MES(res, "Fatal error on hash calculation: scratchpad_size=" << m_scratchpad.size());
return res_hash;
}
crypto::hash scratchpad_keeper::get_pow_hash(const block& b, const crypto::hash& scr_seed)
{
blobdata bl = get_block_hashing_blob(b);
return get_pow_hash(bl, get_block_height(b), scr_seed);
}
//------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------
uint64_t scratchpad_keeper::size()
{
return m_scratchpad.size();
}
}
//------------------------------------------------------------------------------------
crypto::hash scratchpad_light_pool::get_pow_hash_from_blob(const blobdata& bd, uint64_t height, const crypto::hash& seed)
{
CRITICAL_REGION_LOCAL(m_lock);
std::shared_ptr<std::vector<crypto::hash>> pscr_light;
if (!m_scratchpad_pools.get(seed, pscr_light))
{
LOG_PRINT_MAGENTA("Generating scratchpad light for " << seed << "["<< height <<"]", LOG_LEVEL_0);
pscr_light.reset(new std::vector<crypto::hash>());
bool r = crypto::generate_scratchpad_light(seed, *pscr_light, currency::get_scratchpad_size_for_height(height));
CHECK_AND_ASSERT_THROW_MES(r, "Failed to generate_scratchpad_light");
m_scratchpad_pools.set(seed, pscr_light);
LOG_PRINT_MAGENTA("Generated ok", LOG_LEVEL_0);
}
CHECK_AND_ASSERT_THROW_MES(pscr_light->size()*10 == currency::get_scratchpad_size_for_height(height),
"Wrong size of cached scratchpad = " << pscr_light->size() << ", expected " << currency::get_scratchpad_size_for_height(height) << " for height " << height);
crypto::hash res = currency::null_hash;
bool r = crypto::get_wild_keccak_light(bd, res, *pscr_light);
CHECK_AND_ASSERT_THROW_MES(r, "Failed to get_wild_keccak_light");
return res;
}
//------------------------------------------------------------------------------------
}

View file

@ -6,16 +6,30 @@
#include "crypto/wild_keccak.h"
#include "currency_protocol/blobdatatype.h"
#include "currency_core/currency_basic.h"
#include "cache_helper.h"
#include "currency_core/currency_format_utils.h"
#include "currency_core/currency_format_utils_blocks.h"
namespace currency
{
class scratchpad_keeper
template<class t_parent>
class scratchpad_keeper_base
{
public:
crypto::hash get_pow_hash(const block& b, const crypto::hash& scr_seed)
{
blobdata bl = get_block_hashing_blob(b);
return static_cast<t_parent*>(this)->get_pow_hash_from_blob(bl, get_block_height(b), scr_seed);
}
};
class scratchpad_keeper: public scratchpad_keeper_base<scratchpad_keeper>
{
public:
scratchpad_keeper();
bool generate(const crypto::hash& seed, uint64_t height);
crypto::hash get_pow_hash(const blobdata& bd, uint64_t height, const crypto::hash& seed);
crypto::hash get_pow_hash(const block& b, const crypto::hash& seed);
crypto::hash get_pow_hash_from_blob(const blobdata& bd, uint64_t height, const crypto::hash& seed);
uint64_t size();
private:
scratchpad_keeper(const scratchpad_keeper&) {}
@ -24,4 +38,16 @@ namespace currency
std::recursive_mutex m_lock;
};
class scratchpad_light_pool : public scratchpad_keeper_base<scratchpad_light_pool>
{
public:
scratchpad_light_pool() {}
crypto::hash get_pow_hash_from_blob(const blobdata& bd, uint64_t height, const crypto::hash& seed);
private:
//map of seed to
epee::misc_utils::cache_base<false, crypto::hash, std::shared_ptr<std::vector<crypto::hash>>, 4> m_scratchpad_pools;
std::recursive_mutex m_lock;
};
}

View file

@ -145,9 +145,10 @@ namespace currency
//check key images for transaction if it is not kept by block
if(!from_core && !kept_by_block)
{
if(have_tx_keyimges_as_spent(tx))
crypto::key_image spent_ki = AUTO_VAL_INIT(spent_ki);
if(have_tx_keyimges_as_spent(tx, &spent_ki))
{
LOG_ERROR("Transaction with id= "<< id << " used already spent key images");
LOG_ERROR("Transaction " << id << " uses already spent key image " << spent_ki);
tvc.m_verification_failed = true;
return false;
}
@ -735,15 +736,19 @@ namespace currency
return false;
}
//---------------------------------------------------------------------------------
bool tx_memory_pool::have_tx_keyimges_as_spent(const transaction& tx) const
bool tx_memory_pool::have_tx_keyimges_as_spent(const transaction& tx, crypto::key_image* p_spent_ki /* = nullptr */) const
{
for(const auto& in : tx.vin)
{
if (in.type() == typeid(txin_to_key))
{
CHECKED_GET_SPECIFIC_VARIANT(in, const txin_to_key, tokey_in, true);//should never fail
if(have_tx_keyimg_as_spent(tokey_in.k_image))
return true;
if (have_tx_keyimg_as_spent(tokey_in.k_image))
{
if (p_spent_ki)
*p_spent_ki = tokey_in.k_image;
return true;
}
}
}
@ -761,8 +766,10 @@ namespace currency
auto ki_entry_ptr = m_db_key_images_set.get(tokey_in.k_image);
if (ki_entry_ptr.get())
count = *ki_entry_ptr;
uint64_t count_before = count;
++count;
m_db_key_images_set.set(tokey_in.k_image, count);
LOG_PRINT_L2("tx pool: key image added: " << tokey_in.k_image << ", from tx " << get_transaction_hash(tx) << ", counter: " << count_before << " -> " << count);
}
}
return false;
@ -828,11 +835,13 @@ namespace currency
continue;
}
count = *ki_entry_ptr;
uint64_t count_before = count;
--count;
if (count)
m_db_key_images_set.set(tokey_in.k_image, count);
else
m_db_key_images_set.erase(tokey_in.k_image);
LOG_PRINT_L2("tx pool: key image removed: " << tokey_in.k_image << ", from tx " << get_transaction_hash(tx) << ", counter: " << count_before << " -> " << count);
}
}
return false;

View file

@ -92,7 +92,7 @@ namespace currency
bool have_tx(const crypto::hash &id)const;
bool have_tx_keyimg_as_spent(const crypto::key_image& key_im)const;
bool have_tx_keyimges_as_spent(const transaction& tx)const;
bool have_tx_keyimges_as_spent(const transaction& tx, crypto::key_image* p_spent_ki = nullptr) const;
const performnce_data& get_performnce_data() const { return m_performance_data; }

View file

@ -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);

View file

@ -152,6 +152,7 @@ int main(int argc, char* argv[])
//create objects and link them
bc_services::bc_offers_service offers_service(nullptr);
offers_service.set_disabled(true);
currency::core ccore(NULL);
currency::t_currency_protocol_handler<currency::core> cprotocol(ccore, NULL );
nodetool::node_server<currency::t_currency_protocol_handler<currency::core> > p2psrv(cprotocol);

View file

@ -42,7 +42,8 @@ daemon_backend::daemon_backend():m_pview(&m_view_stub),
m_remote_node_mode(false),
m_is_pos_allowed(false)
{
m_ccore.get_blockchain_storage().get_attachment_services_manager().add_service(&m_offers_service);
m_offers_service.set_disabled(true);
//m_ccore.get_blockchain_storage().get_attachment_services_manager().add_service(&m_offers_service);
}
const command_line::arg_descriptor<bool> arg_alloc_win_console = {"alloc-win-console", "Allocates debug console with GUI", false};
@ -204,8 +205,7 @@ bool daemon_backend::init(int argc, char* argv[], view::i_view* pview_handler)
if (command_line::has_arg(m_vm, arg_remote_node))
{
bool r = configure_for_remote_node(command_line::get_arg(m_vm, arg_remote_node));
CHECK_AND_ASSERT_MES(r, false, "Failed to configure_for_remote_node");
// configure for remote node
}
m_pview->init(path_to_html);
@ -222,18 +222,6 @@ bool daemon_backend::init(int argc, char* argv[], view::i_view* pview_handler)
CATCH_ENTRY_L0("init", false);
}
bool daemon_backend::configure_for_remote_node(const std::string& remote_host)
{
//parse node
tools::default_http_core_proxy* proxy = new tools::default_http_core_proxy();
m_rpc_proxy.reset(proxy);
bool r = proxy->set_connection_addr(remote_host);
CHECK_AND_ASSERT_MES(r, false, "Failed to assign remote node address");
proxy->set_plast_daemon_is_disconnected(&m_last_daemon_is_disconnected);
m_remote_node_mode = true;
return true;
}
bool daemon_backend::start()
{
TRY_ENTRY();
@ -618,7 +606,7 @@ std::string daemon_backend::get_my_offers(const bc_services::core_offers_filter&
size_t offers_added = offers_count_after - offers_count_before;
if (offers_added > 0)
{
LOG_PRINT("get_my_offers(): " << offers_added << " offers added from wallet " << wallet_title, LOG_LEVEL_2);
LOG_PRINT(get_wallet_log_prefix(w.second.wallet_id) + "get_my_offers(): " << offers_added << " offers added from wallet " << wallet_title, LOG_LEVEL_2);
}
++wallet_index;
@ -948,14 +936,14 @@ std::string daemon_backend::request_alias_registration(const currency::alias_rpc
}
catch (const std::exception& e)
{
LOG_ERROR("request_alias_registration error: " << e.what());
LOG_ERROR(get_wallet_log_prefix(wallet_id) + "request_alias_registration error: " << e.what());
std::string err_code = API_RETURN_CODE_INTERNAL_ERROR;
err_code += std::string(":") + e.what();
return err_code;
}
catch (...)
{
LOG_ERROR("request_alias_registration error: unknown error");
LOG_ERROR(get_wallet_log_prefix(wallet_id) + "request_alias_registration error: unknown error");
return API_RETURN_CODE_INTERNAL_ERROR;
}
}
@ -987,14 +975,14 @@ std::string daemon_backend::request_alias_update(const currency::alias_rpc_detai
}
catch (const std::exception& e)
{
LOG_ERROR("request_alias_update error: " << e.what());
LOG_ERROR(get_wallet_log_prefix(wallet_id) + "request_alias_update error: " << e.what());
std::string err_code = API_RETURN_CODE_INTERNAL_ERROR;
err_code += std::string(":") + e.what();
return err_code;
}
catch (...)
{
LOG_ERROR("request_alias_update error: unknown error");
LOG_ERROR(get_wallet_log_prefix(wallet_id) + "request_alias_update error: unknown error");
return API_RETURN_CODE_INTERNAL_ERROR;
}
}
@ -1094,14 +1082,14 @@ std::string daemon_backend::transfer(size_t wallet_id, const view::transfer_para
}
catch (const std::exception& e)
{
LOG_ERROR("Transfer error: " << e.what());
LOG_ERROR(get_wallet_log_prefix(wallet_id) + "Transfer error: " << e.what());
std::string err_code = API_RETURN_CODE_INTERNAL_ERROR;
err_code += std::string(":") + e.what();
return err_code;
}
catch (...)
{
LOG_ERROR("Transfer error: unknown error");
LOG_ERROR(get_wallet_log_prefix(wallet_id) + "Transfer error: unknown error");
return API_RETURN_CODE_INTERNAL_ERROR;
}
@ -1156,20 +1144,20 @@ std::string daemon_backend::create_proposal(size_t wallet_id,
}
catch (const tools::error::not_enough_money& e)
{
LOG_ERROR("send_escrow_proposal error: API_RETURN_CODE_NOT_ENOUGH_MONEY: " << e.what());
LOG_ERROR(get_wallet_log_prefix(wallet_id) + "send_escrow_proposal error: API_RETURN_CODE_NOT_ENOUGH_MONEY: " << e.what());
std::string err_code = API_RETURN_CODE_NOT_ENOUGH_MONEY;
return err_code;
}
catch (const std::exception& e)
{
LOG_ERROR("send_escrow_proposal error: " << e.what());
LOG_ERROR(get_wallet_log_prefix(wallet_id) + "send_escrow_proposal error: " << e.what());
std::string err_code = API_RETURN_CODE_INTERNAL_ERROR;
err_code += std::string(":") + e.what();
return err_code;
}
catch (...)
{
LOG_ERROR("send_escrow_proposal error: unknown error");
LOG_ERROR(get_wallet_log_prefix(wallet_id) + "send_escrow_proposal error: unknown error");
return API_RETURN_CODE_INTERNAL_ERROR;
}
}
@ -1225,7 +1213,7 @@ std::string daemon_backend::accept_cancel_contract(size_t wallet_id, const crypt
//TODO: add some
TIME_MEASURE_FINISH_MS(timing1);
if (timing1 > 500)
LOG_PRINT_RED_L0("[daemon_backend::accept_cancel_contract] LOW PERFORMANCE: " << timing1 );
LOG_PRINT_RED_L0(get_wallet_log_prefix(wallet_id) + "[daemon_backend::accept_cancel_contract] LOW PERFORMANCE: " << timing1 );
return API_RETURN_CODE_OK;
}
@ -1344,14 +1332,14 @@ std::string daemon_backend::push_offer(size_t wallet_id, const bc_services::offe
}
catch (const std::exception& e)
{
LOG_ERROR("push_offer error: " << e.what());
LOG_ERROR(get_wallet_log_prefix(wallet_id) + "push_offer error: " << e.what());
std::string err_code = API_RETURN_CODE_INTERNAL_ERROR;
err_code += std::string(":") + e.what();
return err_code;
}
catch (...)
{
LOG_ERROR("push_offer error: unknown error");
LOG_ERROR(get_wallet_log_prefix(wallet_id) + "push_offer error: unknown error");
return API_RETURN_CODE_INTERNAL_ERROR;
}
}
@ -1365,14 +1353,14 @@ std::string daemon_backend::cancel_offer(const view::cancel_offer_param& co, cur
}
catch (const std::exception& e)
{
LOG_ERROR("cancel_offer error: " << e.what());
LOG_ERROR(get_wallet_log_prefix(co.wallet_id) + "cancel_offer error: " << e.what());
std::string err_code = API_RETURN_CODE_INTERNAL_ERROR;
err_code += std::string(":") + e.what();
return err_code;
}
catch (...)
{
LOG_ERROR("cancel_offer error: unknown error");
LOG_ERROR(get_wallet_log_prefix(co.wallet_id) + "cancel_offer error: unknown error");
return API_RETURN_CODE_INTERNAL_ERROR;
}
}
@ -1388,14 +1376,14 @@ std::string daemon_backend::push_update_offer(const bc_services::update_offer_de
}
catch (const std::exception& e)
{
LOG_ERROR("cancel_offer error: " << e.what());
LOG_ERROR(get_wallet_log_prefix(uo.wallet_id) + "push_update_offer error: " << e.what());
std::string err_code = API_RETURN_CODE_INTERNAL_ERROR;
err_code += std::string(":") + e.what();
return err_code;
}
catch (...)
{
LOG_ERROR("cancel_offer error: unknown error");
LOG_ERROR(get_wallet_log_prefix(uo.wallet_id) + "push_update_offer error: unknown error");
return API_RETURN_CODE_INTERNAL_ERROR;
}
}
@ -1468,7 +1456,7 @@ void daemon_backend::on_transfer_canceled(size_t wallet_id, const tools::wallet_
}
else
{
LOG_ERROR("on_transfer() wallet with id = " << wallet_id << " not found");
LOG_ERROR(get_wallet_log_prefix(wallet_id) + "on_transfer() wallet with id = " << wallet_id << " not found");
}
m_pview->money_transfer_cancel(tei);
}
@ -1546,10 +1534,10 @@ void daemon_backend::wallet_vs_options::worker_func()
{
pos_minin_interval.do_call([this](){
tools::wallet2::mining_context ctx = AUTO_VAL_INIT(ctx);
LOG_PRINT_L1("Starting PoS mint iteration");
LOG_PRINT_L1(w->get()->get_log_prefix() + " Starting PoS mint iteration");
if (!w->get()->fill_mining_context(ctx) || ctx.rsp.status != CORE_RPC_STATUS_OK)
return true;
LOG_PRINT_L1("POS_ENTRIES: " << ctx.sp.pos_entries.size());
LOG_PRINT_L1(w->get()->get_log_prefix() + " POS_ENTRIES: " << ctx.sp.pos_entries.size());
tools::wallet2::scan_pos(ctx, break_mining_loop, [this](){
return *plast_daemon_network_state == currency::COMMAND_RPC_GET_INFO::daemon_network_state_online && *plast_daemon_height == last_wallet_synch_height;
}, core_conf);
@ -1558,7 +1546,7 @@ void daemon_backend::wallet_vs_options::worker_func()
{
w->get()->build_minted_block(ctx.sp, ctx.rsp);
}
LOG_PRINT_L1("PoS mint iteration finished(" << ctx.rsp.status << ")");
LOG_PRINT_L1(w->get()->get_log_prefix() + " PoS mint iteration finished(" << ctx.rsp.status << ")");
return true;
});
}
@ -1577,7 +1565,7 @@ void daemon_backend::wallet_vs_options::worker_func()
catch (const std::exception& e)
{
LOG_PRINT_L0("Failed to refresh wallet: " << e.what());
LOG_PRINT_L0(w->get()->get_log_prefix() + "Failed to refresh wallet: " << e.what());
wallet_state = wsi.wallet_state = view::wallet_status_info::wallet_state_error;
pview->update_wallet_status(wsi);
return;
@ -1585,7 +1573,7 @@ void daemon_backend::wallet_vs_options::worker_func()
catch (...)
{
LOG_PRINT_L0("Failed to refresh wallet, unknownk exception");
LOG_PRINT_L0(w->get()->get_log_prefix() + "Failed to refresh wallet, unknownk exception");
wallet_state = wsi.wallet_state = view::wallet_status_info::wallet_state_error;
pview->update_wallet_status(wsi);
return;
@ -1602,3 +1590,14 @@ daemon_backend::wallet_vs_options::~wallet_vs_options()
if (miner_thread.joinable())
miner_thread.join();
}
std::string daemon_backend::get_wallet_log_prefix(size_t wallet_id) const
{
CRITICAL_REGION_LOCAL(m_wallets_lock);
auto it = m_wallets.find(wallet_id);
if (it == m_wallets.end())
return std::string("[") + epee::string_tools::num_to_string_fast(wallet_id) + ":???]";
return std::string("[") + epee::string_tools::num_to_string_fast(wallet_id) + ":" + it->second.w->get()->get_account().get_public_address_str().substr(0, 6) + "]";
}

View file

@ -137,8 +137,8 @@ public:
void subscribe_to_core_events(currency::i_core_event_handler* pevents_handler);
void unsubscribe_to_core_events();
void get_gui_options(view::gui_options& opt);
bool is_remote_node_mode() { return m_remote_node_mode; }
bool configure_for_remote_node(const std::string& remote_host);
std::string get_wallet_log_prefix(size_t wallet_id) const;
private:
void main_worker(const po::variables_map& vm);
bool init_local_daemon();
@ -163,7 +163,7 @@ private:
view::i_view m_view_stub;
view::i_view* m_pview;
std::shared_ptr<tools::i_core_proxy> m_rpc_proxy;
critical_section m_wallets_lock;
mutable critical_section m_wallets_lock;
po::variables_map m_vm;
std::atomic<uint64_t> m_last_daemon_height;

View file

@ -542,7 +542,7 @@ bool MainWindow::init_backend(int argc, char* argv[])
QString MainWindow::is_remnotenode_mode_preconfigured()
{
return m_backend.is_remote_node_mode() ? "TRUE":"FALSE";
return "FALSE";
}
QString MainWindow::start_backend(const QString& params)
@ -555,19 +555,6 @@ QString MainWindow::start_backend(const QString& params)
ar.error_code = API_RETURN_CODE_BAD_ARG;
return MAKE_RESPONSE(ar);
}
if (sbp.configure_for_remote_node)
{
//@#@
sbp.remote_node_host = "88.198.50.112";
sbp.remote_node_port = 11512;
bool r = m_backend.configure_for_remote_node(sbp.remote_node_host + ":" + std::to_string(sbp.remote_node_port));
if (!r)
{
ar.error_code = API_RETURN_CODE_BAD_ARG;
return MAKE_RESPONSE(ar);
}
}
bool r = m_backend.start();
if (!r)
@ -584,7 +571,7 @@ bool MainWindow::update_wallet_status(const view::wallet_status_info& wsi)
m_wallet_states->operator [](wsi.wallet_id) = wsi.wallet_state;
std::string json_str;
epee::serialization::store_t_to_json(wsi, json_str);
LOG_PRINT_L0("SENDING SIGNAL -> [update_wallet_status]:" << std::endl << json_str );
LOG_PRINT_L0(get_wallet_log_prefix(wsi.wallet_id) + "SENDING SIGNAL -> [update_wallet_status]:" << std::endl << json_str );
QMetaObject::invokeMethod(this, "update_wallet_status", Qt::QueuedConnection, Q_ARG(QString, json_str.c_str()));
return true;
}
@ -627,7 +614,7 @@ bool MainWindow::money_transfer(const view::transfer_event_info& tei)
std::string json_str;
epee::serialization::store_t_to_json(tei, json_str);
LOG_PRINT_L0("SENDING SIGNAL -> [money_transfer]" << std::endl << json_str);
LOG_PRINT_L0(get_wallet_log_prefix(tei.wallet_id) + "SENDING SIGNAL -> [money_transfer]" << std::endl << json_str);
//this->money_transfer(json_str.c_str());
QMetaObject::invokeMethod(this, "money_transfer", Qt::QueuedConnection, Q_ARG(QString, json_str.c_str()));
if (!m_tray_icon)
@ -670,7 +657,7 @@ bool MainWindow::money_transfer_cancel(const view::transfer_event_info& tei)
std::string json_str;
epee::serialization::store_t_to_json(tei, json_str);
LOG_PRINT_L0("SENDING SIGNAL -> [money_transfer_cancel]");
LOG_PRINT_L0(get_wallet_log_prefix(tei.wallet_id) + "SENDING SIGNAL -> [money_transfer_cancel]");
//this->money_transfer_cancel(json_str.c_str());
QMetaObject::invokeMethod(this, "money_transfer_cancel", Qt::QueuedConnection, Q_ARG(QString, json_str.c_str()));
@ -679,7 +666,7 @@ bool MainWindow::money_transfer_cancel(const view::transfer_event_info& tei)
}
bool MainWindow::wallet_sync_progress(const view::wallet_sync_progres_param& p)
{
LOG_PRINT_L2("SENDING SIGNAL -> [wallet_sync_progress]" << " wallet_id: " << p.wallet_id << ": " << p.progress << "%");
LOG_PRINT_L2(get_wallet_log_prefix(p.wallet_id) + "SENDING SIGNAL -> [wallet_sync_progress]" << " wallet_id: " << p.wallet_id << ": " << p.progress << "%");
//this->wallet_sync_progress(epee::serialization::store_t_to_json(p).c_str());
QMetaObject::invokeMethod(this, "wallet_sync_progress", Qt::QueuedConnection, Q_ARG(QString, epee::serialization::store_t_to_json(p).c_str()));
return true;

View file

@ -215,6 +215,7 @@ private:
bool store_app_config();
bool load_app_config();
std::string get_wallet_log_prefix(size_t wallet_id) const { return m_backend.get_wallet_log_prefix(wallet_id); }
//MediatorObject mo;

View file

@ -509,14 +509,8 @@ public:
struct start_backend_params
{
bool configure_for_remote_node;
std::string remote_node_host;
uint64_t remote_node_port;
BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE(configure_for_remote_node)
KV_SERIALIZE(remote_node_host)
KV_SERIALIZE(remote_node_port)
END_KV_SERIALIZE_MAP()
};

View file

@ -1785,7 +1785,7 @@ var BackendService = /** @class */ (function () {
this.runCommand('open_wallet', params, callback);
};
BackendService.prototype.closeWallet = function (wallet_id, callback) {
this.runCommand('close_wallet', { wallet_id: wallet_id }, callback);
this.runCommand('close_wallet', { wallet_id: +wallet_id }, callback);
};
BackendService.prototype.getSmartWalletInfo = function (wallet_id, callback) {
this.runCommand('get_smart_wallet_info', { wallet_id: +wallet_id }, callback);
@ -1904,9 +1904,6 @@ var BackendService = /** @class */ (function () {
BackendService.prototype.openUrlInBrowser = function (url, callback) {
this.runCommand('open_url_in_browser', url, callback);
};
BackendService.prototype.is_remnotenode_mode_preconfigured = function (callback) {
this.runCommand('is_remnotenode_mode_preconfigured', {}, callback);
};
BackendService.prototype.start_backend = function (node, host, port, callback) {
var params = {
configure_for_remote_node: node,
@ -2605,13 +2602,8 @@ var AppComponent = /** @class */ (function () {
this.backend.initService().subscribe(function (initMessage) {
console.log('Init message: ', initMessage);
_this.backend.webkitLaunchedScript();
_this.backend.is_remnotenode_mode_preconfigured(function (status, data) {
// if (data === 'FALSE') {
// } else {
// }
_this.backend.start_backend(false, '127.0.0.1', 11512, function (st2, dd2) {
console.log(st2, dd2);
});
_this.backend.start_backend(false, '127.0.0.1', 11512, function (st2, dd2) {
console.log(st2, dd2);
});
_this.backend.eventSubscribe('quit_requested', function () {
if (!_this.onQuitRequest) {
@ -4998,7 +4990,7 @@ var ReceiveComponent = /** @class */ (function () {
/*! no static exports found */
/***/ (function(module, exports) {
module.exports = "<div class=\"content\">\r\n\r\n <div class=\"head\">\r\n <div class=\"breadcrumbs\">\r\n <span [routerLink]=\"['/main']\">{{ 'BREADCRUMBS.ADD_WALLET' | translate }}</span>\r\n <span>{{ 'BREADCRUMBS.RESTORE_WALLET' | translate }}</span>\r\n </div>\r\n <a class=\"back-btn\" [routerLink]=\"['/main']\">\r\n <i class=\"icon back\"></i>\r\n <span>{{ 'COMMON.BACK' | translate }}</span>\r\n </a>\r\n </div>\r\n\r\n <form class=\"form-restore\" [formGroup]=\"restoreForm\">\r\n\r\n <div class=\"input-block half-block\">\r\n <label for=\"wallet-name\">{{ 'RESTORE_WALLET.LABEL_NAME' | translate }}</label>\r\n <input type=\"text\" id=\"wallet-name\" formControlName=\"name\" [attr.disabled]=\"walletSaved ? '' : null\">\r\n <div class=\"error-block\" *ngIf=\"restoreForm.controls['name'].invalid && (restoreForm.controls['name'].dirty || restoreForm.controls['name'].touched)\">\r\n <div *ngIf=\"restoreForm.controls['name'].errors['required']\">\r\n {{ 'RESTORE_WALLET.FORM_ERRORS.NAME_REQUIRED' | translate }}\r\n </div>\r\n <div *ngIf=\"restoreForm.controls['name'].errors['duplicate']\">\r\n {{ 'RESTORE_WALLET.FORM_ERRORS.NAME_DUPLICATE' | translate }}\r\n </div>\r\n </div>\r\n </div>\r\n\r\n <div class=\"input-block half-block\">\r\n <label for=\"wallet-password\">{{ 'RESTORE_WALLET.PASS' | translate }}</label>\r\n <input type=\"password\" id=\"wallet-password\" formControlName=\"password\" [attr.disabled]=\"walletSaved ? '' : null\">\r\n </div>\r\n\r\n <div class=\"input-block half-block\">\r\n <label for=\"confirm-wallet-password\">{{ 'RESTORE_WALLET.CONFIRM' | translate }}</label>\r\n <input type=\"password\" id=\"confirm-wallet-password\" formControlName=\"confirm\" [attr.disabled]=\"walletSaved ? '' : null\">\r\n <div class=\"error-block\" *ngIf=\"restoreForm.controls['password'].dirty && restoreForm.controls['confirm'].dirty && restoreForm.errors\">\r\n <div *ngIf=\"restoreForm.errors['confirm_mismatch']\">\r\n {{ 'RESTORE_WALLET.FORM_ERRORS.CONFIRM_NOT_MATCH' | translate }}\r\n </div>\r\n </div>\r\n </div>\r\n\r\n <div class=\"input-block\">\r\n <label for=\"phrase-key\">{{ 'RESTORE_WALLET.LABEL_PHRASE_KEY' | translate }}</label>\r\n <input type=\"text\" id=\"phrase-key\" formControlName=\"key\" [attr.disabled]=\"walletSaved ? '' : null\">\r\n <div class=\"error-block\" *ngIf=\"restoreForm.controls['key'].invalid && (restoreForm.controls['key'].dirty || restoreForm.controls['key'].touched)\">\r\n <div *ngIf=\"restoreForm.controls['key'].errors['required']\">\r\n {{ 'RESTORE_WALLET.FORM_ERRORS.KEY_REQUIRED' | translate }}\r\n </div>\r\n <div *ngIf=\"restoreForm.controls['key'].errors['key_not_valid']\">\r\n {{ 'RESTORE_WALLET.FORM_ERRORS.KEY_NOT_VALID' | translate }}\r\n </div>\r\n </div>\r\n </div>\r\n\r\n <div class=\"wrap-buttons\">\r\n <button type=\"button\" class=\"transparent-button\" *ngIf=\"walletSaved\">{{restoreForm.controls['name'].value}}</button>\r\n <button type=\"button\" class=\"blue-button select-button\" (click)=\"saveWallet()\" [disabled]=\"!restoreForm.valid\" *ngIf=\"!walletSaved\">{{ 'RESTORE_WALLET.BUTTON_SELECT' | translate }}</button>\r\n <button type=\"button\" class=\"blue-button create-button\" (click)=\"createWallet()\" [disabled]=\"!walletSaved\">{{ 'RESTORE_WALLET.BUTTON_CREATE' | translate }}</button>\r\n </div>\r\n\r\n </form>\r\n\r\n</div>\r\n"
module.exports = "<div class=\"content\">\r\n\r\n <div class=\"head\">\r\n <div class=\"breadcrumbs\">\r\n <span [routerLink]=\"['/main']\">{{ 'BREADCRUMBS.ADD_WALLET' | translate }}</span>\r\n <span>{{ 'BREADCRUMBS.RESTORE_WALLET' | translate }}</span>\r\n </div>\r\n <a class=\"back-btn\" [routerLink]=\"['/main']\">\r\n <i class=\"icon back\"></i>\r\n <span>{{ 'COMMON.BACK' | translate }}</span>\r\n </a>\r\n </div>\r\n\r\n <form class=\"form-restore\" [formGroup]=\"restoreForm\">\r\n\r\n <div class=\"input-block half-block\">\r\n <label for=\"wallet-name\">{{ 'RESTORE_WALLET.LABEL_NAME' | translate }}</label>\r\n <input type=\"text\" id=\"wallet-name\" formControlName=\"name\" [attr.disabled]=\"walletSaved ? '' : null\">\r\n <div class=\"error-block\" *ngIf=\"restoreForm.controls['name'].invalid && (restoreForm.controls['name'].dirty || restoreForm.controls['name'].touched)\">\r\n <div *ngIf=\"restoreForm.controls['name'].errors['required']\">\r\n {{ 'RESTORE_WALLET.FORM_ERRORS.NAME_REQUIRED' | translate }}\r\n </div>\r\n <div *ngIf=\"restoreForm.controls['name'].errors['duplicate']\">\r\n {{ 'RESTORE_WALLET.FORM_ERRORS.NAME_DUPLICATE' | translate }}\r\n </div>\r\n </div>\r\n </div>\r\n\r\n <div class=\"input-block half-block\">\r\n <label for=\"wallet-password\">{{ 'RESTORE_WALLET.PASS' | translate }}</label>\r\n <input type=\"password\" id=\"wallet-password\" formControlName=\"password\" [attr.disabled]=\"walletSaved ? '' : null\">\r\n </div>\r\n\r\n <div class=\"input-block half-block\">\r\n <label for=\"confirm-wallet-password\">{{ 'RESTORE_WALLET.CONFIRM' | translate }}</label>\r\n <input type=\"password\" id=\"confirm-wallet-password\" formControlName=\"confirm\" [attr.disabled]=\"walletSaved ? '' : null\">\r\n <div class=\"error-block\" *ngIf=\"restoreForm.controls['password'].dirty && restoreForm.controls['confirm'].dirty && restoreForm.errors\">\r\n <div *ngIf=\"restoreForm.errors['confirm_mismatch']\">\r\n {{ 'RESTORE_WALLET.FORM_ERRORS.CONFIRM_NOT_MATCH' | translate }}\r\n </div>\r\n </div>\r\n </div>\r\n\r\n <div class=\"input-block\">\r\n <label for=\"phrase-key\">{{ 'RESTORE_WALLET.LABEL_PHRASE_KEY' | translate }}</label>\r\n <input type=\"text\" id=\"phrase-key\" formControlName=\"key\" [attr.disabled]=\"walletSaved ? '' : null\" (contextmenu)=\"variablesService.onContextMenu($event)\">\r\n <div class=\"error-block\" *ngIf=\"restoreForm.controls['key'].invalid && (restoreForm.controls['key'].dirty || restoreForm.controls['key'].touched)\">\r\n <div *ngIf=\"restoreForm.controls['key'].errors['required']\">\r\n {{ 'RESTORE_WALLET.FORM_ERRORS.KEY_REQUIRED' | translate }}\r\n </div>\r\n <div *ngIf=\"restoreForm.controls['key'].errors['key_not_valid']\">\r\n {{ 'RESTORE_WALLET.FORM_ERRORS.KEY_NOT_VALID' | translate }}\r\n </div>\r\n </div>\r\n </div>\r\n\r\n <div class=\"wrap-buttons\">\r\n <button type=\"button\" class=\"transparent-button\" *ngIf=\"walletSaved\">{{restoreForm.controls['name'].value}}</button>\r\n <button type=\"button\" class=\"blue-button select-button\" (click)=\"saveWallet()\" [disabled]=\"!restoreForm.valid\" *ngIf=\"!walletSaved\">{{ 'RESTORE_WALLET.BUTTON_SELECT' | translate }}</button>\r\n <button type=\"button\" class=\"blue-button create-button\" (click)=\"createWallet()\" [disabled]=\"!walletSaved\">{{ 'RESTORE_WALLET.BUTTON_CREATE' | translate }}</button>\r\n </div>\r\n\r\n </form>\r\n\r\n</div>\r\n"
/***/ }),
@ -5183,6 +5175,7 @@ __webpack_require__.r(__webpack_exports__);
/* harmony import */ var _helpers_services_backend_service__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../_helpers/services/backend.service */ "./src/app/_helpers/services/backend.service.ts");
/* harmony import */ var _angular_router__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @angular/router */ "./node_modules/@angular/router/fesm5/router.js");
/* harmony import */ var _helpers_services_variables_service__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../_helpers/services/variables.service */ "./src/app/_helpers/services/variables.service.ts");
/* harmony import */ var _helpers_services_modal_service__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../_helpers/services/modal.service */ "./src/app/_helpers/services/modal.service.ts");
var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@ -5196,12 +5189,14 @@ var __metadata = (undefined && undefined.__metadata) || function (k, v) {
var SeedPhraseComponent = /** @class */ (function () {
function SeedPhraseComponent(route, router, backend, variablesService, ngZone) {
function SeedPhraseComponent(route, router, backend, variablesService, modalService, ngZone) {
this.route = route;
this.router = router;
this.backend = backend;
this.variablesService = variablesService;
this.modalService = modalService;
this.ngZone = ngZone;
this.seedPhrase = '';
}
@ -5246,6 +5241,7 @@ var SeedPhraseComponent = /** @class */ (function () {
}
else {
this.variablesService.opening_wallet = null;
this.modalService.prepareModal('error', 'OPEN_WALLET.WITH_ADDRESS_ALREADY_OPEN');
this.backend.closeWallet(this.wallet_id, function (close_status, close_data) {
console.log(close_status, close_data);
_this.ngZone.run(function () {
@ -5267,6 +5263,7 @@ var SeedPhraseComponent = /** @class */ (function () {
_angular_router__WEBPACK_IMPORTED_MODULE_2__["Router"],
_helpers_services_backend_service__WEBPACK_IMPORTED_MODULE_1__["BackendService"],
_helpers_services_variables_service__WEBPACK_IMPORTED_MODULE_3__["VariablesService"],
_helpers_services_modal_service__WEBPACK_IMPORTED_MODULE_4__["ModalService"],
_angular_core__WEBPACK_IMPORTED_MODULE_0__["NgZone"]])
], SeedPhraseComponent);
return SeedPhraseComponent;

File diff suppressed because one or more lines are too long

View file

@ -347,7 +347,7 @@ export class BackendService {
}
closeWallet(wallet_id, callback) {
this.runCommand('close_wallet', {wallet_id: wallet_id}, callback);
this.runCommand('close_wallet', {wallet_id: +wallet_id}, callback);
}
getSmartWalletInfo(wallet_id, callback) {
@ -485,10 +485,6 @@ export class BackendService {
this.runCommand('open_url_in_browser', url, callback);
}
is_remnotenode_mode_preconfigured(callback) {
this.runCommand('is_remnotenode_mode_preconfigured', {}, callback);
}
start_backend(node, host, port, callback) {
const params = {
configure_for_remote_node: node,

View file

@ -66,13 +66,8 @@ export class AppComponent implements OnInit, OnDestroy {
this.backend.webkitLaunchedScript();
this.backend.is_remnotenode_mode_preconfigured((status, data) => {
// if (data === 'FALSE') {
// } else {
// }
this.backend.start_backend(false, '127.0.0.1', 11512, (st2, dd2) => {
console.log(st2, dd2);
});
this.backend.start_backend(false, '127.0.0.1', 11512, (st2, dd2) => {
console.log(st2, dd2);
});
this.backend.eventSubscribe('quit_requested', () => {

View file

@ -43,7 +43,7 @@
<div class="input-block">
<label for="phrase-key">{{ 'RESTORE_WALLET.LABEL_PHRASE_KEY' | translate }}</label>
<input type="text" id="phrase-key" formControlName="key" [attr.disabled]="walletSaved ? '' : null">
<input type="text" id="phrase-key" formControlName="key" [attr.disabled]="walletSaved ? '' : null" (contextmenu)="variablesService.onContextMenu($event)">
<div class="error-block" *ngIf="restoreForm.controls['key'].invalid && (restoreForm.controls['key'].dirty || restoreForm.controls['key'].touched)">
<div *ngIf="restoreForm.controls['key'].errors['required']">
{{ 'RESTORE_WALLET.FORM_ERRORS.KEY_REQUIRED' | translate }}

View file

@ -2,6 +2,7 @@ import {Component, NgZone, OnDestroy, OnInit} from '@angular/core';
import {BackendService} from '../_helpers/services/backend.service';
import {ActivatedRoute, Router} from '@angular/router';
import {VariablesService} from '../_helpers/services/variables.service';
import {ModalService} from '../_helpers/services/modal.service';
@Component({
selector: 'app-seed-phrase',
@ -19,6 +20,7 @@ export class SeedPhraseComponent implements OnInit, OnDestroy {
private router: Router,
private backend: BackendService,
private variablesService: VariablesService,
private modalService: ModalService,
private ngZone: NgZone
) {}
@ -60,6 +62,7 @@ export class SeedPhraseComponent implements OnInit, OnDestroy {
});
} else {
this.variablesService.opening_wallet = null;
this.modalService.prepareModal('error', 'OPEN_WALLET.WITH_ADDRESS_ALREADY_OPEN');
this.backend.closeWallet(this.wallet_id, (close_status, close_data) => {
console.log(close_status, close_data);
this.ngZone.run(() => {

View file

@ -1062,8 +1062,9 @@ namespace nodetool
ce.time_started = cntxt.m_started;
ce.last_recv = cntxt.m_last_recv;
ce.last_send = cntxt.m_last_send;
std::strncpy(ce.version, cntxt.m_remote_version.c_str(), std::min(sizeof(ce.version), cntxt.m_remote_version.size()));
ce.version[sizeof(ce.version) - 1] = 0; //null terminating just to be sure
size_t len = std::min(sizeof(ce.version) - 1, cntxt.m_remote_version.size());
std::strncpy(ce.version, cntxt.m_remote_version.c_str(), len);
ce.version[len] = 0; //null terminating just to be sure
rsp.connections_list.push_back(ce);
return true;
});

View file

@ -156,6 +156,8 @@ namespace currency
m_core.get_blockchain_storage().get_top_block(b);
res.last_block_total_reward = currency::get_reward_from_miner_tx(b.miner_tx);
res.pos_diff_total_coins_rate = (pos_diff / (res.total_coins - PREMINE_AMOUNT + 1)).convert_to<uint64_t>();
res.last_block_timestamp = b.timestamp;
res.last_block_hash = string_tools::pod_to_hex(get_block_hash(b));
}
if (req.flags&COMMAND_RPC_GET_INFO_FLAG_POS_BLOCK_TS_SHIFT_VS_ACTUAL)
{
@ -792,6 +794,7 @@ namespace currency
blobdata block_blob = t_serializable_object_to_blob(b);
res.blocktemplate_blob = string_tools::buff_to_hex_nodelimer(block_blob);
res.prev_hash = string_tools::pod_to_hex(b.prev_id);
res.status = CORE_RPC_STATUS_OK;
return true;

View file

@ -660,6 +660,8 @@ namespace currency
uint64_t tx_count_in_last_block;
uint64_t default_fee;
uint64_t minimum_fee;
uint64_t last_block_timestamp;
std::string last_block_hash;
//market
uint64_t offers_count;
@ -708,6 +710,8 @@ namespace currency
KV_SERIALIZE(tx_count_in_last_block)
KV_SERIALIZE(default_fee)
KV_SERIALIZE(minimum_fee)
KV_SERIALIZE(last_block_timestamp)
KV_SERIALIZE(last_block_hash)
KV_SERIALIZE(offers_count)
END_KV_SERIALIZE_MAP()
};
@ -788,6 +792,7 @@ namespace currency
uint64_t height;
crypto::hash seed;
blobdata blocktemplate_blob;
std::string prev_hash;
std::string status;
BEGIN_KV_SERIALIZE_MAP()
@ -795,6 +800,7 @@ namespace currency
KV_SERIALIZE(height)
KV_SERIALIZE_POD_AS_HEX_STRING(seed)
KV_SERIALIZE(blocktemplate_blob)
KV_SERIALIZE(prev_hash)
KV_SERIALIZE(status)
END_KV_SERIALIZE_MAP()
};

View file

@ -2,6 +2,6 @@
#define BUILD_COMMIT_ID "@VERSION@"
#define PROJECT_VERSION "1.0"
#define PROJECT_VERSION_BUILD_NO 8
#define PROJECT_VERSION_BUILD_NO 9
#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 "]"

View file

@ -1757,6 +1757,11 @@ namespace
}
}
//----------------------------------------------------------------------------------------------------
void wallet2::init_log_prefix()
{
m_log_prefix = m_account.get_public_address_str().substr(0, 6);
}
//----------------------------------------------------------------------------------------------------
void wallet2::load_keys(const std::string& buff, const std::string& password)
{
wallet2::keys_file_data keys_file_data;
@ -1781,14 +1786,14 @@ void wallet2::load_keys(const std::string& buff, const std::string& password)
WLT_LOG_L0("Wrong password for wallet " << string_encoding::convert_to_ansii(m_wallet_file));
tools::error::throw_wallet_ex<error::invalid_password>(std::string(__FILE__ ":" STRINGIZE(__LINE__)));
}
m_log_prefix = m_account.get_public_address_str().substr(0, 6);
init_log_prefix();
}
//----------------------------------------------------------------------------------------------------
void wallet2::assign_account(const currency::account_base& acc)
{
clear();
m_account = acc;
init_log_prefix();
}
//----------------------------------------------------------------------------------------------------
void wallet2::generate(const std::wstring& path, const std::string& pass)
@ -1797,6 +1802,7 @@ void wallet2::generate(const std::wstring& path, const std::string& pass)
m_wallet_file = path;
m_password = pass;
m_account.generate();
init_log_prefix();
boost::system::error_code ignored_ec;
THROW_IF_TRUE_WALLET_EX(boost::filesystem::exists(m_wallet_file, ignored_ec), error::file_exists, epee::string_encoding::convert_to_ansii(m_wallet_file));
store();
@ -1808,6 +1814,7 @@ void wallet2::restore(const std::wstring& path, const std::string& pass, const s
m_wallet_file = path;
m_password = pass;
bool r = m_account.restore_keys_from_braindata(restore_key);
init_log_prefix();
THROW_IF_TRUE_WALLET_EX(!r, error::wallet_internal_error, epee::string_encoding::convert_to_ansii(m_wallet_file));
boost::system::error_code ignored_ec;
THROW_IF_TRUE_WALLET_EX(boost::filesystem::exists(m_wallet_file, ignored_ec), error::file_exists, epee::string_encoding::convert_to_ansii(m_wallet_file));

View file

@ -255,7 +255,8 @@ namespace tools
void store();
void store(const std::wstring& path);
std::wstring get_wallet_path(){ return m_wallet_file; }
currency::account_base& get_account(){return m_account;}
currency::account_base& get_account() { return m_account; }
const currency::account_base& get_account() const { return m_account; }
void get_recent_transfers_history(std::vector<wallet_rpc::wallet_transfer_info>& trs, size_t offset, size_t count);
uint64_t get_recent_transfers_total_count();
@ -497,6 +498,8 @@ namespace tools
std::vector<currency::tx_destination_entry>& prepared_destinations,
crypto::hash multisig_id = currency::null_hash);
std::string get_log_prefix() const { return m_log_prefix; }
private:
void add_transfers_to_expiration_list(const std::vector<uint64_t>& selected_transfers, uint64_t expiration, uint64_t change_amount, const crypto::hash& related_tx_id);
void remove_transfer_from_expiration_list(uint64_t transfer_index);
@ -596,6 +599,8 @@ private:
void fill_transfer_details(const currency::transaction& tx, const tools::money_transfer2_details& td, tools::wallet_rpc::wallet_transfer_info_details& res_td) const;
void print_source_entry(const currency::tx_source_entry& src) const;
void init_log_prefix();
struct construct_tx_param
{
std::vector<currency::tx_destination_entry> dsts;

View file

@ -62,11 +62,9 @@ add_test(coretests coretests)
# set PCH for core_tests
if(MSVC)
if(MSVC AND USE_PCH)
set_property(TARGET coretests APPEND_STRING PROPERTY COMPILE_FLAGS " /Yuchaingen.h /Zm1000")
set_property(SOURCE "core_tests/chaingen.cpp" APPEND_STRING PROPERTY COMPILE_FLAGS " /Ycchaingen.h /Zm1000")
if(USE_PCH) # see also src/CMakeLists.txt for details
set_property(TARGET coretests difficulty-tests functional_tests hash-target-tests performance_tests unit_tests APPEND_STRING PROPERTY LINK_FLAGS "$(MSBuildProjectDirectory)/../src/$(ConfigurationName)/stdafx.obj")
set_property(TARGET db_tests APPEND_STRING PROPERTY LINK_FLAGS "$(MSBuildProjectDirectory)/../../src/$(ConfigurationName)/stdafx.obj")
endif()
set_property(TARGET coretests difficulty-tests functional_tests hash-target-tests performance_tests unit_tests APPEND_STRING PROPERTY LINK_FLAGS "$(MSBuildProjectDirectory)/../src/$(ConfigurationName)/stdafx.obj")
set_property(TARGET db_tests APPEND_STRING PROPERTY LINK_FLAGS "$(MSBuildProjectDirectory)/../../src/$(ConfigurationName)/stdafx.obj")
endif()

View file

@ -597,7 +597,7 @@ gen_no_attchments_in_coinbase::gen_no_attchments_in_coinbase()
// NOTE: This test is made deterministic to be able to correctly set up checkpoint.
random_state_test_restorer::reset_random(); // random generator's state was previously stored, will be restore on dtor (see also m_random_state_test_restorer)
bool r = m_miner_acc.restore_keys_from_braindata("confusion reason crash guess dude scatter rabbit view story protect trickle gather");
bool r = m_miner_acc.restore_keys_from_braindata("battle harsh arrow gain best doubt nose raw protect salty apart tell distant final yeah stubborn true stop shoulder breathe throne problem everyone stranger only");
CHECK_AND_ASSERT_THROW_MES(r, "gen_no_attchments_in_coinbase: Can't restore account from braindata");
REGISTER_CALLBACK_METHOD(gen_no_attchments_in_coinbase, c1);
@ -628,7 +628,7 @@ bool gen_no_attchments_in_coinbase::init_config_set_cp(currency::core& c, size_t
crc.pos_minimum_heigh = 1;
c.get_blockchain_storage().set_core_runtime_config(crc);
m_checkpoints.add_checkpoint(12, "d34f992c250cad590b474bf0096273fb9beb0d5540a258b46bbbe6e99632fc1a");
m_checkpoints.add_checkpoint(12, "4ba98ca9d92e99e28a30bd5395a305213be2fc18372bbf94ef216ba017640e56");
c.set_checkpoints(currency::checkpoints(m_checkpoints));
return true;

View file

@ -1625,7 +1625,7 @@ multisig_and_checkpoints::multisig_and_checkpoints()
bool multisig_and_checkpoints::set_cp(currency::core& c, size_t ev_index, const std::vector<test_event_entry>& events)
{
currency::checkpoints checkpoints;
checkpoints.add_checkpoint(15, "697d829dd0898fd8c766f5cfc9c174ba353d0c0ebf48def8edec0e2f2e355781");
checkpoints.add_checkpoint(15, "816f96e8a0e259491ed7e03ef0f2eea69762276152f4990d71f657b1e37d8764");
c.set_checkpoints(std::move(checkpoints));
return true;

View file

@ -1,3 +1,3 @@
add_executable(db_tests db_tests.cpp)
target_link_libraries(db_tests crypto common lmdb zlib ${Boost_LIBRARIES})
target_link_libraries(db_tests crypto common lmdb zlibstatic ${Boost_LIBRARIES})

View file

@ -100,14 +100,14 @@ currency::wide_difficulty_type bbr_next_difficulty(std::vector<uint64_t>& timest
void get_cut_location_from_len(size_t length, size_t& cut_begin, size_t& cut_end, size_t REDEF_DIFFICULTY_WINDOW, size_t REDEF_DIFFICULTY_CUT_OLD, size_t REDEF_DIFFICULTY_CUT_LAST)
{
if (length <= REDEF_DIFFICULTY_WINDOW)
if (length <= REDEF_DIFFICULTY_WINDOW - (REDEF_DIFFICULTY_CUT_OLD+ REDEF_DIFFICULTY_CUT_LAST))
{
cut_begin = 0;
cut_end = length;
}
else
{
cut_begin = REDEF_DIFFICULTY_WINDOW - REDEF_DIFFICULTY_CUT_LAST + 1;
cut_begin = REDEF_DIFFICULTY_CUT_LAST;
cut_end = cut_begin + (REDEF_DIFFICULTY_WINDOW - (REDEF_DIFFICULTY_CUT_OLD + REDEF_DIFFICULTY_CUT_LAST));
}
}
@ -154,7 +154,7 @@ currency::wide_difficulty_type bbr_next_difficulty_composit(std::vector<uint64_t
sort(timestamps.begin(), timestamps.end(), std::greater<uint64_t>());
std::vector<uint64_t> timestamps_local = timestamps;
currency::wide_difficulty_type dif = bbr_next_difficulty_configurable(timestamps_local, cumulative_difficulties, target_seconds, REDEF_DIFFICULTY_WINDOW, REDEF_DIFFICULTY_CUT_OLD, REDEF_DIFFICULTY_CUT_LAST);
currency::wide_difficulty_type dif2 = bbr_next_difficulty_configurable(timestamps_local, cumulative_difficulties, target_seconds, 200, 5, 5);
currency::wide_difficulty_type dif2 = bbr_next_difficulty_configurable(timestamps_local, cumulative_difficulties, target_seconds, 240, 5, 5);
currency::wide_difficulty_type dif3 = bbr_next_difficulty_configurable(timestamps_local, cumulative_difficulties, target_seconds, 40, 1, 1);
return (dif3 + dif2 + dif) / 3;
}
@ -300,10 +300,19 @@ void run_emulation(const std::string& path)
}); \
current_index+=2;
#define PERFORME_SIMULATION_FOR_FUNCTION_NO_WINDOW(func_name) \
perform_simulation_for_function(timestamp_to_hashrate, current_index, blocks, result_blocks, \
[&](std::vector<uint64_t>& timestamps, std::vector<currency::wide_difficulty_type>& cumulative_difficulties, size_t target_seconds) \
{ \
return func_name(timestamps, cumulative_difficulties, target_seconds); \
}); \
current_index+=2;
PERFORME_SIMULATION_FOR_FUNCTION(bbr_next_difficulty_configurable, BBR_DIFFICULTY_WINDOW, BBR_DIFFICULTY_CUT, BBR_DIFFICULTY_CUT);
PERFORME_SIMULATION_FOR_FUNCTION(bbr_next_difficulty_configurable, 500, 60, 60);
PERFORME_SIMULATION_FOR_FUNCTION(bbr_next_difficulty_configurable, 300, 60, 60);
PERFORME_SIMULATION_FOR_FUNCTION(bbr_next_difficulty_composit, 720, 60, 60);
PERFORME_SIMULATION_FOR_FUNCTION_NO_WINDOW(currency::next_difficulty);
print_blocks(result_blocks, path + "result.txt");
LOG_PRINT_L0("Done");

View file

@ -7,7 +7,7 @@
#include "crypto/crypto.h"
#include "currency_core/currency_basic.h"
#include "profile_tools.h"
extern "C" {
#include "crypto/keccak.h"
@ -18,7 +18,7 @@ extern "C" {
#include "crypto/wild_keccak.h"
//#include "crypto/wild_keccak2.h"
#include "../core_tests/random_helper.h"
#include "crypto/hash.h"
@ -151,59 +151,57 @@ protected:
#ifdef _DEBUG
#define max_measere_scratchpad 100000
#else
#define max_measere_scratchpad 10000000
#define max_measere_scratchpad 50000000
#endif
#define measere_rounds 10000
void measure_keccak_over_scratchpad()
void generate_scratchpad()
{
std::cout << std::setw(20) << std::left << "sz\t" <<
crypto::hash seed = crypto::cn_fast_hash("sdssdsffdss", 10);
std::vector<crypto::hash> scratchpad;
size_t count = 500000000 / 32;
TIME_MEASURE_START_MS(gen_time);
LOG_PRINT_L0("Generating....");
crypto::generate_scratchpad2(seed, scratchpad, count);
TIME_MEASURE_FINISH_MS(gen_time);
LOG_PRINT_L0("Generated scratchpad " << (scratchpad.size() * 32) / (1024 * 1024) << "MB in " << gen_time << "ms");
}
void generate_light_scratchpad()
{
crypto::hash seed = crypto::cn_fast_hash("sdssdsffdss", 10);
std::vector<crypto::hash> scratchpad;
size_t count = 500000000 / 32;
TIME_MEASURE_START_MS(gen_time);
LOG_PRINT_L0("Generating....");
crypto::generate_scratchpad_light(seed, scratchpad, count);
TIME_MEASURE_FINISH_MS(gen_time);
LOG_PRINT_L0("Generated scratchpad " << (scratchpad.size() * 32) / (1024 * 1024) << "MB in " << gen_time << "ms");
}
void measure_keccak_over_scratchpad(uint64_t start_scratchpad_size, uint64_t step_size)
{
// std::cout << std::setw(20) << std::left << "sz\t" <<
//std::setw(10) << "original\t" <<
std::setw(10) << "original opt\t" <<
// std::setw(10) << "original opt\t" <<
// std::setw(10) << "w2\t" <<
std::setw(10) << "w2_opt" << ENDL;
// std::setw(10) << "w2_opt" << ENDL;
std::vector<crypto::hash> scratchpad_vec;
scratchpad_vec.resize(max_measere_scratchpad);
std::string has_str = "Keccak is a family of sponge functions. The sponge function is a generalization of the concept of cryptographic hash function with infinite output and can perform quasi all symmetric cryptographic functions, from hashing to pseudo-random number generation to authenticated encryption";
//static const uint64_t my_own_random_seed = 4669201609102990671;
//random_state_test_restorer::reset_random(my_own_random_seed); // random seeded, entering deterministic mode...
//uint64_t size_original = scratchpad_vec.size();
//scratchpad_vec.resize(i / sizeof(crypto::hash));
for (size_t j = 0; j != scratchpad_vec.size(); j++)
scratchpad_vec[j] = crypto::rand<crypto::hash>();
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);
OPT_XOR_4_RES(scratchpad_vec[0], scratchpad_vec[1], scratchpad_vec[2], scratchpad_vec[3], res_etalon);
//
// crypto::hash res_h1 = currency::null_hash;
// res_h1 = crypto::get_wild_keccak2_over_scratchpad(has_str, 1, scratchpad_vec, 1000);
//
// crypto::hash res_h2 = currency::null_hash;
// crypto::get_wild_keccak2(has_str, res_h2, 1, scratchpad_vec, 1000);
// if (res_h2 != res_h1)
// {
// return;
// }
for (uint64_t i = 1000; i < max_measere_scratchpad; i += 100000)
for (uint64_t i = start_scratchpad_size; i < max_measere_scratchpad; i += i/10)
{
crypto::hash res_h = currency::null_hash;
uint64_t ticks_a = epee::misc_utils::get_tick_count();
*(uint64_t*)(&has_str[8]) = i;
//original keccak
// for (size_t r = 0; r != measere_rounds; r++)
// {
// *(size_t*)(&has_str[0]) = r;
// res_h = crypto::get_blob_longhash(has_str, 1, scratchpad_vec, i);
// }
//original keccak opt
uint64_t ticks_b = epee::misc_utils::get_tick_count();
for (size_t r = 0; r != measere_rounds; r++)
{
@ -213,11 +211,11 @@ void measure_keccak_over_scratchpad()
//wild keccak 2
uint64_t ticks_c = epee::misc_utils::get_tick_count();
// for (size_t r = 0; r != measere_rounds; r++)
// {
// *(size_t*)(&has_str[1]) = r;
// res_h = crypto::get_wild_keccak2_over_scratchpad(has_str, 1, scratchpad_vec, i);
// }
for (size_t r = 0; r != measere_rounds; r++)
{
*(size_t*)(&has_str[1]) = r;
res_h = crypto::cn_fast_hash(has_str.data(), has_str.size());
}
//wild keccak 2 opt
uint64_t ticks_d = epee::misc_utils::get_tick_count();
for (size_t r = 0; r != measere_rounds; r++)
@ -228,8 +226,15 @@ void measure_keccak_over_scratchpad()
uint64_t ticks_e = epee::misc_utils::get_tick_count();
std::cout << std::setw(20) << std::left << i * sizeof(crypto::hash) << "\t" <<
//std::setw(10) << ticks_b - ticks_a << "\t" <<
std::setw(10) << ticks_c - ticks_b << "\t" <<
//std::setw(10) << ticks_d - ticks_c << "\t" <<
//std::setw(10) << ticks_c - ticks_b << "\t" <<
std::setw(10) << ticks_d - ticks_c << "\t" <<
std::setw(10) << ticks_e - ticks_d << ENDL;
}
}
void measure_keccak_over_scratchpad()
{
//measure_keccak_over_scratchpad(100/32, 100/32);
//measure_keccak_over_scratchpad(10, max_measere_scratchpad / 10);
measure_keccak_over_scratchpad(max_measere_scratchpad/10, 0);
}

View file

@ -35,8 +35,10 @@ int main(int argc, char** argv)
performance_timer timer;
timer.start();
measure_keccak_over_scratchpad();
//generate_scratchpad();
//generate_light_scratchpad();
//measure_keccak_over_scratchpad();
test_scratchpad_against_light_scratchpad();
/*
TEST_PERFORMANCE2(test_construct_tx, 1, 1);
TEST_PERFORMANCE2(test_construct_tx, 1, 2);

View file

@ -2,188 +2,50 @@
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
/*
DISCLAIMER:
Due to hash change (Wild Keccak -> x11 -> Ethash) this test should be completely rewritten.
Also consider using this function:
crypto::hash get_block_longhash(const blobdata& bd)
{
crypto::hash result = null_hash;
block b = AUTO_VAL_INIT(b);
if (parse_and_validate_block_from_blob(bd, b))
{
blobdata local_bd = bd;
access_nonce_in_block_blob(local_bd) = 0;
crypto::hash bl_hash = crypto::cn_fast_hash(local_bd.data(), local_bd.size());
result = get_block_longhash(get_block_height(b), bl_hash, b.nonce);
}
return result;
}
#include "gtest/gtest.h"
#include "crypto/crypto.h"
#include "currency_core/currency_basic.h"
#include "profile_tools.h"
#include "crypto/wild_keccak.h"
#include "currency_core/currency_format_utils.h"
using namespace currency;
const char* test_hashes[51] = {
"0069fbf4c58a4d48ef3134f277c7a711da33fc030fdbf4a6a9eee372616c0f57",
"2ea7ddcbc819ad4fe96def105335773a19e83b8ee04272c63ec034425fbbcccd",
"995cd314592747e673487a8eab8bd8a97bc32c078cc2b975b73cae2c031af7c3",
"8daba3abaeaf44848d4800c44b237638e2ac1650ac58917e34ede513825696ff",
"95d5d7e08e2cc6d81211342b43f7a6ccdd0f05248bd59d5390bcc6c5cea89aae",
"7949d3d906bb66871bca78ef0e4b56f999e000fff987a58b90efef5073b6b27c",
"87ce7ee6527a533c5ac900b0b28d88996ad965d18a8182329e187cfaa96e1272",
"cd6385547b7f64cd2e09455d0b540334d542302600a8f08c7ccd265759a4b324",
"4ba77c0da65bee3088eaca598bfe63a71c257850a16535f3e2e2518cef306aed",
"794372f55692df868c4ca53ff879aa7dddbb290f3fe4a19297ddf4d5e08fe6ad",
"d16e207f9fdb2e61d738cd4318a6024cba9512d56b1624b76d03e5453fb88818",
"39a7669648a0f54f0a1bc311267a0cc124ceee34bfbd6a60a8d43ba5437e8a4f",
"0e6d1192662c71b65201a27d35f1da933e7070c42186f104c9ae1c231ea09f8a",
"9b8cfe7c7acef37ff11b3e9bdfd69c998c63a42adf42b569ab111ef1cfa12afe",
"f83187e1e7c6c3f4d0f7ab964da16f39a78a47dc8ce0aa8df55abc689283f3ed",
"7e2fd86fb9de617bba76a9382772a7aa4369d626c5e127f9699fc464ea1f21b2",
"9a53eb68c7e8b1a4177029014350dea2b7023aae777d5a2509cedb946e794ccb",
"127442cf4d970764cd903b0620c613ffdf92ad43aef9054edf54647ee8ee9a79",
"d7fc147f5a5ddf4f8131c2721498f2bd10a36a50d79bd7f7b1c03e765c4fe16a",
"a7b3729a2a4a9c393e342003edf265aa88a704ff4a659f3ef5326a666f73ebe3",
"3574f8e0c1dd85b704d2dbd9dddc5e9007bb9903e5654f921acd2e1e7be8d6ea",
"a5037e77c4d2c789e32b22e74366c32ee0697c5b4f958d98e3743a704ffc977a",
"d417520014ada3ec182b5cc1ce05ab29b204b1e3545ebee44136eb15801ec042",
"7c17de8607cdcb7776671803504f1f78015df93ee8ae9c1e269ec5dc228e0f31",
"c4679efc2fc306fcb1f3ea7c509ee87daa3b66e54696e63ca4a58235e15f72fc",
"4de02c7066962e6f31c1a686d241d067498d2d326ae69b6588baf49fd62b927d",
"035c335ce07a60387e835858f690376c87993585f4e26964cf33623a90decf2d",
"14ccc27cfb8f2d643cdb775c0afbed38bd30cbe64087bfb12a2a8ee5d185f16a",
"4e19d5a360b3c3de7364d8b7fa53f1c0d051ddc993b32f8356a2123020bc4d94",
"e10e90853db58de03423c5c9f02751c002b11db0baef5428612fc3f2e71fd52b",
"e5f91c2a5a6b33652d2af2d473e07996a26aadf9c545be361555191ef4d8b101",
"2f595481d3fc0d8636d73b95b1b94ea50aeb956a4eeeb06d45d3d8691de5984c",
"5f53e64b1a06be5b2b7b597f462a0ac079cb4a05243b560165688c90867580f2",
"3254d508fe51c42526045048bee5cd29516477180ea8522f1f3b0cc249d98959",
"df364e5c4c10083b8d19639ea04cb23c8268fef04c6601f8fbff284cca4a6e64",
"1a15e83c9bc8bd6ca38e05f2e3318eb50deaa1b4f0d44316d0a16ac608fcf8ec",
"1e4614f61d7c78480fbac8d79863b05ac7c47fd7856489796b10aada9b472b87",
"1ea359c55bef9fa54fc0a89dcdab63281f93ffd0d373d7f29d96ba4f9df0f560",
"f4f58ce5f6afba27075b0d1566a2534cd12a1d546792c50acc0506ebfaf6e5b6",
"4b8feee88ff37929cab4c2aa50334b4908f6b0019da75a4cbb00d759737b0b97",
"07c6c8f4303e456b7f350ffc19a14c0daa303ef38cbf8ed729d0a65cc0d0fe31",
"2cc3c3c065689c1e2639e76aa75d7c7a2356045038bd8e39492f9b5752356b0c",
"ab6c1c109b0ca67f75a54a8b353f817b0704b8dc70ffc7d97eaa45616348f4eb",
"53e23a7291704817fc8a84cf332ef99aa5388cf6cd0d3ca59f2483ff57703849",
"408a8c0141abbdef767669a1624f2d49b24cc277a11d042e318cc64fd41001dd",
"3daf24a36a87fd5c2eda7cf4d58da3eafc3cc26e2a343d97a02a12ecf76eb0a1",
"0c53057b47dac5a7539ec806148fe6534186af5325b0f35014f1abfb4fcf0be1",
"b5404f47ddb58667422ef37a1fa9611565b0c6d4ce07b106ef43832e5a57988d",
"4ae02032ed82d1aed440b4351bd4f0baf54e3c18b853b48f60aea2556d0b1e2b",
"5a017e9303c9d18efaf8716445a3786d81126030f2803646db01d424161461e1",
"83325584cdca2a153a26fb3f5b7a9cc89171bb62c1db85bdba7e113c773f5f41"
};
bool test_scratchpad_against_light_scratchpad()
{
crypto::hash seed = crypto::cn_fast_hash("sdssdsffdss", 10);
std::vector<crypto::hash> scratchpad;
size_t count = 400;
TIME_MEASURE_START_MS(gen_time);
LOG_PRINT_L0("Generating full ....");
crypto::generate_scratchpad2(seed, scratchpad, count);
TIME_MEASURE_FINISH_MS(gen_time);
LOG_PRINT_L0("Generated full scratchpad " << (scratchpad.size() * 32) / (1024 * 1024) << "MB in " << gen_time << "ms");
std::vector<crypto::hash> scratchpad_light;
crypto::generate_scratchpad_light(seed, scratchpad_light, count);
const char* test_srings[] = {
"",
"President Obama is ready to use American air power in targeted and precise military action",
"Roy Hodgson insisted last night that he would not quit despite admitting that England's World Cup dream was all but over",
};
struct hash_result
{
size_t scratch_size;
size_t string_no;
const char* expected_hash;
};
hash_result expected_results[] =
std::string hashing_str = "dsfssfadfada";
crypto::hash full_h = currency::null_hash;
crypto::hash light_h = currency::null_hash;
crypto::get_wild_keccak2(hashing_str, full_h, scratchpad);
crypto::get_wild_keccak_light(hashing_str, light_h, scratchpad_light);
if (full_h != light_h)
{
{1,0,"b2767f554a15e3471c854118f62c2cc0959ccd6c67a70e75f80f85f548a715bb"},
{10,0,"7071b26139d8469916adba2ada612adc7c767344564907e977bb7466d7cc69ab"},
{100,0,"3fd77bcacf0c579618a9b5f054223692a5cf56926f95a1a5df4a57e044100a20"},
{1000,0,"5a7fc927e8eff077557cc4ad6a4691d4036548ba3131374a543d685e94ea1ea0"},
{10000,0,"d672d0d532fcd0e3a6796975a1ee976f0eae0572d531c5eb45fe0c178099f48f"},
{100000,0,"c7cadb46cbb5575d5bd01d9a8272e427a0f5bc5df69e400c93f5595da78c52d1"},
{1,1,"1a7656a4f0403c3cd2ef7a1471bd5d7a18c7965921e1d03ad12209cca6302cb9"},
{10,1,"94a747ddb33cb6d3908a1e47930903dfd06c365020db0a176b4b5609a37a19f3"},
{100,1,"bcabc30513f4f2b7ff907e86d0fed06894b11a3b11e3e273c26e08f7b5f0666f"},
{1000,1,"03e2ede9f00079404457c385375122e9a0e6f10216f62f70d789cc9ab4491694"},
{10000,1,"ed9594fc45b5161af4d16293449c042ad2508f0c86ef6f42352ec72ae6d94a0a"},
{100000,1,"6650ca0ad0132f85ae757f9a5e41efb638fde7efe2bf2a7e113a7d3d6bd8189d"},
{1,2,"b1d3119e86600023f18aa1e633059de545c835dff2392457e6cac92f1a0da5be"},
{10,2,"fdb1ff6b103d056fe3d68de3deabf0e568cbca56ab5b3b46197a078d5fc2a83b"},
{100,2,"f9acedad2cdca5d5fe2eb0da62d651bb5a8f7dfc9becc4ba9530d71f531effba"},
{1000,2,"4f319beb818183d51cb203c9fa26cd250c67bf3e1fec62995d122dbf8df7292b"},
{10000,2,"e5d95f8465af6e41f132e6e3a625d8b4e6f41c30a85808137b1ae07635bd7804"},
{100000,2,"8ea12900e89a9002080605f06d85b6aab3c584cef761886f450c163ee65168f3"}
};
bool add_hash_str_to_hash_vector(const std::string& str, std::vector<crypto::hash>& scratchpad)
{
crypto::hash h = null_hash;
bool r = epee::string_tools::parse_tpod_from_hex_string(str, h);
CHECK_AND_ASSERT_THROW_MES(r, "wrong hash str");
scratchpad.push_back(h);
return true;
}
void get_scratchpad(size_t hashes_count, std::vector<crypto::hash>& scratchpad)
{
scratchpad.reserve(hashes_count);
size_t count_text_hashes = (sizeof(test_hashes)/sizeof(test_hashes[0]));
for(size_t i = 0; i != hashes_count;i++)
if(i < count_text_hashes)
{
add_hash_str_to_hash_vector(test_hashes[i], scratchpad);
}else
{
scratchpad.push_back(scratchpad[i%count_text_hashes]);
}
}
template<typename hash_cb>
bool check_hash(hash_cb hcb)
{
for(size_t i = 0; i < sizeof(expected_results)/sizeof(expected_results[0]); i++)
{
std::vector<crypto::hash> scratchpad;
get_scratchpad(expected_results[i].scratch_size, scratchpad);
crypto::hash h_expected = null_hash;
bool r = epee::string_tools::parse_tpod_from_hex_string(expected_results[i].expected_hash, h_expected);
CHECK_AND_ASSERT_THROW_MES(r, "wrong expected hash");
crypto::hash res = hcb(test_srings[expected_results[i].string_no], scratchpad);
CHECK_AND_ASSERT_MES(res == h_expected, false, "wrong pow_hash: " << res << ", expected: " );
LOG_ERROR("Hash missmatch");
return false;
}
return true;
}
TEST(pow_tests, test_reference_func)
TEST(pow_tests, test_full_against_light)
{
bool r = check_hash([](const std::string& blob, std::vector<crypto::hash>& scratchpad){
return get_block_longhash(blob);
});
ASSERT_TRUE(r);
r = check_hash([](const std::string& blob, std::vector<crypto::hash>& scratchpad){
return get_block_longhash(blob);
});
ASSERT_TRUE(r);
bool res = test_scratchpad_against_light_scratchpad();
ASSERT_TRUE(res);
}
*/

0
utils/Zano.sh Normal file → Executable file
View file

View file

@ -4,4 +4,4 @@ cd ..
@mkdir build_msvc2013_64
cd build_msvc2013_64
cmake -D CMAKE_PREFIX_PATH="%QT_PREFIX_PATH%"\msvc2013_64 -D BUILD_GUI=TRUE -D STATIC=FALSE -DBOOST_ROOT="%BOOST_ROOT%" -DBOOST_LIBRARYDIR="%BOOST_ROOT%\lib64-msvc-12.0" -G "Visual Studio 12 2013 Win64" ".."
cmake -D BUILD_TESTS=TRUE -D CMAKE_PREFIX_PATH="%QT_PREFIX_PATH%"\msvc2013_64 -D BUILD_GUI=TRUE -D STATIC=FALSE -DBOOST_ROOT="%BOOST_ROOT%" -DBOOST_LIBRARYDIR="%BOOST_ROOT%\lib64-msvc-12.0" -G "Visual Studio 12 2013 Win64" ".."

View file

@ -4,4 +4,4 @@ cd ..
@mkdir build_msvc2015_64
cd build_msvc2015_64
cmake -D USE_PCH=TRUE -D CMAKE_PREFIX_PATH="%QT_PREFIX_PATH%"\msvc2015_64 -D BUILD_GUI=TRUE -D USE_OPENCL=TRUE -D STATIC=FALSE -DBOOST_ROOT="%BOOST_ROOT%" -DBOOST_LIBRARYDIR="%BOOST_ROOT%\lib64-msvc-14.0" -G "Visual Studio 14 2015 Win64" -T host=x64 ".."
cmake -D USE_PCH=TRUE -D BUILD_TESTS=TRUE -D CMAKE_PREFIX_PATH="%QT_PREFIX_PATH%"\msvc2015_64 -D BUILD_GUI=TRUE -D USE_OPENCL=TRUE -D STATIC=FALSE -DBOOST_ROOT="%BOOST_ROOT%" -DBOOST_LIBRARYDIR="%BOOST_ROOT%\lib64-msvc-14.0" -G "Visual Studio 14 2015 Win64" -T host=x64 ".."

View file

@ -4,4 +4,4 @@ cd ..
@mkdir build_msvc2017_64
cd build_msvc2017_64
cmake -D USE_PCH=TRUE -D CMAKE_PREFIX_PATH="%QT_PREFIX_PATH%"\msvc2017_64 -D BUILD_GUI=TRUE -D USE_OPENCL=TRUE -D STATIC=FALSE -DBOOST_ROOT="%BOOST_ROOT%" -DBOOST_LIBRARYDIR="%BOOST_ROOT%\lib64-msvc-14.1" -G "Visual Studio 15 2017 Win64" -T host=x64 ".."
cmake -D USE_PCH=TRUE -D BUILD_TESTS=TRUE -D CMAKE_PREFIX_PATH="%QT_PREFIX_PATH%"\msvc2017_64 -D BUILD_GUI=TRUE -D USE_OPENCL=TRUE -D STATIC=FALSE -DBOOST_ROOT="%BOOST_ROOT%" -DBOOST_LIBRARYDIR="%BOOST_ROOT%\lib64-msvc-14.1" -G "Visual Studio 15 2017 Win64" -T host=x64 ".."

View file

@ -31,7 +31,7 @@ WizardImageFile=../resources/installer_bg_164x313.bmp
PrivilegesRequired=poweruser
;SetupIconFile=../resources/app.ico
AppMutex=Zano_instance
UninstallDisplayIcon={app}\{#MyAppExeName}
[Languages]

View file

@ -32,6 +32,7 @@ PrivilegesRequired=poweruser
ArchitecturesAllowed=x64
;SetupIconFile=../resources/app.ico
AppMutex=Zano_instance
UninstallDisplayIcon={app}\{#MyAppExeName}
[Languages]