Replies: 1 comment
-
How to Run Circuit Relay v2 Test with Log Analysis🚀 Quick Start# 1. Navigate to project directory
cd py-libp2p
# 2. Activate virtual environment
source venv/bin/activate
# 3. Run the test with timeout
timeout 50 ./libp2p/relay/circuit_v2/test_relay_example_parallel_debug.sh📋 What the Test DoesThe script automatically:
📊 Log Files Generated
🔍 Key Log Checks✅ Success Indicators:# Check for successful connection
grep "Successfully connected to destination through relay" source_output.log
# Check for echo protocol handler
grep "🎯 DESTINATION ECHO HANDLER CALLED" dest_output.log
# Check for message exchange
grep "📤 SOURCE SENT APPLICATION MESSAGE" source_output.log
grep "🎯 SOURCE RECEIVED ECHO RESPONSE" source_output.log❌ Error Indicators:# Check for connection errors
grep -i "error\|exception\|failed" source_output.log
# Check for protocol negotiation failures
grep "MultiselectClientError" source_output.log
# Check for stream creation issues
grep "set_state" source_output.log🎯 Expected Results✅ Working Circuit Relay v2:
❌ Current Issues:
🔧 TroubleshootingIf Test Times Out:# Check relay logs
tail -20 relay_output.log
# Check destination logs
tail -20 dest_output.log
# Check source logs
tail -20 source_output.logIf Context Error:# Should be fixed now - check for:
grep "unexpected keyword argument 'context'" source_output.logIf Stream Routing Fails:# Look for these patterns:
grep "🎯 DESTINATION ECHO HANDLER CALLED" dest_output.log # Should appear
grep "Successfully routed Circuit Relay v2 stream" relay_output.log # Should appear📈 Test Output AnalysisThe script provides colored output:
🎯 Current Status✅ Circuit Relay v2 connection established The test is working correctly and shows the fundamental stream routing issue that needs to be resolved in the Circuit Relay v2 implementation. |
Beta Was this translation helpful? Give feedback.
0 replies
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.
-
Circuit Relay v2 Implementation Analysis
Date: Oct 16th 2025
Overview
This document analyzes the current state of Circuit Relay v2 implementation in py-libp2p, focusing on the changes made in the recent commits and the current functionality.
Current Implementation Status
⭐ Features Added After Commit d60dac6
The following features were NOT present in commit d60dac601a4006ad9a0a73aefbfe5325e2811162 and were added in subsequent work:
Network Context Support (
libp2p/network/context.py) - NEW FILEwith_allow_limited_conn()functionget_allow_limited_conn()functionSwarm Connection Limited Support (
libp2p/network/connection/swarm_connection.py)limitedproperty added toSwarmConnclassSwarm Limited Connection Handling (
libp2p/network/swarm.py)new_stream()Circuit Relay v2 Transport Integration (
libp2p/network/swarm.py)limited=TrueHost Context Support (
libp2p/host/basic_host.py)new_stream()methodEnhanced Example Usage (
examples/circuit_relay/relay_example.py)WithAllowLimitedConnequivalent implementationTransport Registry Integration (
libp2p/transport/transport_registry.py)/p2p-circuitprotocolKey Components
1. Circuit Relay v2 Protocol (
libp2p/relay/circuit_v2/protocol.py)The Circuit Relay v2 protocol implementation handles the core relay functionality:
2. Network Context Support (
libp2p/network/context.py) ⭐ NEW FEATURENote: This file was not present in commit d60dac601a4006ad9a0a73aefbfe5325e2811162 and was added in subsequent work.
Added support for limited connections, equivalent to Go's
WithAllowLimitedConn:3. Swarm Connection Limited Support (
libp2p/network/connection/swarm_connection.py) ⭐ ENHANCED FEATURENote: The
limitedproperty and related functionality was not present in commit d60dac601a4006ad9a0a73aefbfe5325e2811162 and was added in subsequent work.Added support for marking connections as limited:
4. Swarm Limited Connection Handling (
libp2p/network/swarm.py) ⭐ ENHANCED FEATURENote: The limited connection handling logic was not present in commit d60dac601a4006ad9a0a73aefbfe5325e2811162 and was added in subsequent work.
Modified the swarm to handle limited connections:
5. Circuit Relay v2 Transport Integration (
libp2p/network/swarm.py) ⭐ ENHANCED FEATURENote: The Circuit Relay v2 connection marking as limited was not present in commit d60dac601a4006ad9a0a73aefbfe5325e2811162 and was added in subsequent work.
Circuit Relay v2 connections are marked as limited:
6. Host Context Support (
libp2p/host/basic_host.py) ⭐ ENHANCED FEATURENote: The context parameter support was not present in commit d60dac601a4006ad9a0a73aefbfe5325e2811162 and was added in subsequent work.
Added context parameter to host's new_stream method:
7. Transport Registry Integration (
libp2p/transport/transport_registry.py) ⭐ NEW FEATURENote: Circuit Relay v2 transport registration was not present in commit d60dac601a4006ad9a0a73aefbfe5325e2811162 and was added in subsequent work.
Added Circuit Relay v2 transport support to the transport registry:
Circuit Relay v2 multiaddr handling:
8. Example Usage (
examples/circuit_relay/relay_example.py) ⭐ ENHANCED FEATURENote: The context system usage in the example was not present in commit d60dac601a4006ad9a0a73aefbfe5325e2811162 and was added in subsequent work.
Updated the example to use the new context system:
Current Limitations
1. Raw Data Relaying Only
The current implementation only supports raw data relaying between a single source stream and a single destination stream:
2. No Multi-Stream Support
The Circuit Relay v2 implementation doesn't support multiple streams over a single connection, which is required for proper protocol negotiation.
3. Protocol Negotiation Issues
When the source tries to perform protocol negotiation over the Circuit Relay v2 connection, the destination never receives the protocol negotiation requests because the relay only forwards raw bytes.
Test Results
The current implementation shows the following behavior:
Circuit Relay v2 Connection Establishment: ✅ Working
Protocol Negotiation: ❌ Failing
MultiselectClientError: response timed out)Echo Protocol: ❌ Not Working
Conclusion
The current Circuit Relay v2 implementation provides basic connection establishment and data relaying, but lacks the multi-stream support required for proper protocol negotiation. The implementation needs significant architectural changes to support multiple streams over Circuit Relay v2 connections, similar to the Go implementation.
Beta Was this translation helpful? Give feedback.
All reactions