Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: limit wallet base node peer outbound connections #6307

Conversation

hansieodendaal
Copy link
Contributor

@hansieodendaal hansieodendaal commented Apr 24, 2024

Description

Added functionality to limit the number of base node peer connections that a wallet can have, based on a config setting. The furtherest nodes will be disconnected, but nodes on the allow list (e.g. connected base node) will be ignored. Request to a newly connected base node for SAF messages will also be limited to the closest connections only.

Motivation and Context

Wallets do not need to be as aggressive in establishing and keeping many connections compared to a base node.

How Has This Been Tested?

System-level testing on nextnet

Some results for a fresh wallet are below with using these settings:

[wallet.p2p.dht]
# The maximum number of peer nodes that a message has to be closer to, to be considered a neighbour. Default: 8
num_neighbouring_nodes = 5
# Number of random peers to include. Default: 4
num_random_nodes = 1
# Connections above the configured number of neighbouring nodes (minimum of 1) will be removed (default: false)
minimize_connections = true
# The interval to update the neighbouring and random pools, if necessary. Default: 2 minutes
connectivity.update_interval = 300 # 2 * 60
# The minimum desired ratio of TCPv4 to Tor connections. TCPv4 addresses have some significant cost to create,
# making sybil attacks costly. This setting does not guarantee this ratio is maintained.
# Currently, it only emits a warning if the ratio is below this setting. Default: 0.1 (10%)
connectivity.minimum_desired_tcpv4_node_ratio = 0.0
# A threshold for the minimum number of peers this node should ideally be aware of. If below this threshold a
# more "aggressive" strategy is employed. Default: 50
network_discovery.min_desired_peers = 16
2024-05-09 16:59:18.051376500 [comms::dht::connectivity] DEBUG minimize_connections: Filtered peers: 1, Handles: 1
2024-05-09 16:59:23.846098200 [comms::dht::connectivity] DEBUG minimize_connections: Filtered peers: 2, Handles: 2
2024-05-09 16:59:25.141738700 [comms::dht::connectivity] DEBUG minimize_connections: Filtered peers: 2, Handles: 2
2024-05-09 16:59:26.526939300 [comms::dht::connectivity] DEBUG minimize_connections: Filtered peers: 2, Handles: 2
2024-05-09 16:59:31.890309600 [comms::dht::connectivity] DEBUG minimize_connections: Filtered peers: 3, Handles: 3
2024-05-09 16:59:34.875531400 [comms::dht::connectivity] DEBUG minimize_connections: Filtered peers: 4, Handles: 4
2024-05-09 16:59:40.211479200 [comms::dht::connectivity] DEBUG minimize_connections: Filtered peers: 5, Handles: 5
2024-05-09 16:59:51.798007000 [comms::dht::connectivity] DEBUG minimize_connections: Filtered peers: 5, Handles: 5
2024-05-09 17:00:06.424634900 [comms::dht::connectivity] DEBUG minimize_connections: Filtered peers: 5, Handles: 5
2024-05-09 17:00:15.098731700 [comms::dht::connectivity] DEBUG minimize_connections: Filtered peers: 5, Handles: 5
2024-05-09 17:01:34.202148100 [comms::dht::connectivity] DEBUG minimize_connections: Filtered peers: 6, Handles: 6
2024-05-09 17:01:48.869645800 [comms::connectivity::manager] DEBUG minimize_connections: Filtered peers: 10, Handles: 11
2024-05-09 17:01:48.869650900 [comms::connectivity::manager] DEBUG minimize_connections: Disconnecting 'b93ca6de3f1cabbd3a40581224' because the node is not among the 6 closest peers
2024-05-09 17:01:48.869876100 [comms::connectivity::manager] DEBUG minimize_connections: Disconnecting 'b12bdf00bfb5d3c32c235fd2cb' because the node is not among the 6 closest peers
2024-05-09 17:01:48.870090800 [comms::connectivity::manager] DEBUG minimize_connections: Disconnecting '305cd9f487aa9e58f884f534c4' because the node is not among the 6 closest peers
2024-05-09 17:01:48.870431900 [comms::connectivity::manager] DEBUG minimize_connections: Disconnecting '54e1ea3aa6646c75f3247aeab1' because the node is not among the 6 closest peers
2024-05-09 17:04:48.868549100 [comms::connectivity::manager] DEBUG minimize_connections: Filtered peers: 6, Handles: 7
2024-05-09 17:07:48.870620800 [comms::connectivity::manager] DEBUG minimize_connections: Filtered peers: 6, Handles: 7
2024-05-09 17:10:48.883504000 [comms::connectivity::manager] DEBUG minimize_connections: Filtered peers: 6, Handles: 7
2024-05-09 17:13:48.885640800 [comms::connectivity::manager] DEBUG minimize_connections: Filtered peers: 6, Handles: 7
2024-05-09 17:16:48.895746200 [comms::connectivity::manager] DEBUG minimize_connections: Filtered peers: 6, Handles: 7
2024-05-09 17:19:48.909768500 [comms::connectivity::manager] DEBUG minimize_connections: Filtered peers: 6, Handles: 7
2024-05-09 17:20:13.246169600 [comms::dht::connectivity] DEBUG minimize_connections: Filtered peers: 6, Handles: 6
2024-05-09 17:22:48.910592100 [comms::connectivity::manager] DEBUG minimize_connections: Filtered peers: 7, Handles: 8
2024-05-09 17:22:48.910598000 [comms::connectivity::manager] DEBUG minimize_connections: Disconnecting 'e9f94287e9893c4934f89edce7' because the node is not among the 6 closest peers
2024-05-09 17:25:48.919283400 [comms::connectivity::manager] DEBUG minimize_connections: Filtered peers: 6, Handles: 7
2024-05-09 16:59:13.888003200 [comms::dht::connectivity] DEBUG DHT connectivity status: neighbour pool: 4/5 (0 connected), random pool: 1/1 (0 connected, last refreshed 900ns ago), active DHT connections: 0/6
2024-05-09 17:00:35.789826900 [comms::dht::connectivity] DEBUG DHT connectivity status: neighbour pool: 5/5 (4 connected), random pool: 1/1 (0 connected, last refreshed 78s ago), active DHT connections: 5/6
2024-05-09 17:00:35.789851700 [comms::dht::connectivity] DEBUG DHT connectivity status: neighbour pool: 5/5 (4 connected), random pool: 1/1 (0 connected, last refreshed 78s ago), active DHT connections: 5/6
2024-05-09 17:02:42.134128800 [comms::dht::connectivity] DEBUG DHT connectivity status: neighbour pool: 5/5 (0 connected), random pool: 1/1 (0 connected, last refreshed 59s ago), active DHT connections: 6/6
2024-05-09 17:02:42.134163900 [comms::dht::connectivity] DEBUG DHT connectivity status: neighbour pool: 5/5 (0 connected), random pool: 1/1 (0 connected, last refreshed 59s ago), active DHT connections: 6/6
2024-05-09 17:03:11.289312400 [comms::dht::connectivity] DEBUG DHT connectivity status: neighbour pool: 5/5 (0 connected), random pool: 1/1 (0 connected, last refreshed 88s ago), active DHT connections: 6/6
2024-05-09 17:03:11.289348400 [comms::dht::connectivity] DEBUG DHT connectivity status: neighbour pool: 5/5 (0 connected), random pool: 1/1 (0 connected, last refreshed 88s ago), active DHT connections: 6/6
2024-05-09 17:03:15.884240000 [comms::dht::connectivity] DEBUG DHT connectivity status: neighbour pool: 5/5 (0 connected), random pool: 1/1 (1 connected, last refreshed 93s ago), active DHT connections: 6/6
2024-05-09 17:03:15.884288100 [comms::dht::connectivity] DEBUG DHT connectivity status: neighbour pool: 5/5 (0 connected), random pool: 1/1 (1 connected, last refreshed 93s ago), active DHT connections: 6/6
2024-05-09 17:03:17.350056500 [comms::dht::connectivity] DEBUG DHT connectivity status: neighbour pool: 5/5 (0 connected), random pool: 1/1 (1 connected, last refreshed 94s ago), active DHT connections: 6/6
2024-05-09 17:03:17.350087200 [comms::dht::connectivity] DEBUG DHT connectivity status: neighbour pool: 5/5 (0 connected), random pool: 1/1 (1 connected, last refreshed 94s ago), active DHT connections: 6/6
2024-05-09 17:03:21.324948500 [comms::dht::connectivity] DEBUG DHT connectivity status: neighbour pool: 5/5 (0 connected), random pool: 1/1 (1 connected, last refreshed 98s ago), active DHT connections: 6/6
2024-05-09 17:03:21.324980600 [comms::dht::connectivity] DEBUG DHT connectivity status: neighbour pool: 5/5 (0 connected), random pool: 1/1 (1 connected, last refreshed 98s ago), active DHT connections: 6/6
2024-05-09 17:03:36.180570200 [comms::dht::connectivity] DEBUG DHT connectivity status: neighbour pool: 5/5 (0 connected), random pool: 1/1 (1 connected, last refreshed 113s ago), active DHT connections: 6/6
2024-05-09 17:03:36.180604500 [comms::dht::connectivity] DEBUG DHT connectivity status: neighbour pool: 5/5 (0 connected), random pool: 1/1 (1 connected, last refreshed 113s ago), active DHT connections: 6/6
2024-05-09 17:03:47.654100000 [comms::dht::connectivity] DEBUG DHT connectivity status: neighbour pool: 4/5 (0 connected), random pool: 1/1 (1 connected, last refreshed 124s ago), active DHT connections: 6/6
2024-05-09 17:03:47.654120200 [comms::dht::connectivity] DEBUG DHT connectivity status: neighbour pool: 4/5 (0 connected), random pool: 1/1 (1 connected, last refreshed 124s ago), active DHT connections: 6/6
2024-05-09 17:04:13.887169600 [comms::dht::connectivity] DEBUG DHT connectivity status: neighbour pool: 4/5 (0 connected), random pool: 1/1 (1 connected, last refreshed 151s ago), active DHT connections: 6/6
2024-05-09 17:04:14.062651100 [comms::dht::connectivity] DEBUG DHT connectivity status: neighbour pool: 3/5 (0 connected), random pool: 1/1 (1 connected, last refreshed 151s ago), active DHT connections: 6/6
2024-05-09 17:04:14.062669400 [comms::dht::connectivity] DEBUG DHT connectivity status: neighbour pool: 3/5 (0 connected), random pool: 1/1 (1 connected, last refreshed 151s ago), active DHT connections: 6/6
2024-05-09 17:04:17.893635900 [comms::dht::connectivity] DEBUG DHT connectivity status: neighbour pool: 2/5 (0 connected), random pool: 1/1 (1 connected, last refreshed 155s ago), active DHT connections: 6/6
2024-05-09 17:04:17.893652200 [comms::dht::connectivity] DEBUG DHT connectivity status: neighbour pool: 2/5 (0 connected), random pool: 1/1 (1 connected, last refreshed 155s ago), active DHT connections: 6/6
2024-05-09 17:04:59.589188600 [comms::dht::connectivity] DEBUG DHT connectivity status: neighbour pool: 1/5 (0 connected), random pool: 1/1 (1 connected, last refreshed 196s ago), active DHT connections: 6/6
2024-05-09 17:04:59.589202800 [comms::dht::connectivity] DEBUG DHT connectivity status: neighbour pool: 1/5 (0 connected), random pool: 1/1 (1 connected, last refreshed 196s ago), active DHT connections: 6/6
2024-05-09 17:05:00.693970600 [comms::dht::connectivity] DEBUG DHT connectivity status: neighbour pool: 0/5 (0 connected), random pool: 1/1 (1 connected, last refreshed 197s ago), active DHT connections: 6/6
2024-05-09 17:05:00.693978600 [comms::dht::connectivity] DEBUG DHT connectivity status: neighbour pool: 0/5 (0 connected), random pool: 1/1 (1 connected, last refreshed 197s ago), active DHT connections: 6/6
2024-05-09 17:09:13.888616000 [comms::dht::connectivity] DEBUG DHT connectivity status: neighbour pool: 0/5 (0 connected), random pool: 1/1 (1 connected, last refreshed 451s ago), active DHT connections: 6/6
2024-05-09 17:14:13.888027100 [comms::dht::connectivity] DEBUG DHT connectivity status: neighbour pool: 0/5 (0 connected), random pool: 1/1 (1 connected, last refreshed 751s ago), active DHT connections: 6/6
2024-05-09 17:19:13.887787200 [comms::dht::connectivity] DEBUG DHT connectivity status: neighbour pool: 0/5 (0 connected), random pool: 1/1 (1 connected, last refreshed 1051s ago), active DHT connections: 6/6
2024-05-09 17:24:13.885459600 [comms::dht::connectivity] DEBUG DHT connectivity status: neighbour pool: 0/5 (0 connected), random pool: 1/1 (1 connected, last refreshed 1351s ago), active DHT connections: 6/6

In contrast to the wallet, these results for a fresh base node during the same period:

2024-05-09 16:58:48.018109100 [comms::dht::connectivity] DEBUG DHT connectivity status: neighbour pool: 8/8 (0 connected), random pool: 4/4 (0 connected, last refreshed 11µs ago), active DHT connections: 0/12
2024-05-09 17:00:06.125021800 [comms::dht::connectivity] DEBUG DHT connectivity status: neighbour pool: 8/8 (7 connected), random pool: 4/4 (3 connected, last refreshed 65s ago), active DHT connections: 11/12
2024-05-09 17:00:06.125044000 [comms::dht::connectivity] DEBUG DHT connectivity status: neighbour pool: 8/8 (7 connected), random pool: 4/4 (3 connected, last refreshed 65s ago), active DHT connections: 11/12
2024-05-09 17:00:35.062813300 [comms::dht::connectivity] DEBUG DHT connectivity status: neighbour pool: 8/8 (0 connected), random pool: 4/4 (1 connected, last refreshed 10s ago), active DHT connections: 10/12
2024-05-09 17:00:35.062849200 [comms::dht::connectivity] DEBUG DHT connectivity status: neighbour pool: 8/8 (0 connected), random pool: 4/4 (1 connected, last refreshed 10s ago), active DHT connections: 10/12
2024-05-09 17:00:38.762475500 [comms::dht::connectivity] DEBUG DHT connectivity status: neighbour pool: 8/8 (0 connected), random pool: 4/4 (1 connected, last refreshed 14s ago), active DHT connections: 10/12
2024-05-09 17:00:38.762518300 [comms::dht::connectivity] DEBUG DHT connectivity status: neighbour pool: 8/8 (0 connected), random pool: 4/4 (1 connected, last refreshed 14s ago), active DHT connections: 10/12
2024-05-09 17:00:48.026914700 [comms::dht::connectivity] DEBUG DHT connectivity status: neighbour pool: 8/8 (0 connected), random pool: 4/4 (1 connected, last refreshed 23s ago), active DHT connections: 12/12
2024-05-09 17:01:26.772288600 [comms::dht::connectivity] DEBUG DHT connectivity status: neighbour pool: 8/8 (2 connected), random pool: 4/4 (4 connected, last refreshed 62s ago), active DHT connections: 17/12
2024-05-09 17:01:26.772317900 [comms::dht::connectivity] DEBUG DHT connectivity status: neighbour pool: 8/8 (2 connected), random pool: 4/4 (4 connected, last refreshed 62s ago), active DHT connections: 17/12
2024-05-09 17:02:48.023292100 [comms::dht::connectivity] DEBUG DHT connectivity status: neighbour pool: 8/8 (0 connected), random pool: 4/4 (4 connected, last refreshed 143s ago), active DHT connections: 18/12
2024-05-09 17:04:48.025758700 [comms::dht::connectivity] DEBUG DHT connectivity status: neighbour pool: 8/8 (0 connected), random pool: 4/4 (4 connected, last refreshed 263s ago), active DHT connections: 18/12
2024-05-09 17:06:48.023565000 [comms::dht::connectivity] DEBUG DHT connectivity status: neighbour pool: 8/8 (0 connected), random pool: 4/4 (4 connected, last refreshed 383s ago), active DHT connections: 18/12
2024-05-09 17:08:48.023885600 [comms::dht::connectivity] DEBUG DHT connectivity status: neighbour pool: 8/8 (0 connected), random pool: 4/4 (4 connected, last refreshed 503s ago), active DHT connections: 18/12
2024-05-09 17:10:48.026087000 [comms::dht::connectivity] DEBUG DHT connectivity status: neighbour pool: 8/8 (0 connected), random pool: 4/4 (4 connected, last refreshed 623s ago), active DHT connections: 18/12
2024-05-09 17:12:48.025937800 [comms::dht::connectivity] DEBUG DHT connectivity status: neighbour pool: 8/8 (0 connected), random pool: 4/4 (4 connected, last refreshed 743s ago), active DHT connections: 18/12
2024-05-09 17:14:48.022341700 [comms::dht::connectivity] DEBUG DHT connectivity status: neighbour pool: 8/8 (0 connected), random pool: 4/4 (3 connected, last refreshed 863s ago), active DHT connections: 19/12
2024-05-09 17:16:48.016408600 [comms::dht::connectivity] DEBUG DHT connectivity status: neighbour pool: 8/8 (0 connected), random pool: 4/4 (3 connected, last refreshed 983s ago), active DHT connections: 19/12
2024-05-09 17:18:48.021984800 [comms::dht::connectivity] DEBUG DHT connectivity status: neighbour pool: 8/8 (0 connected), random pool: 4/4 (3 connected, last refreshed 1103s ago), active DHT connections: 19/12
2024-05-09 17:20:48.018004600 [comms::dht::connectivity] DEBUG DHT connectivity status: neighbour pool: 8/8 (0 connected), random pool: 4/4 (3 connected, last refreshed 1223s ago), active DHT connections: 20/12
2024-05-09 17:20:52.757274600 [comms::dht::connectivity] DEBUG DHT connectivity status: neighbour pool: 8/8 (0 connected), random pool: 4/4 (3 connected, last refreshed 1228s ago), active DHT connections: 20/12
2024-05-09 17:20:52.757311800 [comms::dht::connectivity] DEBUG DHT connectivity status: neighbour pool: 8/8 (0 connected), random pool: 4/4 (3 connected, last refreshed 1228s ago), active DHT connections: 20/12
2024-05-09 17:22:48.022367900 [comms::dht::connectivity] DEBUG DHT connectivity status: neighbour pool: 8/8 (0 connected), random pool: 4/4 (3 connected, last refreshed 1343s ago), active DHT connections: 21/12
2024-05-09 17:24:48.026643700 [comms::dht::connectivity] DEBUG DHT connectivity status: neighbour pool: 8/8 (0 connected), random pool: 4/4 (3 connected, last refreshed 1463s ago), active DHT connections: 22/12
2024-05-09 17:26:48.025649400 [comms::dht::connectivity] DEBUG DHT connectivity status: neighbour pool: 8/8 (0 connected), random pool: 4/4 (3 connected, last refreshed 1583s ago), active DHT connections: 22/12
2024-05-09 17:28:48.015161100 [comms::dht::connectivity] DEBUG DHT connectivity status: neighbour pool: 8/8 (0 connected), random pool: 4/4 (3 connected, last refreshed 1703s ago), active DHT connections: 22/12

What process can a PR reviewer use to test or verify this change?

  • Code review
  • System-level testing on nextnet

Breaking Changes

  • None
  • Requires data directory on base node to be deleted
  • Requires hard fork
  • Other - Please specify

@hansieodendaal hansieodendaal requested a review from a team as a code owner April 24, 2024 15:48
Copy link

github-actions bot commented Apr 24, 2024

Test Results (CI)

    3 files    113 suites   36m 3s ⏱️
1 277 tests 1 276 ✅ 0 💤 1 ❌
3 710 runs  3 709 ✅ 0 💤 1 ❌

For more details on these failures, see this check.

Results for commit 9bdb87a.

♻️ This comment has been updated with latest results.

@ghpbot-tari-project ghpbot-tari-project added P-acks_required Process - Requires more ACKs or utACKs P-reviews_required Process - Requires a review from a lead maintainer to be merged labels Apr 24, 2024
Copy link

github-actions bot commented Apr 24, 2024

Test Results (Integration tests)

33 tests  +33   33 ✅ +33   13m 46s ⏱️ + 13m 46s
11 suites +11    0 💤 ± 0 
 2 files   + 2    0 ❌ ± 0 

Results for commit 9bdb87a. ± Comparison against base commit ae63bab.

♻️ This comment has been updated with latest results.

@hansieodendaal hansieodendaal force-pushed the ho_limit_wallet_peer_connections branch 2 times, most recently from b60fd69 to 60debf2 Compare April 25, 2024 00:31
@hansieodendaal hansieodendaal marked this pull request as draft April 25, 2024 01:48
@hansieodendaal hansieodendaal force-pushed the ho_limit_wallet_peer_connections branch 3 times, most recently from 809ac8c to fcf0fd8 Compare May 3, 2024 06:13
@hansieodendaal hansieodendaal force-pushed the ho_limit_wallet_peer_connections branch from fcf0fd8 to 7a599d6 Compare May 7, 2024 15:26
@hansieodendaal hansieodendaal marked this pull request as ready for review May 7, 2024 15:26
@hansieodendaal hansieodendaal force-pushed the ho_limit_wallet_peer_connections branch from 7a599d6 to 39604cc Compare May 7, 2024 15:45
@hansieodendaal hansieodendaal marked this pull request as draft May 8, 2024 07:17
@hansieodendaal hansieodendaal force-pushed the ho_limit_wallet_peer_connections branch 4 times, most recently from 13c7cc6 to de151bf Compare May 8, 2024 16:52
@hansieodendaal hansieodendaal marked this pull request as ready for review May 8, 2024 16:52
@hansieodendaal hansieodendaal marked this pull request as draft May 9, 2024 04:58
@hansieodendaal hansieodendaal force-pushed the ho_limit_wallet_peer_connections branch from de151bf to a1059b7 Compare May 9, 2024 05:18
Added functionality to limit the number of base node peer connections that a wallet
can have, based on a config setting. The furtherest nodes will be disconnected, but
nodes on the allow list (e.g. connected base node) will be ignored.
@hansieodendaal hansieodendaal force-pushed the ho_limit_wallet_peer_connections branch from a1059b7 to 0b94bcb Compare May 9, 2024 15:24
@hansieodendaal hansieodendaal marked this pull request as ready for review May 9, 2024 15:31
sdbondi
sdbondi previously approved these changes May 10, 2024
Copy link
Member

@sdbondi sdbondi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just need to remove assert!s (should never actually panic anyway) otherwise utACK

I think disconnect reasons would be a great addition, Minimize has a less clear intention. From what I understand "Connection minimisation mode" is like a hard limit on connections (inbound or outbound) to nodes which should only be enabled for the wallet. This seems like it addresses a symptom of a bug that causes a higher amount of connections than desired (should be neighbour pool size + random pool size + a few extra nodes that have connected to you in the base node case N/A for wallet). This method will lead to a number of connects and then disconnects (question: Does this settle down after a while?).

Ideally, we should address this bug so that the connections are not made to begin with, or non-neighbours are disconnected after network discovery. But this does address an issue directly so happy for this to go in (not tested). Well done!

Comment on lines +69 to +73
#[derive(Debug, Clone, Copy, Eq, PartialEq)]
pub enum Minimized {
Yes,
No,
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It appears that this is only used to improve logs.

Not necessary for now but I'd suggest making this a general reason enum (you can use thiserror for the human readable text or impl Display)

Suggested change
#[derive(Debug, Clone, Copy, Eq, PartialEq)]
pub enum Minimized {
Yes,
No,
}
#[derive(Debug, Clone, Copy, thiserror::Error)]
pub enum DisconnectReason {
#[error("Remote disconnected")]
RemoteDisconnected,
#[error("Connection was culled because it was inactive")]
ConnectionCulledInactive,
#[error("Connection was culled to reduce number of connections")]
ConnectionCulledMinimise
#[error("Local node explicit disconnect")]
LocalDisconnected
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Issue created for this: #6331

comms/dht/src/store_forward/service.rs Outdated Show resolved Hide resolved
comms/core/src/test_utils/mocks/connection_manager.rs Outdated Show resolved Hide resolved
comms/core/src/connectivity/connection_pool.rs Outdated Show resolved Hide resolved
comms/core/src/connectivity/manager.rs Outdated Show resolved Hide resolved
@ghpbot-tari-project ghpbot-tari-project removed P-reviews_required Process - Requires a review from a lead maintainer to be merged labels May 10, 2024
@ghpbot-tari-project ghpbot-tari-project added the P-reviews_required Process - Requires a review from a lead maintainer to be merged label May 10, 2024
@hansieodendaal
Copy link
Contributor Author

This seems like it addresses a symptom of a bug that causes a higher amount of connections than desired (should be neighbour pool size + random pool size + a few extra nodes that have connected to you in the base node case N/A for wallet). This method will lead to a number of connects and then disconnects (question: Does this settle down after a while?).

Ideally, we should address this bug so that the connections are not made to begin with, or non-neighbours are disconnected after network discovery. But this does address an issue directly so happy for this to go in (not tested). Well done!

Yes, with these changes we see a couple of connects and disconnects, but all race conditions have been taken care of, especially between the dht service, saf service and connectivity service. When the communication node peer quota have been reached, each new outbound connection due to network discovery, dht or user selection will be weighed up against the actual number of connections and distances. For saf, requesting saf messages are only allowed for the peer quota if the new connection is an actual neighbour.

When I worked on this PR, and with the many system-level tests I have been doing, I thought some of the things implemented here should be the normal way for base nodes as well. As you observed, currently the base nodes will just connect to every other base node that is out there.

@ghpbot-tari-project ghpbot-tari-project removed the P-reviews_required Process - Requires a review from a lead maintainer to be merged label May 10, 2024
@SWvheerden SWvheerden merged commit 79fcd03 into tari-project:development May 10, 2024
13 of 16 checks passed
@hansieodendaal hansieodendaal deleted the ho_limit_wallet_peer_connections branch May 10, 2024 09:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P-acks_required Process - Requires more ACKs or utACKs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants