mirror of
https://github.com/monero-project/monero.git
synced 2025-11-27 06:16:31 -05:00
Merge pull request #6146
70c9cd3c Change to Tx diffusion (Dandelion++ fluff) instead of flooding (Lee Clagett)
This commit is contained in:
commit
d1b08c00cf
15 changed files with 280 additions and 97 deletions
|
|
@ -161,6 +161,10 @@ namespace nodetool
|
|||
const command_line::arg_descriptor<int64_t> arg_limit_rate_down = {"limit-rate-down", "set limit-rate-down [kB/s]", P2P_DEFAULT_LIMIT_RATE_DOWN};
|
||||
const command_line::arg_descriptor<int64_t> arg_limit_rate = {"limit-rate", "set limit-rate [kB/s]", -1};
|
||||
|
||||
const command_line::arg_descriptor<bool> arg_pad_transactions = {
|
||||
"pad-transactions", "Pad relayed transactions to help defend against traffic volume analysis", false
|
||||
};
|
||||
|
||||
boost::optional<std::vector<proxy>> get_proxies(boost::program_options::variables_map const& vm)
|
||||
{
|
||||
namespace ip = boost::asio::ip;
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@
|
|||
#include <boost/program_options/options_description.hpp>
|
||||
#include <boost/program_options/variables_map.hpp>
|
||||
#include <boost/uuid/uuid.hpp>
|
||||
#include <chrono>
|
||||
#include <functional>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
|
@ -109,8 +110,16 @@ namespace nodetool
|
|||
template<class base_type>
|
||||
struct p2p_connection_context_t: base_type //t_payload_net_handler::connection_context //public net_utils::connection_context_base
|
||||
{
|
||||
p2p_connection_context_t(): peer_id(0), support_flags(0), m_in_timedsync(false) {}
|
||||
p2p_connection_context_t()
|
||||
: fluff_txs(),
|
||||
flush_time(std::chrono::steady_clock::time_point::max()),
|
||||
peer_id(0),
|
||||
support_flags(0),
|
||||
m_in_timedsync(false)
|
||||
{}
|
||||
|
||||
std::vector<cryptonote::blobdata> fluff_txs;
|
||||
std::chrono::steady_clock::time_point flush_time;
|
||||
peerid_type peer_id;
|
||||
uint32_t support_flags;
|
||||
bool m_in_timedsync;
|
||||
|
|
@ -337,7 +346,7 @@ namespace nodetool
|
|||
virtual void callback(p2p_connection_context& context);
|
||||
//----------------- i_p2p_endpoint -------------------------------------------------------------
|
||||
virtual bool relay_notify_to_list(int command, const epee::span<const uint8_t> data_buff, std::vector<std::pair<epee::net_utils::zone, boost::uuids::uuid>> connections);
|
||||
virtual epee::net_utils::zone send_txs(std::vector<cryptonote::blobdata> txs, const epee::net_utils::zone origin, const boost::uuids::uuid& source, cryptonote::i_core_events& core, bool pad_txs);
|
||||
virtual epee::net_utils::zone send_txs(std::vector<cryptonote::blobdata> txs, const epee::net_utils::zone origin, const boost::uuids::uuid& source, cryptonote::i_core_events& core);
|
||||
virtual bool invoke_command_to_peer(int command, const epee::span<const uint8_t> req_buff, std::string& resp_buff, const epee::net_utils::connection_context_base& context);
|
||||
virtual bool invoke_notify_to_peer(int command, const epee::span<const uint8_t> req_buff, const epee::net_utils::connection_context_base& context);
|
||||
virtual bool drop_connection(const epee::net_utils::connection_context_base& context);
|
||||
|
|
@ -540,6 +549,7 @@ namespace nodetool
|
|||
extern const command_line::arg_descriptor<int64_t> arg_limit_rate_up;
|
||||
extern const command_line::arg_descriptor<int64_t> arg_limit_rate_down;
|
||||
extern const command_line::arg_descriptor<int64_t> arg_limit_rate;
|
||||
extern const command_line::arg_descriptor<bool> arg_pad_transactions;
|
||||
}
|
||||
|
||||
POP_WARNINGS
|
||||
|
|
|
|||
|
|
@ -116,6 +116,7 @@ namespace nodetool
|
|||
command_line::add_arg(desc, arg_limit_rate_up);
|
||||
command_line::add_arg(desc, arg_limit_rate_down);
|
||||
command_line::add_arg(desc, arg_limit_rate);
|
||||
command_line::add_arg(desc, arg_pad_transactions);
|
||||
}
|
||||
//-----------------------------------------------------------------------------------
|
||||
template<class t_payload_net_handler>
|
||||
|
|
@ -340,6 +341,7 @@ namespace nodetool
|
|||
{
|
||||
bool testnet = command_line::get_arg(vm, cryptonote::arg_testnet_on);
|
||||
bool stagenet = command_line::get_arg(vm, cryptonote::arg_stagenet_on);
|
||||
const bool pad_txs = command_line::get_arg(vm, arg_pad_transactions);
|
||||
m_nettype = testnet ? cryptonote::TESTNET : stagenet ? cryptonote::STAGENET : cryptonote::MAINNET;
|
||||
|
||||
network_zone& public_zone = m_network_zones[epee::net_utils::zone::public_];
|
||||
|
|
@ -384,7 +386,7 @@ namespace nodetool
|
|||
m_use_ipv6 = command_line::get_arg(vm, arg_p2p_use_ipv6);
|
||||
m_require_ipv4 = !command_line::get_arg(vm, arg_p2p_ignore_ipv4);
|
||||
public_zone.m_notifier = cryptonote::levin::notify{
|
||||
public_zone.m_net_server.get_io_service(), public_zone.m_net_server.get_config_shared(), nullptr, true
|
||||
public_zone.m_net_server.get_io_service(), public_zone.m_net_server.get_config_shared(), nullptr, true, pad_txs
|
||||
};
|
||||
|
||||
if (command_line::has_arg(vm, arg_p2p_add_peer))
|
||||
|
|
@ -495,7 +497,7 @@ namespace nodetool
|
|||
}
|
||||
|
||||
zone.m_notifier = cryptonote::levin::notify{
|
||||
zone.m_net_server.get_io_service(), zone.m_net_server.get_config_shared(), std::move(this_noise), false
|
||||
zone.m_net_server.get_io_service(), zone.m_net_server.get_config_shared(), std::move(this_noise), false, pad_txs
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -2054,18 +2056,18 @@ namespace nodetool
|
|||
}
|
||||
//-----------------------------------------------------------------------------------
|
||||
template<class t_payload_net_handler>
|
||||
epee::net_utils::zone node_server<t_payload_net_handler>::send_txs(std::vector<cryptonote::blobdata> txs, const epee::net_utils::zone origin, const boost::uuids::uuid& source, cryptonote::i_core_events& core, const bool pad_txs)
|
||||
epee::net_utils::zone node_server<t_payload_net_handler>::send_txs(std::vector<cryptonote::blobdata> txs, const epee::net_utils::zone origin, const boost::uuids::uuid& source, cryptonote::i_core_events& core)
|
||||
{
|
||||
namespace enet = epee::net_utils;
|
||||
|
||||
const auto send = [&txs, &source, &core, pad_txs] (std::pair<const enet::zone, network_zone>& network)
|
||||
const auto send = [&txs, &source, &core] (std::pair<const enet::zone, network_zone>& network)
|
||||
{
|
||||
const bool is_public = (network.first == enet::zone::public_);
|
||||
const cryptonote::relay_method tx_relay = is_public ?
|
||||
cryptonote::relay_method::flood : cryptonote::relay_method::local;
|
||||
cryptonote::relay_method::fluff : cryptonote::relay_method::local;
|
||||
|
||||
core.on_transactions_relayed(epee::to_span(txs), tx_relay);
|
||||
if (network.second.m_notifier.send_txs(std::move(txs), source, (pad_txs || !is_public)))
|
||||
if (network.second.m_notifier.send_txs(std::move(txs), source))
|
||||
return network.first;
|
||||
return enet::zone::invalid;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ namespace nodetool
|
|||
struct i_p2p_endpoint
|
||||
{
|
||||
virtual bool relay_notify_to_list(int command, const epee::span<const uint8_t> data_buff, std::vector<std::pair<epee::net_utils::zone, boost::uuids::uuid>> connections)=0;
|
||||
virtual epee::net_utils::zone send_txs(std::vector<cryptonote::blobdata> txs, const epee::net_utils::zone origin, const boost::uuids::uuid& source, cryptonote::i_core_events& core, bool pad_txs)=0;
|
||||
virtual epee::net_utils::zone send_txs(std::vector<cryptonote::blobdata> txs, const epee::net_utils::zone origin, const boost::uuids::uuid& source, cryptonote::i_core_events& core)=0;
|
||||
virtual bool invoke_command_to_peer(int command, const epee::span<const uint8_t> req_buff, std::string& resp_buff, const epee::net_utils::connection_context_base& context)=0;
|
||||
virtual bool invoke_notify_to_peer(int command, const epee::span<const uint8_t> req_buff, const epee::net_utils::connection_context_base& context)=0;
|
||||
virtual bool drop_connection(const epee::net_utils::connection_context_base& context)=0;
|
||||
|
|
@ -75,7 +75,7 @@ namespace nodetool
|
|||
{
|
||||
return false;
|
||||
}
|
||||
virtual epee::net_utils::zone send_txs(std::vector<cryptonote::blobdata> txs, const epee::net_utils::zone origin, const boost::uuids::uuid& source, cryptonote::i_core_events& core, const bool pad_txs)
|
||||
virtual epee::net_utils::zone send_txs(std::vector<cryptonote::blobdata> txs, const epee::net_utils::zone origin, const boost::uuids::uuid& source, cryptonote::i_core_events& core)
|
||||
{
|
||||
return epee::net_utils::zone::invalid;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue