Replies: 1 comment 1 reply
-
Well since isssue 1 and 2 is already being implemented in #698 , moving on directly to issue 3 is it a good idea to have fallback mechanisms if scored selection fails, try simpler strategies like random selection from available relays. And for issue 4 , my rationale for choosing the simple A is because rust and go impls do not use them |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
TODO Analysis: Circuit v2 Relay Issues
Last review: August 2025
Overview
This document analyzes four TODO/FIXME issues in the circuit_v2 relay module:
Signature generation for production -✅ RESOLVEDlibp2p/relay/circuit_v2/resources.py:97
Voucher and signature verification -✅ RESOLVEDlibp2p/relay/circuit_v2/resources.py:193
libp2p/relay/circuit_v2/transport.py:222
❌ PENDINGlibp2p/relay/circuit_v2/transport.py:279
❌ PENDINGIssue 1: Signature Generation for Production ✅ RESOLVED
Issue Location
File:
libp2p/relay/circuit_v2/resources.py:97
Method:
to_proto()
Status: ✅ RESOLVED by PR #698
Resolution
PR #698 (link) implemented proper signature generation for production use. The implementation:
RELAY_VOUCHER_DOMAIN_SEP
for securityCurrent Implementation
Issue 2: Voucher and Signature Verification ✅ RESOLVED
Issue Location
File:
libp2p/relay/circuit_v2/resources.py:193
Method:
verify_reservation()
Status: ✅ RESOLVED by PR #698
Resolution
PR #698 (link) implemented comprehensive voucher and signature verification. The implementation:
Current Implementation
Issue 3: Sophisticated Relay Selection
Issue Location
File:
libp2p/relay/circuit_v2/transport.py:222
Method:
_select_relay()
TODO Comment:
# TODO: Implement more sophisticated relay selection
Current Status Analysis
Current Implementation
The
_select_relay()
method currently uses a simple "first available" strategy:The Problem
Cross-Implementation Analysis
Go Implementation Status
/p2p/host/autorelay/relay_finder.go:753-770
// TODO: better relay selection strategy; this just selects random relays, but we should probably use ping latency as the selection metric
JavaScript Implementation Status
/packages/transport-circuit-relay-v2/src/transport/discovery.ts
What Must Be Done
Required Changes
Implementation Options
Option A: Simple Round-Robin Selection (Recommended)
Option B: Reservation-Priority Selection
Option C: Future Enhancement - Ping-Based Selection
Impact Analysis
Recommendation
Start with Option A (Round-Robin) because:
Priority: LOW - This is an optimization issue, not a critical functionality problem. Both Go and JavaScript implementations also use simple selection strategies and have TODOs for future improvements.
Developer Feedback: The PR developer suggests implementing fallback mechanisms (e.g., random selection) if more sophisticated selection strategies fail, which aligns with the progressive enhancement approach.
Issue 4: Reservation Storage and Refresh Mechanism
Issue Location
File:
libp2p/relay/circuit_v2/transport.py:279
Method:
_make_reservation()
TODO Comment:
# TODO: Implement reservation storage and refresh mechanism
Current Status Analysis
Current Implementation
The
_make_reservation()
method currently doesn't store or manage reservations:The Problem
Cross-Implementation Analysis
Go Implementation Status
/p2p/host/autorelay/relay_finder.go
map[peer.ID]*circuitv2.Reservation
rsvpRefreshInterval = time.Minute
autorelayTag
errgroup.Group
JavaScript Implementation Status
/packages/transport-circuit-relay-v2/src/transport/reservation-store.ts
PeerMap<RelayEntry>
setTimeout
KEEP_ALIVE_TAG
What Must Be Done
Required Changes (Based on Spec and Other Implementations)
Implementation Options
Option A: Go-Style Implementation (Recommended)
Option B: JavaScript-Style Implementation
Option C: Hybrid Approach (Best of Both)
Impact Analysis
Recommendation
Start with Option A (Go-Style) because:
Priority: CRITICAL - This is a specification compliance issue. The Circuit Relay v2 spec explicitly requires reservation refresh, and current implementation violates this requirement. Both Go and JavaScript have fully implemented this feature.
Developer Note: The PR developer has confirmed that Go and Rust implementations do not use complex database storage, validating the simple in-memory approach.
Summary and Recommendations
Priority Order
✅ COMPLETED: Signature generation and verification (Issues 1 & 2)
🔴 CRITICAL: Reservation storage and refresh (Issue 4)
🟡 LOW: Sophisticated relay selection (Issue 3)
Implementation Strategy
Testing Requirements
Documentation Needs
Issue Comparison Summary
Cross-Implementation Analysis
Go libp2p Implementation
JavaScript libp2p Implementation
Python libp2p Implementation
Key Findings
Next Steps
Developer Feedback Summary
From PR #698 Developer (guha-rahul):
Key Insights:
Beta Was this translation helpful? Give feedback.
All reactions