mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-13 15:39:05 +01:00
Add 2 outbound block-relay-only connections
Transaction relay is primarily optimized for balancing redundancy/robustness with bandwidth minimization -- as a result transaction relay leaks information that adversaries can use to infer the network topology. Network topology is better kept private for (at least) two reasons: (a) Knowledge of the network graph can make it easier to find the source IP of a given transaction. (b) Knowledge of the network graph could be used to split a target node or nodes from the honest network (eg by knowing which peers to attack in order to achieve a network split). We can eliminate the risks of (b) by separating block relay from transaction relay; inferring network connectivity from the relay of blocks/block headers is much more expensive for an adversary. After this commit, bitcoind will make 2 additional outbound connections that are only used for block relay. (In the future, we might consider rotating our transaction-relay peers to help limit the effects of (a).)
This commit is contained in:
@@ -151,17 +151,17 @@ BOOST_AUTO_TEST_CASE(stale_tip_peer_management)
|
||||
auto peerLogic = MakeUnique<PeerLogicValidation>(connman.get(), nullptr, scheduler, false);
|
||||
|
||||
const Consensus::Params& consensusParams = Params().GetConsensus();
|
||||
constexpr int nMaxOutbound = 8;
|
||||
constexpr int max_outbound_full_relay = 8;
|
||||
CConnman::Options options;
|
||||
options.nMaxConnections = 125;
|
||||
options.nMaxOutbound = nMaxOutbound;
|
||||
options.m_max_outbound_full_relay = max_outbound_full_relay;
|
||||
options.nMaxFeeler = 1;
|
||||
|
||||
connman->Init(options);
|
||||
std::vector<CNode *> vNodes;
|
||||
|
||||
// Mock some outbound peers
|
||||
for (int i=0; i<nMaxOutbound; ++i) {
|
||||
for (int i=0; i<max_outbound_full_relay; ++i) {
|
||||
AddRandomOutboundPeer(vNodes, *peerLogic, connman.get());
|
||||
}
|
||||
|
||||
@@ -190,7 +190,7 @@ BOOST_AUTO_TEST_CASE(stale_tip_peer_management)
|
||||
AddRandomOutboundPeer(vNodes, *peerLogic, connman.get());
|
||||
|
||||
peerLogic->CheckForStaleTipAndEvictPeers(consensusParams);
|
||||
for (int i=0; i<nMaxOutbound; ++i) {
|
||||
for (int i=0; i<max_outbound_full_relay; ++i) {
|
||||
BOOST_CHECK(vNodes[i]->fDisconnect == false);
|
||||
}
|
||||
// Last added node should get marked for eviction
|
||||
@@ -203,10 +203,10 @@ BOOST_AUTO_TEST_CASE(stale_tip_peer_management)
|
||||
UpdateLastBlockAnnounceTime(vNodes.back()->GetId(), GetTime());
|
||||
|
||||
peerLogic->CheckForStaleTipAndEvictPeers(consensusParams);
|
||||
for (int i=0; i<nMaxOutbound-1; ++i) {
|
||||
for (int i=0; i<max_outbound_full_relay-1; ++i) {
|
||||
BOOST_CHECK(vNodes[i]->fDisconnect == false);
|
||||
}
|
||||
BOOST_CHECK(vNodes[nMaxOutbound-1]->fDisconnect == true);
|
||||
BOOST_CHECK(vNodes[max_outbound_full_relay-1]->fDisconnect == true);
|
||||
BOOST_CHECK(vNodes.back()->fDisconnect == false);
|
||||
|
||||
bool dummy;
|
||||
|
||||
Reference in New Issue
Block a user