1
0
Fork 0
forked from lthn/blockchain

Merge branch 'master' into develop

This commit is contained in:
crypro.zoidberg 2019-05-15 20:25:07 +02:00
commit 11900a2f3d
20 changed files with 98 additions and 78 deletions

View file

@ -55,7 +55,7 @@ namespace
const command_line::arg_descriptor<uint64_t> arg_genesis_split_amount = { "genesis-split-amount", "Set split amount for generating genesis block", 0, true };
const command_line::arg_descriptor<std::string> arg_get_info_flags = { "getinfo-flags-hex", "Set of bits for rpc-get-daemon-info", "", true };
const command_line::arg_descriptor<int64_t> arg_set_peer_log_level = { "set-peer-log-level", "Set log level for remote peer", 0, true };
const command_line::arg_descriptor<uint64_t> arg_download_peer_log = { "download-peer-log", "Download log from remote peer (starting offset)", 0, true };
const command_line::arg_descriptor<std::string> arg_download_peer_log = { "download-peer-log", "Download log from remote peer <starting_offset>[,<count>]", "", true };
const command_line::arg_descriptor<bool> arg_do_consloe_log = { "do-console-log", "Tool generates debug console output(debug purposes)", "", true };
}
@ -793,6 +793,7 @@ bool handle_increment_build_no(po::variables_map& vm)
//---------------------------------------------------------------------------------------------------------------
bool handle_update_maintainers_info(po::variables_map& vm)
{
log_space::log_singletone::add_logger(LOGGER_CONSOLE, NULL, NULL);
if(!command_line::has_arg(vm, arg_rpc_port))
{
std::cout << "ERROR: rpc port not set" << ENDL;
@ -930,7 +931,27 @@ bool handle_download_peer_log(po::variables_map& vm)
return false;
}
uint64_t start_offset = command_line::get_arg(vm, arg_download_peer_log);
int64_t start_offset = 0;
int64_t count = -1;
std::string arg_str = command_line::get_arg(vm, arg_download_peer_log);
size_t comma_pos = arg_str.find(',');
if (comma_pos != std::string::npos)
{
// count is specified
if (!epee::string_tools::string_to_num_fast(arg_str.substr(comma_pos + 1), count) || count < 0)
{
std::cout << "ERROR: invalid argument: " << arg_str << ENDL;
return false;
}
arg_str.erase(comma_pos);
}
if (!epee::string_tools::string_to_num_fast(arg_str, start_offset) || start_offset < 0)
{
std::cout << "ERROR: couldn't parse start_offset: " << arg_str << ENDL;
return false;
}
levin::levin_client_impl2 transport;
peerid_type peer_id = 0;
@ -946,6 +967,9 @@ bool handle_download_peer_log(po::variables_map& vm)
std::cout << "Current log level: " << rsp.current_log_level << ENDL;
std::cout << "Current log size: " << rsp.current_log_size << ENDL;
if (start_offset == 0 && count == 0)
return true; // a caller wanted to just get the info, end of story
if (start_offset >= rsp.current_log_size)
{
std::cout << "ERROR: invalid start offset: " << start_offset << ", log size: " << rsp.current_log_size << ENDL;
@ -968,6 +992,13 @@ bool handle_download_peer_log(po::variables_map& vm)
{
req.log_chunk_offset = end_offset;
req.log_chunk_size = std::min(chunk_size, rsp.current_log_size - req.log_chunk_offset);
if (count > 0)
{
uint64_t bytes_left = count + start_offset - end_offset;
req.log_chunk_size = std::min(req.log_chunk_size, bytes_left);
}
if (req.log_chunk_size == 0)
break;

View file

@ -902,9 +902,10 @@ wide_difficulty_type blockchain_storage::get_next_diff_conditional(bool pos) con
return DIFFICULTY_STARTER;
//skip genesis timestamp
TIME_MEASURE_START_PD(target_calculating_enum_blocks);
CRITICAL_REGION_BEGIN(m_targetdata_cache_lock);
std::list<std::pair<wide_difficulty_type, uint64_t>>& targetdata_cache = pos ? m_pos_targetdata_cache : m_pow_targetdata_cache;
if (targetdata_cache.empty())
load_targetdata_cache(pos);
//if (targetdata_cache.empty())
load_targetdata_cache(pos);
size_t count = 0;
for (auto it = targetdata_cache.rbegin(); it != targetdata_cache.rend() && count < DIFFICULTY_WINDOW; it++)
@ -913,6 +914,7 @@ wide_difficulty_type blockchain_storage::get_next_diff_conditional(bool pos) con
commulative_difficulties.push_back(it->first);
++count;
}
CRITICAL_REGION_END();
wide_difficulty_type& dif = pos ? m_cached_next_pos_difficulty : m_cached_next_pow_difficulty;
TIME_MEASURE_FINISH_PD(target_calculating_enum_blocks);
@ -2211,31 +2213,6 @@ bool blockchain_storage::is_multisig_output_spent(const crypto::hash& multisig_i
return source_tx_ptr->m_spent_flags[ms_out_index];
}
//------------------------------------------------------------------
// bool blockchain_storage::resync_spent_tx_flags()
// {
// LOG_PRINT_L0("Started re-building spent tx outputs data...");
// CRITICAL_REGION_LOCAL(m_blockchain_lock);
// for(auto& tx: m_db_transactions)
// {
// if(is_coinbase(tx.second.tx))
// continue;
//
// for(auto& in: tx.second.tx.vin)
// {
// CHECKED_GET_SPECIFIC_VARIANT(in, txin_to_key, in_to_key, false);
// if(in_to_key.key_offsets.size() != 1)
// continue;
//
// //direct spending
// if(!update_spent_tx_flags_for_input(in_to_key.amount, in_to_key.key_offsets[0], true))
// return false;
//
// }
// }
// LOG_PRINT_L0("Finished re-building spent tx outputs data");
// return true;
// }
//------------------------------------------------------------------
bool blockchain_storage::find_blockchain_supplement(const std::list<crypto::hash>& qblock_ids, uint64_t& starter_offset)const
{
CRITICAL_REGION_LOCAL(m_read_lock);
@ -4259,8 +4236,6 @@ bool blockchain_storage::handle_block_to_main_chain(const block& bl, const crypt
return false;
}
get_block_height(bl);
if(!check_block_timestamp_main(bl))
{
LOG_PRINT_L0("Block with id: " << id << ENDL
@ -4596,6 +4571,7 @@ void blockchain_storage::on_block_removed(const block_extended_info& bei)
//------------------------------------------------------------------
void blockchain_storage::update_targetdata_cache_on_block_added(const block_extended_info& bei)
{
CRITICAL_REGION_LOCAL(m_targetdata_cache_lock);
if (bei.height == 0)
return; //skip genesis
std::list<std::pair<wide_difficulty_type, uint64_t>>& targetdata_cache = is_pos_block(bei.bl) ? m_pos_targetdata_cache : m_pow_targetdata_cache;
@ -4606,6 +4582,7 @@ void blockchain_storage::update_targetdata_cache_on_block_added(const block_exte
//------------------------------------------------------------------
void blockchain_storage::update_targetdata_cache_on_block_removed(const block_extended_info& bei)
{
CRITICAL_REGION_LOCAL(m_targetdata_cache_lock);
std::list<std::pair<wide_difficulty_type, uint64_t>>& targetdata_cache = is_pos_block(bei.bl) ? m_pos_targetdata_cache : m_pow_targetdata_cache;
if (targetdata_cache.size())
targetdata_cache.pop_back();
@ -4615,6 +4592,7 @@ void blockchain_storage::update_targetdata_cache_on_block_removed(const block_ex
//------------------------------------------------------------------
void blockchain_storage::load_targetdata_cache(bool is_pos)const
{
CRITICAL_REGION_LOCAL(m_targetdata_cache_lock);
std::list<std::pair<wide_difficulty_type, uint64_t>>& targetdata_cache = is_pos? m_pos_targetdata_cache: m_pow_targetdata_cache;
targetdata_cache.clear();
uint64_t stop_ind = 0;

View file

@ -511,6 +511,7 @@ namespace currency
mutable wide_difficulty_type m_cached_next_pow_difficulty;
mutable wide_difficulty_type m_cached_next_pos_difficulty;
mutable critical_section m_targetdata_cache_lock;
mutable std::list <std::pair<wide_difficulty_type, uint64_t>> m_pos_targetdata_cache;
mutable std::list <std::pair<wide_difficulty_type, uint64_t>> m_pow_targetdata_cache;
//work like a cache to avoid recalculation on read operations

View file

@ -205,7 +205,7 @@
#define CURRENT_TRANSACTION_CHAIN_ENTRY_ARCHIVE_VER 3
#define CURRENT_BLOCK_EXTENDED_INFO_ARCHIVE_VER 1
#define BLOCKCHAIN_STORAGE_MAJOR_COMPATIBILITY_VERSION CURRENCY_FORMATION_VERSION + 4
#define BLOCKCHAIN_STORAGE_MAJOR_COMPATIBILITY_VERSION CURRENCY_FORMATION_VERSION + 7
#define BLOCKCHAIN_STORAGE_MINOR_COMPATIBILITY_VERSION 1

View file

@ -258,6 +258,11 @@ namespace currency
}
//pre-validate block here, and propagate it to network asap to avoid latency of handling big block (tx flood)
//########################################################
/*
problem with prevalidation: in case of pre_validate_block() is passed but handle_incoming_tx() is failed
network got spammed with notifications about this broken block and then connections got closed.
temporary disabled to more investigation
bool prevalidate_relayed = false;
if (m_core.pre_validate_block(b, bvc, block_id) && bvc.m_added_to_main_chain)
{
@ -266,6 +271,8 @@ namespace currency
relay_block(arg, context);
prevalidate_relayed = true;
}
*/
//########################################################
//now actually process block
for(auto tx_blob_it = arg.b.txs.begin(); tx_blob_it!=arg.b.txs.end();tx_blob_it++)
@ -291,13 +298,13 @@ namespace currency
}
LOG_PRINT_GREEN("[HANDLE]NOTIFY_NEW_BLOCK EXTRA: id: " << block_id
<< ",bvc.m_added_to_main_chain " << bvc.m_added_to_main_chain
<< ",prevalidate_result " << prevalidate_relayed
//<< ",prevalidate_result " << prevalidate_relayed
<< ",bvc.added_to_altchain " << bvc.added_to_altchain
<< ",bvc.m_marked_as_orphaned " << bvc.m_marked_as_orphaned, LOG_LEVEL_2);
if (bvc.m_added_to_main_chain || (bvc.added_to_altchain && bvc.height_difference < 2))
{
if (!prevalidate_relayed)
if (true/*!prevalidate_relayed*/)
{
// pre-validation failed prevoiusly, but complete check was success, not an alternative block
++arg.hop;

View file

@ -45,8 +45,7 @@
"ERROR": "System error",
"COMPLETE": "Completion",
"SYNCING": "Syncing blockchain",
"LOADING": "Loading blockchain data",
"TESTNET": ""
"LOADING": "Loading blockchain data"
}
},
"MAIN": {

View file

@ -202,13 +202,6 @@ app-sidebar {
background-color: themed(onlineColor);
}
}
.testnet {
@include themify($themes) {
color: themed(mainTextColor);
}
}
}
.progress-bar-container {

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -54,22 +54,22 @@
<div class="sidebar-synchronization-status">
<div class="status-container">
<span class="offline" *ngIf="variablesService.daemon_state === 0">
{{ 'SIDEBAR.SYNCHRONIZATION.OFFLINE' | translate }} <span class="testnet">{{ 'SIDEBAR.SYNCHRONIZATION.TESTNET' | translate }}</span>
{{ 'SIDEBAR.SYNCHRONIZATION.OFFLINE' | translate }}
</span>
<span class="syncing" *ngIf="variablesService.daemon_state === 1">
{{ 'SIDEBAR.SYNCHRONIZATION.SYNCING' | translate }} <span class="testnet">{{ 'SIDEBAR.SYNCHRONIZATION.TESTNET' | translate }}</span>
{{ 'SIDEBAR.SYNCHRONIZATION.SYNCING' | translate }}
</span>
<span class="online" *ngIf="variablesService.daemon_state === 2">
{{ 'SIDEBAR.SYNCHRONIZATION.ONLINE' | translate }} <span class="testnet">{{ 'SIDEBAR.SYNCHRONIZATION.TESTNET' | translate }}</span>
{{ 'SIDEBAR.SYNCHRONIZATION.ONLINE' | translate }}
</span>
<span class="loading" *ngIf="variablesService.daemon_state === 3">
{{ 'SIDEBAR.SYNCHRONIZATION.LOADING' | translate }}
</span>
<span class="offline" *ngIf="variablesService.daemon_state === 4">
{{ 'SIDEBAR.SYNCHRONIZATION.ERROR' | translate }} <span class="testnet">{{ 'SIDEBAR.SYNCHRONIZATION.TESTNET' | translate }}</span>
{{ 'SIDEBAR.SYNCHRONIZATION.ERROR' | translate }}
</span>
<span class="online" *ngIf="variablesService.daemon_state === 5">
{{ 'SIDEBAR.SYNCHRONIZATION.COMPLETE' | translate }} <span class="testnet">{{ 'SIDEBAR.SYNCHRONIZATION.TESTNET' | translate }}</span>
{{ 'SIDEBAR.SYNCHRONIZATION.COMPLETE' | translate }}
</span>
</div>
<div class="progress-bar-container">

View file

@ -45,8 +45,7 @@
"ERROR": "System error",
"COMPLETE": "Completion",
"SYNCING": "Syncing blockchain",
"LOADING": "Loading blockchain data",
"TESTNET": "(testnet)"
"LOADING": "Loading blockchain data"
}
},
"MAIN": {

View file

@ -202,13 +202,6 @@ app-sidebar {
background-color: themed(onlineColor);
}
}
.testnet {
@include themify($themes) {
color: themed(mainTextColor);
}
}
}
.progress-bar-container {

View file

@ -402,14 +402,14 @@ namespace nodetool
template<class t_payload_net_handler>
bool node_server<t_payload_net_handler>::on_maintainers_entry_update()
{
LOG_PRINT_MAGENTA("Fresh maintainers info recieved(timestamp: " << m_maintainers_info_local.timestamp << ")", LOG_LEVEL_0);
LOG_PRINT_CHANNEL_COLOR2(NULL, NULL, "Fresh maintainers info recieved(timestamp: " << m_maintainers_info_local.timestamp << ")", LOG_LEVEL_0, epee::log_space::console_color_magenta);
if(PROJECT_VERSION_BUILD_NO < m_maintainers_info_local.build_no)
{
LOG_PRINT_MAGENTA("Newer version avaliable: " << static_cast<uint32_t>(m_maintainers_info_local.ver_major) <<
LOG_PRINT_CHANNEL_COLOR2(NULL, NULL, "Newer version avaliable: " << static_cast<uint32_t>(m_maintainers_info_local.ver_major) <<
"." << static_cast<uint32_t>(m_maintainers_info_local.ver_minor) <<
"." << static_cast<uint32_t>(m_maintainers_info_local.ver_revision) <<
"." << static_cast<uint32_t>(m_maintainers_info_local.build_no) <<
", current version: " << PROJECT_VERSION_LONG, LOG_LEVEL_0);
", current version: " << PROJECT_VERSION_LONG, LOG_LEVEL_0, epee::log_space::console_color_magenta);
}
handle_alert_conditions();
@ -893,7 +893,7 @@ namespace nodetool
if(m_alert_mode != ALERT_TYPE_CALM)
return true;
LOG_PRINT_L0("This software is old, please update.");
LOG_PRINT_CHANNEL2(NULL, NULL, "This software is outdated, please update.", LOG_LEVEL_0);
return true;
}
//-----------------------------------------------------------------------------------
@ -903,7 +903,7 @@ namespace nodetool
if(m_alert_mode != ALERT_TYPE_URGENT)
return true;
LOG_PRINT_CYAN("[URGENT]:This software is old, please update.", LOG_LEVEL_0);
LOG_PRINT_CHANNEL_COLOR2(NULL, NULL, "[URGENT]:This software is dramatically outdated, please update to latest version.", LOG_LEVEL_0, epee::log_space::console_color_cyan);
return true;
}
//-----------------------------------------------------------------------------------
@ -913,7 +913,7 @@ namespace nodetool
if(m_alert_mode != ALERT_TYPE_CRITICAL)
return true;
LOG_PRINT_RED("[CRITICAL]:This software is old, please update.", LOG_LEVEL_0);
LOG_PRINT_CHANNEL_COLOR2(NULL, NULL, "[CRITICAL]:This software is critically outdated, please update to latest version.", LOG_LEVEL_0, epee::log_space::console_color_red);
return true;
}
//-----------------------------------------------------------------------------------

View file

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

@ -226,6 +226,13 @@ namespace tools
m_wallet.get_payments(payment_id, payment_list);
for (auto payment : payment_list)
{
if (payment.m_unlock_time && !req.allow_locked_transactions)
{
//check that transaction don't have locking for time longer then 10 blocks ahead
//TODO: add code for "unlock_time" set as timestamp, now it's all being filtered
if (payment.m_unlock_time > payment.m_block_height + WALLET_DEFAULT_TX_SPENDABLE_AGE)
continue;
}
wallet_rpc::payment_details rpc_payment;
rpc_payment.payment_id = req.payment_id;
rpc_payment.tx_hash = epee::string_tools::pod_to_hex(payment.m_tx_hash);
@ -257,6 +264,14 @@ namespace tools
for (auto & payment : payment_list)
{
if (payment.m_unlock_time && !req.allow_locked_transactions)
{
//check that transaction don't have locking for time longer then 10 blocks ahead
//TODO: add code for "unlock_time" set as timestamp, now it's all being filtered
if (payment.m_unlock_time > payment.m_block_height + WALLET_DEFAULT_TX_SPENDABLE_AGE)
continue;
}
wallet_rpc::payment_details rpc_payment;
rpc_payment.payment_id = payment_id_str;
rpc_payment.tx_hash = epee::string_tools::pod_to_hex(payment.m_tx_hash);

View file

@ -277,9 +277,11 @@ namespace wallet_rpc
struct request
{
std::string payment_id; // hex-encoded
bool allow_locked_transactions;
BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE(payment_id)
KV_SERIALIZE(allow_locked_transactions)
END_KV_SERIALIZE_MAP()
};
@ -299,10 +301,12 @@ namespace wallet_rpc
{
std::vector<std::string> payment_ids;
uint64_t min_block_height;
bool allow_locked_transactions;
BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE(payment_ids)
KV_SERIALIZE(min_block_height)
KV_SERIALIZE(allow_locked_transactions)
END_KV_SERIALIZE_MAP()
};

View file

@ -3,16 +3,16 @@
case $1 in
config)
cat <<'EOM'
graph_title sequense
graph_vlabel sequense
graph_title sequence
graph_vlabel sequence
graph_category daemon
pos_sequense_factor.label pos_sequense_factor
pow_sequense_factor.label pow_sequense_factor
pos_sequence_factor.label pos_sequence_factor
pow_sequence_factor.label pow_sequence_factor
EOM
exit 0;;
esac
printf "pos_sequense_factor.value "
connectivity_tool --ip=127.0.0.1 --rpc-port=$ZANO_RPC_PORT --timeout=1000 --rpc-get-daemon-info --getinfo-flags-hex="0x0000000000002000" | grep pos_sequense_factor | cut -d ' ' -f2
printf "pow_sequense_factor.value "
connectivity_tool --ip=127.0.0.1 --rpc-port=$ZANO_RPC_PORT --timeout=1000 --rpc-get-daemon-info --getinfo-flags-hex="0x0000000000004000" | grep pow_sequense_factor | cut -d ' ' -f2
printf "pos_sequence_factor.value "
connectivity_tool --ip=127.0.0.1 --rpc-port=$ZANO_RPC_PORT --timeout=1000 --rpc-get-daemon-info --getinfo-flags-hex="0x0000000000002000" | grep pos_sequence_factor | cut -d ' ' -f2
printf "pow_sequence_factor.value "
connectivity_tool --ip=127.0.0.1 --rpc-port=$ZANO_RPC_PORT --timeout=1000 --rpc-get-daemon-info --getinfo-flags-hex="0x0000000000004000" | grep pow_sequence_factor | cut -d ' ' -f2

View file

@ -2,10 +2,10 @@
"maj":1,
"min":0,
"rev":0,
"build":8,
"build":26,
"cs":[
{
"build":7,
"build":28,
"mode":3
}
]