Skip to content

Topology manager requests duplicate connections to same peer instead of diversifying #1889

@sanity

Description

@sanity

Problem

The topology manager's adjust_topology() function requests duplicate connections to the same peer instead of diversifying across the ring. This prevents mesh topology formation and blocks peers from discovering each other.

Evidence

When running test_three_node_network_connectivity, the topology adjustment logs show:

INFO freenet::ring: Topology adjustment result, 
  adjustment: AddConnections([
    Location(0.9992056995279488), 
    Location(0.9992056995279488), 
    Location(0.9992056995279488),
    ... (repeated 25 times)
  ]), 
  current_connections: 1, 
  is_gateway: true

All three nodes exhibit this behavior:

  • Gateway requests 25 connections to Location(0.9992056995279488) (Peer1's location)
  • Peer1 requests 25 connections to Location(0.3107304382906112) (Gateway's location)
  • Peer2 requests 25 connections to Location(0.14832842390790457) (Gateway's location)

Each node is trying to create 25 duplicate connections to the single peer it's already connected to.

Expected Behavior

The topology manager should return a diverse set of locations spread across the ring to achieve optimal topology. For example, with min_connections=25 and only 3 nodes in the network, it should request connections to both of the other peers, not just one peer repeated 25 times.

Impact

  • Blocks mesh formation: Peers never establish peer-to-peer connections
  • Network remains in star topology: All traffic must route through gateway
  • Poor resilience: Single point of failure
  • Test failures: test_three_node_network_connectivity fails after 80+ seconds (40+ maintenance cycles)

Reproduction

cargo test --test connectivity test_three_node_network_connectivity 2>&1 | \
  grep -i "topology adjustment" | head -5

Investigation Needed

  1. Check TopologyManager::adjust_topology() logic in crates/core/src/topology/
  2. Verify how it selects target locations for new connections
  3. Ensure it avoids duplicates and spreads connections across the ring
  4. Consider whether it should account for existing connections when suggesting new ones

Related

[AI-assisted debugging and analysis]

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions