From 0220b834b175dc8c45a2c60213474a72c0ef8193 Mon Sep 17 00:00:00 2001 From: John Newbery Date: Mon, 23 Aug 2021 10:42:39 +0100 Subject: [test] Add testing for outbound feeler connections Extend the addconnection RPC method to allow creating outbound feeler connections. Extend the test framework to accept those feeler connections. --- src/net.cpp | 4 +++- src/net.h | 4 ++-- src/rpc/net.cpp | 4 +++- 3 files changed, 8 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/net.cpp b/src/net.cpp index 57b8844d6b..504619dec5 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -1217,7 +1217,6 @@ bool CConnman::AddConnection(const std::string& address, ConnectionType conn_typ switch (conn_type) { case ConnectionType::INBOUND: case ConnectionType::MANUAL: - case ConnectionType::FEELER: return false; case ConnectionType::OUTBOUND_FULL_RELAY: max_connections = m_max_outbound_full_relay; @@ -1228,6 +1227,9 @@ bool CConnman::AddConnection(const std::string& address, ConnectionType conn_typ // no limit for ADDR_FETCH because -seednode has no limit either case ConnectionType::ADDR_FETCH: break; + // no limit for FEELER connections since they're short-lived + case ConnectionType::FEELER: + break; } // no default case, so the compiler can warn about missing cases // Count existing connections diff --git a/src/net.h b/src/net.h index 28cd635976..81004a203c 100644 --- a/src/net.h +++ b/src/net.h @@ -892,8 +892,8 @@ public: * Attempts to open a connection. Currently only used from tests. * * @param[in] address Address of node to try connecting to - * @param[in] conn_type ConnectionType::OUTBOUND or ConnectionType::BLOCK_RELAY - * or ConnectionType::ADDR_FETCH + * @param[in] conn_type ConnectionType::OUTBOUND, ConnectionType::BLOCK_RELAY, + * ConnectionType::ADDR_FETCH or ConnectionType::FEELER * @return bool Returns false if there are no available * slots for this connection: * - conn_type not a supported ConnectionType diff --git a/src/rpc/net.cpp b/src/rpc/net.cpp index 861b889118..4ef44a93db 100644 --- a/src/rpc/net.cpp +++ b/src/rpc/net.cpp @@ -343,7 +343,7 @@ static RPCHelpMan addconnection() "\nOpen an outbound connection to a specified node. This RPC is for testing only.\n", { {"address", RPCArg::Type::STR, RPCArg::Optional::NO, "The IP address and port to attempt connecting to."}, - {"connection_type", RPCArg::Type::STR, RPCArg::Optional::NO, "Type of connection to open (\"outbound-full-relay\", \"block-relay-only\" or \"addr-fetch\")."}, + {"connection_type", RPCArg::Type::STR, RPCArg::Optional::NO, "Type of connection to open (\"outbound-full-relay\", \"block-relay-only\", \"addr-fetch\" or \"feeler\")."}, }, RPCResult{ RPCResult::Type::OBJ, "", "", @@ -371,6 +371,8 @@ static RPCHelpMan addconnection() conn_type = ConnectionType::BLOCK_RELAY; } else if (conn_type_in == "addr-fetch") { conn_type = ConnectionType::ADDR_FETCH; + } else if (conn_type_in == "feeler") { + conn_type = ConnectionType::FEELER; } else { throw JSONRPCError(RPC_INVALID_PARAMETER, self.ToString()); } -- cgit v1.2.3 From eaf6be0114a6d7763767da9496907fe8a670ff9e Mon Sep 17 00:00:00 2001 From: John Newbery Date: Mon, 23 Aug 2021 10:44:41 +0100 Subject: [net processing] Do not request transaction relay from feeler connections Add a test to verify that feeler connections do not request transaction relay. --- src/net_processing.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/net_processing.cpp b/src/net_processing.cpp index 8be82f7ebc..bcc8bf1a2f 100644 --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -1096,7 +1096,7 @@ void PeerManagerImpl::PushNodeVersion(CNode& pnode, int64_t nTime) CService addr_you = addr.IsRoutable() && !IsProxy(addr) && addr.IsAddrV1Compatible() ? addr : CService(); uint64_t your_services{addr.nServices}; - const bool tx_relay = !m_ignore_incoming_txs && pnode.m_tx_relay != nullptr; + const bool tx_relay = !m_ignore_incoming_txs && pnode.m_tx_relay != nullptr && !pnode.IsFeelerConn(); m_connman.PushMessage(&pnode, CNetMsgMaker(INIT_PROTO_VERSION).Make(NetMsgType::VERSION, PROTOCOL_VERSION, my_services, nTime, your_services, addr_you, // Together the pre-version-31402 serialization of CAddress "addrYou" (without nTime) my_services, CService(), // Together the pre-version-31402 serialization of CAddress "addrMe" (without nTime) -- cgit v1.2.3