Accepted
P2P networking requires robust transport infrastructure including:
- Connection management: Establishing, maintaining, and pooling connections
- NAT traversal: Hole punching, STUN/TURN for peers behind NAT
- Protocol negotiation: Version handshakes, capability exchange
- Bootstrap discovery: Finding initial peers to join the network
- Cryptographic transport: TLS 1.3 or equivalent security
Building these from scratch would require:
- Years of development and hardening
- Ongoing maintenance for protocol evolution
- Extensive testing across diverse network conditions
- Security audits for cryptographic implementations
The MaidSafe ecosystem has developed saorsa-transport, a battle-tested QUIC implementation with:
- Native NAT traversal (path validation, hole punching)
- Post-quantum cryptography integration
- Bootstrap cache management
- Connection pooling and multiplexing
We delegate all transport-layer concerns to saorsa-transport, treating it as our transport foundation. Saorsa-core focuses on higher-level P2P semantics while saorsa-transport handles:
┌──────────────────────────────────────────────────────────────────┐
│ saorsa-core │
│ ┌──────────────────────────────────────────────────────────────┐│
│ │ • DHT routing & replication ││
│ │ • Identity & presence management ││
│ │ • Trust computation (EigenTrust) ││
│ │ • Storage placement & orchestration ││
│ │ • Upper-layer applications (saorsa-node) ││
│ └──────────────────────────────────────────────────────────────┘│
│ │ │
│ ▼ │
│ ┌──────────────────────────────────────────────────────────────┐│
│ │ Thin Adapter Layer ││
│ │ • AntQuicAdapter (src/transport/saorsa_transport_adapter.rs) ││
│ │ • BootstrapManager wrapper (src/bootstrap/manager.rs) ││
│ │ • Connection event translation ││
│ └──────────────────────────────────────────────────────────────┘│
└──────────────────────────────────────────────────────────────────┘
│
▼
┌──────────────────────────────────────────────────────────────────┐
│ saorsa-transport │
│ ┌────────────────┐ ┌────────────────┐ ┌────────────────────┐ │
│ │ QUIC Streams │ │ NAT Traversal │ │ Bootstrap Cache │ │
│ │ • Bidirectional│ │ • Path Valid. │ │ • Peer discovery │ │
│ │ • Multiplexed │ │ • Hole punching│ │ • Quality metrics │ │
│ │ • Flow control │ │ • Relay support│ │ • Contact merging │ │
│ └────────────────┘ └────────────────┘ └────────────────────┘ │
│ ┌────────────────┐ ┌────────────────┐ ┌────────────────────┐ │
│ │ Connection Pool│ │ TLS 1.3 + PQC │ │ Endpoint Mgmt │ │
│ │ • LRU eviction │ │ • ML-KEM-768 │ │ • Multi-listener │ │
│ │ • Health checks│ │ • X25519 hybrid│ │ • Port selection │ │
│ └────────────────┘ └────────────────┘ └────────────────────┘ │
└──────────────────────────────────────────────────────────────────┘
The adapter layer translates between saorsa-core abstractions and saorsa-transport primitives:
// src/transport/saorsa_transport_adapter.rs
pub struct AntQuicAdapter {
endpoint: Endpoint,
connections: ConnectionPool,
event_tx: broadcast::Sender<ConnectionEvent>,
}
impl AntQuicAdapter {
/// Connect to a peer, handling NAT traversal automatically
pub async fn connect(&self, addr: SocketAddr) -> Result<Connection> {
// saorsa-transport handles:
// - Path validation for NAT traversal
// - TLS handshake with PQC
// - Connection pooling
self.endpoint.connect(addr).await
}
/// Send message to peer
pub async fn send(&self, peer: &PeerId, msg: &[u8]) -> Result<()> {
let conn = self.get_or_connect(peer).await?;
let mut stream = conn.open_uni().await?;
stream.write_all(msg).await?;
Ok(())
}
}The BootstrapManager wraps saorsa-transport's cache while adding Sybil protection:
// src/bootstrap/manager.rs
pub struct BootstrapManager {
cache: Arc<AntBootstrapCache>, // Delegated to saorsa-transport
rate_limiter: JoinRateLimiter, // Saorsa Sybil protection
diversity_enforcer: IPDiversityEnforcer, // Saorsa Sybil protection
}
impl BootstrapManager {
/// Add contact with Sybil protection
pub async fn add_contact(&self, addr: SocketAddr) -> Result<()> {
// Saorsa-specific protection
self.rate_limiter.check_rate(addr.ip())?;
self.diversity_enforcer.check_diversity(addr.ip())?;
// Delegate storage to saorsa-transport
self.cache.add_contact(addr.into()).await
}
}We track saorsa-transport versions explicitly and test against specific releases:
| saorsa-core | saorsa-transport | Features |
|---|---|---|
| 0.11.x | 0.21.x | Full PQC, placement system, threshold crypto |
| 0.10.x | 0.20.x | Full PQC, unified config |
| 0.5.x | 0.14.x | Unified config, PQC integration |
| 0.3.x | 0.10.x | Basic QUIC, NAT traversal |
- Reduced maintenance: Transport bugs fixed upstream benefit us automatically
- Battle-tested code: saorsa-transport is used in production MaidSafe networks
- NAT traversal: Complex hole-punching logic provided out-of-box
- PQC integration: Post-quantum TLS without cryptographic expertise
- Focus: We concentrate on P2P semantics, not transport mechanics
- Performance: Optimized QUIC implementation with connection pooling
- Version coupling: saorsa-transport upgrades may require adapter changes
- Feature constraints: Limited to saorsa-transport's capabilities
- Debugging complexity: Transport issues require saorsa-transport knowledge
- Build dependency: Larger dependency tree
- API stability: saorsa-transport follows semver; breaking changes are versioned
- Testing: Integration tests must use real saorsa-transport (no mocks for transport)
Implement QUIC from scratch using quinn as a base.
Rejected because:
- 12-18 months additional development
- Ongoing maintenance burden
- NAT traversal is particularly complex
- Security risk from custom crypto
Adopt libp2p's transport abstractions.
Rejected because:
- Heavy dependency with many transitive crates
- Rust implementation less mature than Go version
- Different design philosophy (more opinionated)
- No native PQC support
Fall back to TCP for simplicity.
Rejected because:
- No multiplexing without additional protocol
- NAT traversal much harder (no hole punching)
- Higher latency for small messages
- Missing flow control primitives
Use WebRTC for browser compatibility.
Rejected because:
- Complex signaling requirements
- Higher overhead for server-to-server
- Less suitable for persistent connections
- We use saorsa-webrtc separately for browser peers
When upgrading saorsa-transport versions:
- Review saorsa-transport CHANGELOG for breaking changes
- Update adapter layer for API changes
- Test NAT traversal scenarios
- Verify bootstrap cache compatibility
- Run full integration test suite