maidsafe / safe_network

66 stars 40 forks source link

fix(networking): use default Relay config from libp2p #1894

Closed joshuef closed 1 month ago

joshuef commented 1 month ago

Reduce the relay config to default limits.

We were allowing nodes to handle thousands of relays (which they cannot)

let relay_server_cfg = relay::Config {
                max_reservations: 1024,      // the number of home nodes that we can support
                max_circuits: 32_000, // total max number of relayed connections we can support
                max_circuits_per_peer: 1024, // max number of relayed connections per peer
                ..Default::default()
            };

becomes effectively

let relay_server_cfg = relay::Config {
                max_reservations: 128,      // the number of home nodes that we can support
                max_circuits: 16, // total max number of relayed connections we can support
                max_circuits_per_peer: 4, // max number of relayed connections per peer
                ..Default::default()
            };

We could further tweak rate limiting via the config rate limiters if desired.


This pull request includes a change to the NetworkBuilder implementation in the sn_networking/src/driver.rs file. The change simplifies the creation of the relay_server_cfg object by using the default configuration provided by relay::Config::default(), instead of manually setting each configuration option. This change may affect the number of home nodes, total relayed connections, and relayed connections per peer that the relay server can support.