Skip to content

Commit

Permalink
Merge pull request #8 from Tore-tto/mn-self-intro
Browse files Browse the repository at this point in the history
Mn self intro
  • Loading branch information
Tore-tto committed Jun 5, 2023
2 parents f81babb + 851d78c commit 5ae04ac
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 10 deletions.
3 changes: 3 additions & 0 deletions src/blockchain_db/lmdb/db_lmdb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1999,6 +1999,9 @@ bool BlockchainLMDB::get_txpool_tx_blob(const crypto::hash& txid, cryptonote::bl
if (result != 0)
throw1(DB_ERROR(lmdb_error("Error finding txpool tx blob: ", result).c_str()));

if (v.mv_size == 0)
throw1(DB_ERROR("Error finding txpool tx blob: tx is present, but data is empty"));

bd.assign(reinterpret_cast<const char*>(v.mv_data), v.mv_size);
return true;
}
Expand Down
8 changes: 7 additions & 1 deletion src/cryptonote_core/cryptonote_core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1156,7 +1156,13 @@ namespace cryptonote
tx_info.tvc.m_too_big = true;
return;
}

else if (tx_info.blob->empty())
{
LOG_PRINT_L1("WRONG TRANSACTION BLOB, blob is empty, rejected");
tx_info.tvc.m_verifivation_failed = true;
return;
}

tx_info.parsed = parse_and_validate_tx_from_blob(*tx_info.blob, tx_info.tx, tx_info.tx_hash);
if(!tx_info.parsed)
{
Expand Down
10 changes: 5 additions & 5 deletions src/cryptonote_protocol/cryptonote_protocol_handler.inl
Original file line number Diff line number Diff line change
Expand Up @@ -2646,17 +2646,17 @@ skip:
bool t_cryptonote_protocol_handler<t_core>::relay_transactions(NOTIFY_NEW_TRANSACTIONS::request& arg, cryptonote_connection_context& exclude_context)
{
MTRACE("relay_transactions");
for(auto& tx_blob : arg.txs)
m_core.on_transaction_relayed(tx_blob);

// no check for success, so tell core they're relayed unconditionally and snag a copy of the
// hash so that we can look up any associated flash data we should include.

std::vector<crypto::hash> relayed_txes;
relayed_txes.reserve(arg.txs.size());
for (auto &tx_blob : arg.txs)
relayed_txes.push_back(
m_core.on_transaction_relayed(tx_blob)
);
{
if (auto hash = m_core.on_transaction_relayed(tx_blob))
relayed_txes.push_back(hash);
}

// Rebuild arg.flashes from flash data that we have because we don't necessarily have the same
// flash data that got sent to us (we may have additional flash info, or may have rejected some
Expand Down
21 changes: 17 additions & 4 deletions src/rpc/core_rpc_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3065,9 +3065,21 @@ namespace cryptonote { namespace rpc {
entry.decommission_count = info.decommission_count;
entry.last_decommission_reason_consensus_all = info.last_decommission_reason_consensus_all;
entry.last_decommission_reason_consensus_any = info.last_decommission_reason_consensus_any;

auto& netconf = m_core.get_net_config();
m_core.get_master_node_list().access_proof(mn_info.pubkey, [&entry, &netconf](const auto &proof) {
m_core.get_master_node_list().access_proof(mn_info.pubkey, [
this, &entry, is_me = (m_core.master_node() && m_core.get_master_keys().pub == mn_info.pubkey)
](const auto &proof) {
if (is_me) {
entry.master_node_version = BELDEX_VERSION;
entry.belnet_version = m_core.belnet_version;
entry.storage_server_version = m_core.ss_version;
entry.public_ip = epee::string_tools::get_ip_string_from_int32(m_core.mn_public_ip());
entry.storage_port = m_core.storage_https_port();
entry.storage_lmq_port = m_core.storage_omq_port();
entry.quorumnet_port = m_core.quorumnet_port();
entry.pubkey_ed25519 = tools::type_to_hex(m_core.get_master_keys().pub_ed25519);
entry.pubkey_x25519 = tools::type_to_hex(m_core.get_master_keys().pub_x25519);
}
else{
entry.master_node_version = proof.proof->version;
entry.belnet_version = proof.proof->belnet_version;
entry.storage_server_version = proof.proof->storage_server_version;
Expand All @@ -3077,11 +3089,12 @@ namespace cryptonote { namespace rpc {
entry.pubkey_ed25519 = proof.proof->pubkey_ed25519 ? tools::type_to_hex(proof.proof->pubkey_ed25519) : "";
entry.pubkey_x25519 = proof.pubkey_x25519 ? tools::type_to_hex(proof.pubkey_x25519) : "";
entry.quorumnet_port = proof.proof->qnet_port;

}
// NOTE: Master Node Testing
entry.last_uptime_proof = proof.timestamp;
auto system_now = std::chrono::system_clock::now();
auto steady_now = std::chrono::steady_clock::now();
auto& netconf = m_core.get_net_config();
entry.storage_server_reachable = !proof.ss_reachable.unreachable_for(netconf.UPTIME_PROOF_VALIDITY - netconf.UPTIME_PROOF_FREQUENCY, steady_now);
entry.storage_server_first_unreachable = reachable_to_time_t(proof.ss_reachable.first_unreachable, system_now, steady_now);
entry.storage_server_last_unreachable = reachable_to_time_t(proof.ss_reachable.last_unreachable, system_now, steady_now);
Expand Down

0 comments on commit 5ae04ac

Please sign in to comment.