diff --git a/src/net.h b/src/net.h --- a/src/net.h +++ b/src/net.h @@ -67,7 +67,7 @@ * Maximum number of automatic outgoing nodes over which we'll relay everything * (blocks, tx, addrs, etc) */ -static const int MAX_OUTBOUND_FULL_RELAY_CONNECTIONS = 8; +static const int MAX_OUTBOUND_FULL_RELAY_CONNECTIONS = 16; /** Maximum number of addnode outgoing nodes */ static const int MAX_ADDNODE_CONNECTIONS = 8; /** Maximum number of block-relay-only outgoing connections */ diff --git a/test/functional/p2p_add_connections.py b/test/functional/p2p_add_connections.py --- a/test/functional/p2p_add_connections.py +++ b/test/functional/p2p_add_connections.py @@ -8,6 +8,11 @@ from test_framework.test_framework import BitcoinTestFramework from test_framework.util import assert_equal, check_node_connections +MAX_OUTBOUND_FULL_RELAY_CONNECTIONS = 16 +MAX_BLOCK_RELAY_ONLY_CONNECTIONS = 2 +MAX_OUTBOUND_CONNECTIONS = MAX_OUTBOUND_FULL_RELAY_CONNECTIONS + \ + MAX_BLOCK_RELAY_ONLY_CONNECTIONS + class P2PFeelerReceiver(P2PInterface): def on_version(self, message): @@ -41,53 +46,102 @@ ) self.p2p_idx[node.index] += 1 - self.log.info("Add 8 outbounds to node 0") - add_outbounds(self.nodes[0], 8, "outbound-full-relay") - - self.log.info("Add 2 block-relay-only connections to node 0") - add_outbounds(self.nodes[0], 2, "block-relay-only") - - self.log.info("Add 2 block-relay-only connections to node 1") - add_outbounds(self.nodes[1], 2, "block-relay-only") + self.log.info( + f"Add {MAX_OUTBOUND_FULL_RELAY_CONNECTIONS} outbounds to node 0") + add_outbounds( + self.nodes[0], + MAX_OUTBOUND_FULL_RELAY_CONNECTIONS, + "outbound-full-relay") + + self.log.info( + f"Add {MAX_BLOCK_RELAY_ONLY_CONNECTIONS} block-relay-only connections to node 0") + add_outbounds( + self.nodes[0], + MAX_BLOCK_RELAY_ONLY_CONNECTIONS, + "block-relay-only") + + self.log.info( + f"Add {MAX_BLOCK_RELAY_ONLY_CONNECTIONS} block-relay-only connections to node 1") + add_outbounds( + self.nodes[1], + MAX_BLOCK_RELAY_ONLY_CONNECTIONS, + "block-relay-only") self.log.info("Add 5 inbound connections to node 1") for i in range(5): self.log.info(f"inbound: {i}") self.nodes[1].add_p2p_connection(P2PInterface()) - self.log.info("Add 8 outbounds to node 1") - add_outbounds(self.nodes[1], 8, "outbound-full-relay") + self.log.info("Add 4 outbounds to node 1") + add_outbounds(self.nodes[1], 4, "outbound-full-relay") self.log.info("Check the connections opened as expected") - check_node_connections(node=self.nodes[0], num_in=0, num_out=10) - check_node_connections(node=self.nodes[1], num_in=5, num_out=10) + check_node_connections( + node=self.nodes[0], + num_in=0, + num_out=MAX_OUTBOUND_CONNECTIONS) + check_node_connections( + node=self.nodes[1], + num_in=5, + num_out=4 + MAX_BLOCK_RELAY_ONLY_CONNECTIONS) self.log.info("Disconnect p2p connections & try to re-open") self.nodes[0].disconnect_p2ps() self.p2p_idx[0] = 0 check_node_connections(node=self.nodes[0], num_in=0, num_out=0) - self.log.info("Add 8 outbounds to node 0") - add_outbounds(self.nodes[0], 8, "outbound-full-relay") - check_node_connections(node=self.nodes[0], num_in=0, num_out=8) - - self.log.info("Add 2 block-relay-only connections to node 0") - add_outbounds(self.nodes[0], 2, "block-relay-only") - check_node_connections(node=self.nodes[0], num_in=0, num_out=10) + self.log.info( + f"Add {MAX_OUTBOUND_FULL_RELAY_CONNECTIONS} outbounds to node 0") + add_outbounds( + self.nodes[0], + MAX_OUTBOUND_FULL_RELAY_CONNECTIONS, + "outbound-full-relay") + check_node_connections( + node=self.nodes[0], + num_in=0, + num_out=MAX_OUTBOUND_FULL_RELAY_CONNECTIONS) + + self.log.info( + f"Add {MAX_BLOCK_RELAY_ONLY_CONNECTIONS} block-relay-only connections to node 0") + add_outbounds( + self.nodes[0], + MAX_BLOCK_RELAY_ONLY_CONNECTIONS, + "block-relay-only") + check_node_connections( + node=self.nodes[0], + num_in=0, + num_out=MAX_OUTBOUND_CONNECTIONS) self.log.info("Restart node 0 and try to reconnect to p2ps") self.restart_node(0) self.p2p_idx[0] = 0 - self.log.info("Add 4 outbounds to node 0") - add_outbounds(self.nodes[0], 4, "outbound-full-relay") - check_node_connections(node=self.nodes[0], num_in=0, num_out=4) - - self.log.info("Add 2 block-relay-only connections to node 0") - add_outbounds(self.nodes[0], 2, "block-relay-only") - check_node_connections(node=self.nodes[0], num_in=0, num_out=6) - - check_node_connections(node=self.nodes[1], num_in=5, num_out=10) + self.log.info( + f"Add {MAX_OUTBOUND_FULL_RELAY_CONNECTIONS} outbounds to node 0") + add_outbounds( + self.nodes[0], + MAX_OUTBOUND_FULL_RELAY_CONNECTIONS, + "outbound-full-relay") + check_node_connections( + node=self.nodes[0], + num_in=0, + num_out=MAX_OUTBOUND_FULL_RELAY_CONNECTIONS) + + self.log.info( + f"Add {MAX_BLOCK_RELAY_ONLY_CONNECTIONS} block-relay-only connections to node 0") + add_outbounds( + self.nodes[0], + MAX_BLOCK_RELAY_ONLY_CONNECTIONS, + "block-relay-only") + check_node_connections( + node=self.nodes[0], + num_in=0, + num_out=MAX_OUTBOUND_CONNECTIONS) + + check_node_connections( + node=self.nodes[1], + num_in=5, + num_out=4 + MAX_BLOCK_RELAY_ONLY_CONNECTIONS) self.log.info("Add 1 feeler connection to node 0") feeler_conn = self.nodes[0].add_outbound_p2p_connection( diff --git a/test/functional/p2p_eviction.py b/test/functional/p2p_eviction.py --- a/test/functional/p2p_eviction.py +++ b/test/functional/p2p_eviction.py @@ -54,13 +54,13 @@ def set_test_params(self): self.setup_clean_chain = True self.num_nodes = 1 - # The choice of maxconnections=164 results in a maximum of 153 inbound - # connections (164 - 10 outbound - 1 feeler). 152 inbound peers are + # The choice of maxconnections=172 results in a maximum of 153 inbound + # connections (172 - 18 outbound - 1 feeler). 152 inbound peers are # protected from eviction: # 4 by netgroup, 4 that sent us blocks, 4 that sent us proofs, 4 that # sent us transactions, 8 via lowest ping time, 128 with the best # avalanche availability score - self.extra_args = [['-maxconnections=164', "-enableavalanche=1"]] + self.extra_args = [['-maxconnections=172', "-enableavalanche=1"]] def run_test(self): # peers that we expect to be protected from eviction diff --git a/test/functional/test_framework/util.py b/test/functional/test_framework/util.py --- a/test/functional/test_framework/util.py +++ b/test/functional/test_framework/util.py @@ -294,7 +294,7 @@ # The maximum number of nodes a single test can spawn -MAX_NODES = 12 +MAX_NODES = 64 # Don't assign rpc or p2p ports lower than this (for example: 18333 is the # default testnet port) PORT_MIN = int(os.getenv('TEST_RUNNER_PORT_MIN', default=20000))