mirror of https://github.com/oxen-io/oxen-core.git
commit
d14aba3329
|
@ -1441,39 +1441,14 @@ namespace cryptonote
|
|||
//-----------------------------------------------------------------------------------------------
|
||||
bool core::relay_service_node_votes()
|
||||
{
|
||||
std::vector<service_nodes::quorum_vote_t> relayable_votes = m_quorum_cop.get_relayable_votes(get_current_blockchain_height());
|
||||
uint8_t hf_version = get_blockchain_storage().get_current_hard_fork_version();
|
||||
if (hf_version < cryptonote::network_version_12_checkpointing)
|
||||
NOTIFY_NEW_SERVICE_NODE_VOTE::request req = {};
|
||||
req.votes = m_quorum_cop.get_relayable_votes(get_current_blockchain_height());
|
||||
if (req.votes.size())
|
||||
{
|
||||
NOTIFY_NEW_DEREGISTER_VOTE::request req = {};
|
||||
for (service_nodes::quorum_vote_t const &vote : relayable_votes)
|
||||
cryptonote_connection_context fake_context = AUTO_VAL_INIT(fake_context);
|
||||
if (get_protocol()->relay_service_node_votes(req, fake_context))
|
||||
{
|
||||
service_nodes::legacy_deregister_vote legacy_vote = {};
|
||||
if (service_nodes::convert_deregister_vote_to_legacy(vote, legacy_vote))
|
||||
req.votes.push_back(legacy_vote);
|
||||
}
|
||||
|
||||
if (req.votes.size())
|
||||
{
|
||||
cryptonote_connection_context fake_context = AUTO_VAL_INIT(fake_context);
|
||||
if (get_protocol()->relay_deregister_votes(req, fake_context))
|
||||
{
|
||||
m_quorum_cop.set_votes_relayed(relayable_votes);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Get relayable votes
|
||||
NOTIFY_NEW_SERVICE_NODE_VOTE::request req = {};
|
||||
req.votes = std::move(relayable_votes);
|
||||
if (req.votes.size())
|
||||
{
|
||||
cryptonote_connection_context fake_context = AUTO_VAL_INIT(fake_context);
|
||||
if (get_protocol()->relay_service_node_votes(req, fake_context))
|
||||
{
|
||||
m_quorum_cop.set_votes_relayed(req.votes);
|
||||
}
|
||||
m_quorum_cop.set_votes_relayed(req.votes);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1572,7 +1547,7 @@ namespace cryptonote
|
|||
add_new_block(b, bvc, nullptr /*checkpoint*/);
|
||||
cleanup_handle_incoming_blocks(true);
|
||||
//anyway - update miner template
|
||||
update_miner_block_template();
|
||||
m_miner.on_block_chain_update();
|
||||
m_miner.resume();
|
||||
|
||||
|
||||
|
@ -1687,7 +1662,7 @@ namespace cryptonote
|
|||
}
|
||||
add_new_block(*b, bvc, checkpoint);
|
||||
if(update_miner_blocktemplate && bvc.m_added_to_main_chain)
|
||||
update_miner_block_template();
|
||||
m_miner.on_block_chain_update();
|
||||
return true;
|
||||
|
||||
CATCH_ENTRY_L0("core::handle_incoming_block()", false);
|
||||
|
@ -1802,12 +1777,6 @@ namespace cryptonote
|
|||
return m_mempool.print_pool(short_format);
|
||||
}
|
||||
//-----------------------------------------------------------------------------------------------
|
||||
bool core::update_miner_block_template()
|
||||
{
|
||||
m_miner.on_block_chain_update();
|
||||
return true;
|
||||
}
|
||||
//-----------------------------------------------------------------------------------------------
|
||||
static bool check_storage_server_ping(time_t last_time_storage_server_pinged)
|
||||
{
|
||||
const auto elapsed = std::time(nullptr) - last_time_storage_server_pinged;
|
||||
|
|
|
@ -979,15 +979,6 @@ namespace cryptonote
|
|||
struct tx_verification_batch_info { const cryptonote::transaction *tx; crypto::hash tx_hash; tx_verification_context &tvc; bool &result; };
|
||||
bool handle_incoming_tx_accumulated_batch(std::vector<tx_verification_batch_info> &tx_info, bool keeped_by_block);
|
||||
|
||||
/**
|
||||
* @copydoc miner::on_block_chain_update
|
||||
*
|
||||
* @note see miner::on_block_chain_update
|
||||
*
|
||||
* @return true
|
||||
*/
|
||||
bool update_miner_block_template();
|
||||
|
||||
/**
|
||||
* @brief act on a set of command line options given
|
||||
*
|
||||
|
|
|
@ -49,32 +49,6 @@
|
|||
|
||||
namespace service_nodes
|
||||
{
|
||||
bool convert_deregister_vote_to_legacy(quorum_vote_t const &vote, legacy_deregister_vote &legacy_vote)
|
||||
{
|
||||
if (vote.type != quorum_type::obligations || vote.state_change.state != new_state::deregister)
|
||||
return false;
|
||||
|
||||
legacy_vote.block_height = vote.block_height;
|
||||
legacy_vote.service_node_index = vote.state_change.worker_index;
|
||||
legacy_vote.voters_quorum_index = vote.index_in_group;
|
||||
legacy_vote.signature = vote.signature;
|
||||
return true;
|
||||
}
|
||||
|
||||
// TODO(loki): Post HF12 remove legacy votes, no longer should be propagated
|
||||
quorum_vote_t convert_legacy_deregister_vote(legacy_deregister_vote const &vote)
|
||||
{
|
||||
quorum_vote_t result = {};
|
||||
result.type = quorum_type::obligations;
|
||||
result.block_height = vote.block_height;
|
||||
result.signature = vote.signature;
|
||||
result.group = quorum_group::validator;
|
||||
result.index_in_group = vote.voters_quorum_index;
|
||||
result.state_change.worker_index = vote.service_node_index;
|
||||
result.state_change.state = new_state::deregister;
|
||||
return result;
|
||||
}
|
||||
|
||||
static crypto::hash make_state_change_vote_hash(uint64_t block_height, uint32_t service_node_index, new_state state)
|
||||
{
|
||||
uint16_t state_int = static_cast<uint16_t>(state);
|
||||
|
|
|
@ -121,9 +121,6 @@ namespace service_nodes
|
|||
crypto::signature signature;
|
||||
};
|
||||
|
||||
bool convert_deregister_vote_to_legacy(quorum_vote_t const &vote, legacy_deregister_vote &legacy);
|
||||
quorum_vote_t convert_legacy_deregister_vote (legacy_deregister_vote const &vote);
|
||||
|
||||
struct pool_vote_entry
|
||||
{
|
||||
quorum_vote_t vote;
|
||||
|
|
|
@ -291,25 +291,6 @@ namespace cryptonote
|
|||
typedef epee::misc_utils::struct_init<request_t> request;
|
||||
};
|
||||
|
||||
/************************************************************************/
|
||||
/* */
|
||||
/************************************************************************/
|
||||
struct NOTIFY_NEW_DEREGISTER_VOTE
|
||||
{
|
||||
// TODO(doyle): We need to remove this code post fork, pre checkpointing
|
||||
// fork which revamps the voting system, we need to continue accepting
|
||||
// deregisters using the old system.
|
||||
const static int ID = BC_COMMANDS_POOL_BASE + 10;
|
||||
|
||||
struct request
|
||||
{
|
||||
std::vector<service_nodes::legacy_deregister_vote> votes;
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE_CONTAINER_POD_AS_BLOB(votes)
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
};
|
||||
|
||||
/************************************************************************/
|
||||
/* */
|
||||
/************************************************************************/
|
||||
|
|
|
@ -92,7 +92,6 @@ namespace cryptonote
|
|||
HANDLE_NOTIFY_T2(NOTIFY_RESPONSE_CHAIN_ENTRY, &cryptonote_protocol_handler::handle_response_chain_entry)
|
||||
HANDLE_NOTIFY_T2(NOTIFY_NEW_FLUFFY_BLOCK, &cryptonote_protocol_handler::handle_notify_new_fluffy_block)
|
||||
HANDLE_NOTIFY_T2(NOTIFY_REQUEST_FLUFFY_MISSING_TX, &cryptonote_protocol_handler::handle_request_fluffy_missing_tx)
|
||||
HANDLE_NOTIFY_T2(NOTIFY_NEW_DEREGISTER_VOTE, &cryptonote_protocol_handler::handle_notify_new_deregister_vote)
|
||||
HANDLE_NOTIFY_T2(NOTIFY_UPTIME_PROOF, &cryptonote_protocol_handler::handle_uptime_proof)
|
||||
HANDLE_NOTIFY_T2(NOTIFY_NEW_SERVICE_NODE_VOTE, &cryptonote_protocol_handler::handle_notify_new_service_node_vote)
|
||||
END_INVOKE_MAP2()
|
||||
|
@ -128,7 +127,6 @@ namespace cryptonote
|
|||
int handle_response_chain_entry(int command, NOTIFY_RESPONSE_CHAIN_ENTRY::request& arg, cryptonote_connection_context& context);
|
||||
int handle_notify_new_fluffy_block(int command, NOTIFY_NEW_FLUFFY_BLOCK::request& arg, cryptonote_connection_context& context);
|
||||
int handle_request_fluffy_missing_tx(int command, NOTIFY_REQUEST_FLUFFY_MISSING_TX::request& arg, cryptonote_connection_context& context);
|
||||
int handle_notify_new_deregister_vote(int command, NOTIFY_NEW_DEREGISTER_VOTE::request& arg, cryptonote_connection_context& context);
|
||||
int handle_uptime_proof(int command, NOTIFY_UPTIME_PROOF::request& arg, cryptonote_connection_context& context);
|
||||
int handle_notify_new_service_node_vote(int command, NOTIFY_NEW_SERVICE_NODE_VOTE::request& arg, cryptonote_connection_context& context);
|
||||
|
||||
|
@ -154,7 +152,6 @@ namespace cryptonote
|
|||
|
||||
virtual bool relay_block(NOTIFY_NEW_FLUFFY_BLOCK::request& arg, cryptonote_connection_context& exclude_context);
|
||||
virtual bool relay_transactions(NOTIFY_NEW_TRANSACTIONS::request& arg, cryptonote_connection_context& exclude_context);
|
||||
virtual bool relay_deregister_votes(NOTIFY_NEW_DEREGISTER_VOTE::request& arg, cryptonote_connection_context& exclude_context);
|
||||
virtual bool relay_uptime_proof(NOTIFY_UPTIME_PROOF::request& arg, cryptonote_connection_context& exclude_context);
|
||||
virtual bool relay_service_node_votes(NOTIFY_NEW_SERVICE_NODE_VOTE::request& arg, cryptonote_connection_context& exclude_context);
|
||||
//----------------------------------------------------------------------------------
|
||||
|
|
|
@ -873,57 +873,6 @@ namespace cryptonote
|
|||
}
|
||||
//------------------------------------------------------------------------------------------------------------------------
|
||||
template<class t_core>
|
||||
int t_cryptonote_protocol_handler<t_core>::handle_notify_new_deregister_vote(int command, NOTIFY_NEW_DEREGISTER_VOTE::request& arg, cryptonote_connection_context& context)
|
||||
{
|
||||
MLOG_P2P_MESSAGE("Received NOTIFY_NEW_DEREGISTER_VOTE (" << arg.votes.size() << " txes)");
|
||||
if (m_core.get_blockchain_storage().get_current_hard_fork_version() >= cryptonote::network_version_12_checkpointing)
|
||||
{
|
||||
LOG_DEBUG_CC(context, "Received new deregister vote in HF12, reject. We have a new style of voting");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(context.m_state != cryptonote_connection_context::state_normal)
|
||||
return 1;
|
||||
|
||||
if(!is_synchronized())
|
||||
{
|
||||
LOG_DEBUG_CC(context, "Received new deregister vote while syncing, ignored");
|
||||
return 1;
|
||||
}
|
||||
|
||||
for(auto it = arg.votes.begin(); it != arg.votes.end();)
|
||||
{
|
||||
cryptonote::vote_verification_context vvc = {};
|
||||
service_nodes::legacy_deregister_vote const &legacy_vote = (*it);
|
||||
service_nodes::quorum_vote_t const vote = service_nodes::convert_legacy_deregister_vote(legacy_vote);
|
||||
m_core.add_service_node_vote(vote, vvc);
|
||||
|
||||
if (vvc.m_verification_failed)
|
||||
{
|
||||
LOG_PRINT_CCONTEXT_L1("Deregister vote verification failed, dropping connection");
|
||||
drop_connection(context, false /*add_fail*/, false /*flush_all_spans i.e. delete cached block data from this peer*/);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (vvc.m_added_to_pool)
|
||||
{
|
||||
it++;
|
||||
}
|
||||
else
|
||||
{
|
||||
it = arg.votes.erase(it);
|
||||
}
|
||||
}
|
||||
|
||||
if (arg.votes.size())
|
||||
{
|
||||
relay_deregister_votes(arg, context);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------------------------------
|
||||
template<class t_core>
|
||||
int t_cryptonote_protocol_handler<t_core>::handle_notify_new_transactions(int command, NOTIFY_NEW_TRANSACTIONS::request& arg, cryptonote_connection_context& context)
|
||||
{
|
||||
MLOG_P2P_MESSAGE("Received NOTIFY_NEW_TRANSACTIONS (" << arg.txs.size() << " txes)");
|
||||
|
@ -2306,13 +2255,6 @@ skip:
|
|||
}
|
||||
//------------------------------------------------------------------------------------------------------------------------
|
||||
template<class t_core>
|
||||
bool t_cryptonote_protocol_handler<t_core>::relay_deregister_votes(NOTIFY_NEW_DEREGISTER_VOTE::request& arg, cryptonote_connection_context& exclude_context)
|
||||
{
|
||||
bool result = relay_on_public_network_generic<NOTIFY_NEW_DEREGISTER_VOTE>(arg, exclude_context);
|
||||
return result;
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------------------------------
|
||||
template<class t_core>
|
||||
bool t_cryptonote_protocol_handler<t_core>::relay_uptime_proof(NOTIFY_UPTIME_PROOF::request& arg, cryptonote_connection_context& exclude_context)
|
||||
{
|
||||
bool result = relay_on_public_network_generic<NOTIFY_UPTIME_PROOF>(arg, exclude_context);
|
||||
|
|
|
@ -44,7 +44,6 @@ namespace cryptonote
|
|||
virtual bool relay_transactions(NOTIFY_NEW_TRANSACTIONS::request& arg, cryptonote_connection_context& exclude_context)=0;
|
||||
virtual bool relay_uptime_proof(NOTIFY_UPTIME_PROOF::request& arg, cryptonote_connection_context& exclude_context)=0;
|
||||
//virtual bool request_objects(NOTIFY_REQUEST_GET_OBJECTS::request& arg, cryptonote_connection_context& context)=0;
|
||||
virtual bool relay_deregister_votes(NOTIFY_NEW_DEREGISTER_VOTE::request& arg, cryptonote_connection_context& exclude_context)=0;
|
||||
virtual bool relay_service_node_votes(NOTIFY_NEW_SERVICE_NODE_VOTE::request& arg, cryptonote_connection_context& exclude_context)=0;
|
||||
};
|
||||
|
||||
|
@ -61,10 +60,6 @@ namespace cryptonote
|
|||
{
|
||||
return false;
|
||||
}
|
||||
virtual bool relay_deregister_votes(NOTIFY_NEW_DEREGISTER_VOTE::request& arg, cryptonote_connection_context& exclude_context)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
virtual bool relay_service_node_votes(NOTIFY_NEW_SERVICE_NODE_VOTE::request& arg, cryptonote_connection_context& exclude_context)
|
||||
{
|
||||
return false;
|
||||
|
|
Loading…
Reference in New Issue