forked from lthn/blockchain
Merge branch 'master' into offsig
This commit is contained in:
commit
e66da1bf3e
8 changed files with 52 additions and 14 deletions
|
|
@ -56,6 +56,7 @@ namespace
|
|||
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<bool> arg_do_consloe_log = { "do-console-log", "Tool generates debug console output(debug purposes)", "", true };
|
||||
}
|
||||
|
||||
typedef COMMAND_REQUEST_STAT_INFO_T<t_currency_protocol_handler<core>::stat_info> COMMAND_REQUEST_STAT_INFO;
|
||||
|
|
@ -1004,7 +1005,7 @@ int main(int argc, char* argv[])
|
|||
{
|
||||
|
||||
string_tools::set_module_name_and_folder(argv[0]);
|
||||
log_space::get_set_log_detalisation_level(true, LOG_LEVEL_4);
|
||||
log_space::get_set_log_detalisation_level(true, LOG_LEVEL_2);
|
||||
|
||||
tools::signal_handler::install_fatal([](int sig_number, void* address) {
|
||||
LOG_ERROR("\n\nFATAL ERROR\nsig: " << sig_number << ", address: " << address);
|
||||
|
|
@ -1036,6 +1037,8 @@ int main(int argc, char* argv[])
|
|||
command_line::add_arg(desc_params, arg_log_journal_len);
|
||||
command_line::add_arg(desc_params, arg_set_peer_log_level);
|
||||
command_line::add_arg(desc_params, arg_download_peer_log);
|
||||
command_line::add_arg(desc_params, arg_do_consloe_log);
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -1059,6 +1062,11 @@ int main(int argc, char* argv[])
|
|||
});
|
||||
if (!r)
|
||||
return 1;
|
||||
if (command_line::has_arg(vm, arg_do_consloe_log) && command_line::get_arg(vm, arg_do_consloe_log))
|
||||
{
|
||||
log_space::log_singletone::add_logger(LOGGER_CONSOLE, NULL, NULL);
|
||||
}
|
||||
|
||||
|
||||
if (command_line::get_arg(vm, command_line::arg_version))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -39,16 +39,32 @@ namespace currency
|
|||
return height / ETHASH_EPOCH_LENGTH;
|
||||
}
|
||||
//--------------------------------------------------------------
|
||||
crypto::hash get_block_longhash(uint64_t height, const crypto::hash& block_long_ash, uint64_t nonce)
|
||||
crypto::hash ethash_epoch_to_seed(int epoch)
|
||||
{
|
||||
auto res_eth = ethash_calculate_epoch_seed(epoch);
|
||||
crypto::hash result = currency::null_hash;
|
||||
memcpy(&result.data, &res_eth, sizeof(res_eth));
|
||||
return result;
|
||||
}
|
||||
//--------------------------------------------------------------
|
||||
crypto::hash get_block_longhash(uint64_t height, const crypto::hash& block_header_hash, uint64_t nonce)
|
||||
{
|
||||
int epoch = ethash_height_to_epoch(height);
|
||||
const auto& context = progpow::get_global_epoch_context_full(static_cast<int>(epoch));
|
||||
auto res_eth = progpow::hash(context, height, *(ethash::hash256*)&block_long_ash, nonce);
|
||||
auto res_eth = progpow::hash(context, height, *(ethash::hash256*)&block_header_hash, nonce);
|
||||
crypto::hash result = currency::null_hash;
|
||||
memcpy(&result.data, &res_eth.final_hash, sizeof(res_eth.final_hash));
|
||||
return result;
|
||||
}
|
||||
//---------------------------------------------------------------
|
||||
crypto::hash get_block_header_mining_hash(const block& b)
|
||||
{
|
||||
blobdata bd = get_block_hashing_blob(b);
|
||||
|
||||
access_nonce_in_block_blob(bd) = 0;
|
||||
return crypto::cn_fast_hash(bd.data(), bd.size());
|
||||
}
|
||||
//---------------------------------------------------------------
|
||||
void get_block_longhash(const block& b, crypto::hash& res)
|
||||
{
|
||||
/*
|
||||
|
|
@ -57,11 +73,7 @@ namespace currency
|
|||
To achieve the same effect we make blob of data from block in normal way, but then set to zerro nonce
|
||||
inside serialized buffer, and then pass this nonce to ethash algo as a second argument, as it expected.
|
||||
*/
|
||||
blobdata bd = get_block_hashing_blob(b);
|
||||
|
||||
access_nonce_in_block_blob(bd) = 0;
|
||||
crypto::hash bl_hash = crypto::cn_fast_hash(bd.data(), bd.size());
|
||||
|
||||
crypto::hash bl_hash = get_block_header_mining_hash(b);
|
||||
res = get_block_longhash(get_block_height(b), bl_hash, b.nonce);
|
||||
}
|
||||
//---------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -28,7 +28,9 @@
|
|||
namespace currency
|
||||
{
|
||||
int ethash_height_to_epoch(uint64_t height);
|
||||
crypto::hash get_block_longhash(uint64_t h, const crypto::hash& block_long_ash, uint64_t nonce);
|
||||
crypto::hash ethash_epoch_to_seed(int epoch);
|
||||
crypto::hash get_block_header_mining_hash(const block& b);
|
||||
crypto::hash get_block_longhash(uint64_t h, const crypto::hash& block_header_hash, uint64_t nonce);
|
||||
void get_block_longhash(const block& b, crypto::hash& res);
|
||||
crypto::hash get_block_longhash(const block& b);
|
||||
|
||||
|
|
|
|||
|
|
@ -4295,8 +4295,10 @@ bool blockchain_storage::handle_block_to_main_chain(const block& bl, const crypt
|
|||
if (!check_hash(proof_hash, current_diffic))
|
||||
{
|
||||
LOG_ERROR("Block with id: " << id << ENDL
|
||||
<< "PoW hash: " << proof_hash << ENDL
|
||||
<< "unexpected difficulty: " << current_diffic);
|
||||
<< "PoW hash: " << proof_hash << ENDL
|
||||
<< "nonce: " << bl.nonce << ENDL
|
||||
<< "header_mining_hash: " << get_block_header_mining_hash(bl) << ENDL
|
||||
<< "expected difficulty: " << current_diffic);
|
||||
bvc.m_verification_failed = true;
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,23 +24,29 @@ namespace currency
|
|||
{
|
||||
const command_line::arg_descriptor<std::string> arg_rpc_bind_ip = {"rpc-bind-ip", "", "127.0.0.1"};
|
||||
const command_line::arg_descriptor<std::string> arg_rpc_bind_port = {"rpc-bind-port", "", std::to_string(RPC_DEFAULT_PORT)};
|
||||
const command_line::arg_descriptor<bool> arg_rpc_ignore_status = {"rpc-ignore-offline", "Let rpc calls despite online/offline status", false, true };
|
||||
}
|
||||
//-----------------------------------------------------------------------------------
|
||||
void core_rpc_server::init_options(boost::program_options::options_description& desc)
|
||||
{
|
||||
command_line::add_arg(desc, arg_rpc_bind_ip);
|
||||
command_line::add_arg(desc, arg_rpc_bind_port);
|
||||
command_line::add_arg(desc, arg_rpc_ignore_status);
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------------------------------------
|
||||
core_rpc_server::core_rpc_server(core& cr, nodetool::node_server<currency::t_currency_protocol_handler<currency::core> >& p2p,
|
||||
bc_services::bc_offers_service& of
|
||||
) :m_core(cr), m_p2p(p2p), m_of(of), m_session_counter(0)
|
||||
) :m_core(cr), m_p2p(p2p), m_of(of), m_session_counter(0), m_ignore_status(false)
|
||||
{}
|
||||
//------------------------------------------------------------------------------------------------------------------------------
|
||||
bool core_rpc_server::handle_command_line(const boost::program_options::variables_map& vm)
|
||||
{
|
||||
m_bind_ip = command_line::get_arg(vm, arg_rpc_bind_ip);
|
||||
m_port = command_line::get_arg(vm, arg_rpc_bind_port);
|
||||
if (command_line::has_arg(vm, arg_rpc_ignore_status))
|
||||
{
|
||||
m_ignore_status = command_line::get_arg(vm, arg_rpc_ignore_status);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------------------------------------
|
||||
|
|
@ -55,6 +61,8 @@ namespace currency
|
|||
bool core_rpc_server::check_core_ready_(const std::string& calling_method)
|
||||
{
|
||||
#ifndef TESTNET
|
||||
if (m_ignore_status)
|
||||
return true;
|
||||
if(!m_p2p.get_payload_object().is_synchronized())
|
||||
{
|
||||
LOG_PRINT_L0("[" << calling_method << "]Core busy cz is_synchronized");
|
||||
|
|
@ -799,6 +807,10 @@ namespace currency
|
|||
|
||||
res.blocktemplate_blob = string_tools::buff_to_hex_nodelimer(block_blob);
|
||||
res.prev_hash = string_tools::pod_to_hex(b.prev_id);
|
||||
|
||||
//calculate epoch seed
|
||||
res.seed = currency::ethash_epoch_to_seed(currency::ethash_height_to_epoch(res.height));
|
||||
|
||||
res.status = CORE_RPC_STATUS_OK;
|
||||
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -177,6 +177,7 @@ namespace currency
|
|||
bc_services::bc_offers_service& m_of;
|
||||
std::string m_port;
|
||||
std::string m_bind_ip;
|
||||
bool m_ignore_status;
|
||||
//mining stuff
|
||||
epee::critical_section m_session_jobs_lock;
|
||||
std::map<std::string, currency::block> m_session_jobs; //session id -> blob
|
||||
|
|
|
|||
|
|
@ -821,7 +821,7 @@ namespace
|
|||
}
|
||||
|
||||
m_json_helper.feed(str, data_size);
|
||||
LP_CC_WORKER(m_context, "data received: " << data_size << " bytes:" << ENDL << std::string(str, data_size), LOG_LEVEL_4);
|
||||
LP_CC_WORKER(m_context, "DATA received <<<<<<<<<<<<< " << data_size << " bytes:" << ENDL << std::string(str, data_size), LOG_LEVEL_0);
|
||||
|
||||
if (m_json_helper.has_objects())
|
||||
{
|
||||
|
|
@ -975,7 +975,7 @@ namespace
|
|||
void send(const std::string& data)
|
||||
{
|
||||
static_cast<epee::net_utils::i_service_endpoint*>(m_p_connection)->do_send(data.c_str(), data.size());
|
||||
LOG_PRINT_CC(m_context, "DATA sent >>>>>>>>>>>>> " << ENDL << data, LOG_LEVEL_4);
|
||||
LOG_PRINT_CC(m_context, "DATA sent >>>>>>>>>>>>> " << ENDL << data, LOG_LEVEL_0);
|
||||
}
|
||||
|
||||
void send_notification(const std::string& json)
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ namespace tools
|
|||
command_line::add_arg(desc, arg_rpc_bind_ip);
|
||||
command_line::add_arg(desc, arg_rpc_bind_port);
|
||||
command_line::add_arg(desc, arg_miner_text_info);
|
||||
command_line::add_arg(desc, arg_rpc_ignore_status);
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------------------------------------
|
||||
wallet_rpc_server::wallet_rpc_server(wallet2& w):m_wallet(w), m_do_mint(false)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue