Skip to content

Commit

Permalink
Merge pull request #6146
Browse files Browse the repository at this point in the history
70c9cd3 Change to Tx diffusion (Dandelion++ fluff) instead of flooding (Lee Clagett)
  • Loading branch information
Snipa22 committed Jan 25, 2020
2 parents 5558919 + 70c9cd3 commit d1b08c0
Show file tree
Hide file tree
Showing 15 changed files with 280 additions and 97 deletions.
6 changes: 3 additions & 3 deletions src/blockchain_db/blockchain_db.cpp
Expand Up @@ -67,7 +67,7 @@ bool matches_category(relay_method method, relay_category category) noexcept
case relay_method::local:
return false;
case relay_method::block:
case relay_method::flood:
case relay_method::fluff:
return true;
case relay_method::none:
break;
Expand All @@ -90,7 +90,7 @@ void txpool_tx_meta_t::set_relay_method(relay_method method) noexcept
is_local = 1;
break;
default:
case relay_method::flood:
case relay_method::fluff:
break;
case relay_method::block:
kept_by_block = 1;
Expand All @@ -106,7 +106,7 @@ relay_method txpool_tx_meta_t::get_relay_method() const noexcept
return relay_method::none;
if (is_local)
return relay_method::local;
return relay_method::flood;
return relay_method::fluff;
}

const command_line::arg_descriptor<std::string> arg_db_sync_mode = {
Expand Down
2 changes: 1 addition & 1 deletion src/blockchain_db/blockchain_db.h
Expand Up @@ -108,7 +108,7 @@ extern const command_line::arg_descriptor<bool, false> arg_db_salvage;

enum class relay_category : uint8_t
{
broadcasted = 0,//!< Public txes received via block/flooding/fluff
broadcasted = 0,//!< Public txes received via block/fluff
relayable, //!< Every tx not marked `relay_method::none`
legacy, //!< `relay_category::broadcasted` + `relay_method::none` for rpc relay requests or historical reasons
all //!< Everything in the db
Expand Down
3 changes: 3 additions & 0 deletions src/cryptonote_config.h
Expand Up @@ -101,6 +101,9 @@
#define CRYPTONOTE_MEMPOOL_TX_LIVETIME (86400*3) //seconds, three days
#define CRYPTONOTE_MEMPOOL_TX_FROM_ALT_BLOCK_LIVETIME 604800 //seconds, one week


#define CRYPTONOTE_DANDELIONPP_FLUSH_AVERAGE 5 // seconds

// see src/cryptonote_protocol/levin_notify.cpp
#define CRYPTONOTE_NOISE_MIN_EPOCH 5 // minutes
#define CRYPTONOTE_NOISE_EPOCH_RANGE 30 // seconds
Expand Down
12 changes: 2 additions & 10 deletions src/cryptonote_core/cryptonote_core.cpp
Expand Up @@ -174,11 +174,6 @@ namespace cryptonote
, "Relay blocks as normal blocks"
, false
};
static const command_line::arg_descriptor<bool> arg_pad_transactions = {
"pad-transactions"
, "Pad relayed transactions to help defend against traffic volume analysis"
, false
};
static const command_line::arg_descriptor<size_t> arg_max_txpool_weight = {
"max-txpool-weight"
, "Set maximum txpool weight in bytes."
Expand Down Expand Up @@ -235,8 +230,7 @@ namespace cryptonote
m_disable_dns_checkpoints(false),
m_update_download(0),
m_nettype(UNDEFINED),
m_update_available(false),
m_pad_transactions(false)
m_update_available(false)
{
m_checkpoints_updating.clear();
set_cryptonote_protocol(pprotocol);
Expand Down Expand Up @@ -333,7 +327,6 @@ namespace cryptonote
command_line::add_arg(desc, arg_block_download_max_size);
command_line::add_arg(desc, arg_sync_pruned_blocks);
command_line::add_arg(desc, arg_max_txpool_weight);
command_line::add_arg(desc, arg_pad_transactions);
command_line::add_arg(desc, arg_block_notify);
command_line::add_arg(desc, arg_prune_blockchain);
command_line::add_arg(desc, arg_reorg_notify);
Expand Down Expand Up @@ -376,7 +369,6 @@ namespace cryptonote
set_enforce_dns_checkpoints(command_line::get_arg(vm, arg_dns_checkpoints));
test_drop_download_height(command_line::get_arg(vm, arg_test_drop_download_height));
m_fluffy_blocks_enabled = !get_arg(vm, arg_no_fluffy_blocks);
m_pad_transactions = get_arg(vm, arg_pad_transactions);
m_offline = get_arg(vm, arg_offline);
m_disable_dns_checkpoints = get_arg(vm, arg_disable_dns_checkpoints);
if (!command_line::is_arg_defaulted(vm, arg_fluffy_blocks))
Expand Down Expand Up @@ -1295,7 +1287,7 @@ namespace cryptonote
private_req.txs.push_back(std::move(std::get<1>(tx)));
break;
case relay_method::block:
case relay_method::flood:
case relay_method::fluff:
public_req.txs.push_back(std::move(std::get<1>(tx)));
break;
}
Expand Down
8 changes: 0 additions & 8 deletions src/cryptonote_core/cryptonote_core.h
Expand Up @@ -791,13 +791,6 @@ namespace cryptonote
*/
bool fluffy_blocks_enabled() const { return m_fluffy_blocks_enabled; }

/**
* @brief get whether transaction relay should be padded
*
* @return whether transaction relay should be padded
*/
bool pad_transactions() const { return m_pad_transactions; }

/**
* @brief check a set of hashes against the precompiled hash set
*
Expand Down Expand Up @@ -1102,7 +1095,6 @@ namespace cryptonote

bool m_fluffy_blocks_enabled;
bool m_offline;
bool m_pad_transactions;

std::shared_ptr<tools::Notify> m_block_rate_notify;
};
Expand Down
4 changes: 2 additions & 2 deletions src/cryptonote_protocol/cryptonote_protocol_handler.inl
Expand Up @@ -910,7 +910,7 @@ namespace cryptonote
for (size_t i = 0; i < arg.txs.size(); ++i)
{
cryptonote::tx_verification_context tvc{};
m_core.handle_incoming_tx({arg.txs[i], crypto::null_hash}, tvc, relay_method::flood, true);
m_core.handle_incoming_tx({arg.txs[i], crypto::null_hash}, tvc, relay_method::fluff, true);
if(tvc.m_verifivation_failed)
{
LOG_PRINT_CCONTEXT_L1("Tx verification failed, dropping connection");
Expand Down Expand Up @@ -2351,7 +2351,7 @@ skip:
local mempool before doing the relay. The code was already updating the
DB twice on received transactions - it is difficult to workaround this
due to the internal design. */
return m_p2p->send_txs(std::move(arg.txs), zone, source, m_core, m_core.pad_transactions()) != epee::net_utils::zone::invalid;
return m_p2p->send_txs(std::move(arg.txs), zone, source, m_core) != epee::net_utils::zone::invalid;
}
//------------------------------------------------------------------------------------------------------------------------
template<class t_core>
Expand Down
2 changes: 1 addition & 1 deletion src/cryptonote_protocol/enums.h
Expand Up @@ -38,6 +38,6 @@ namespace cryptonote
none = 0, //!< Received via RPC with `do_not_relay` set
local, //!< Received via RPC; trying to send over i2p/tor, etc.
block, //!< Received in block, takes precedence over others
flood //!< Received/sent over public networks
fluff //!< Received/sent over public networks
};
}

0 comments on commit d1b08c0

Please sign in to comment.