You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This document provides a comprehensive overview of the Python libp2p ping implementation for transport-interop testing, consolidating information from all documentation files.
To add new protocols to Python, you would need to:
Update versionsInput.json: Add new protocols to the Python configuration
Update ping_test.py: Add validation and implementation for new protocols
Test Compatibility: Ensure new protocols work with the py-libp2p library
The protocol list is intentionally limited in Python compared to other implementations, likely due to the current capabilities of the py-libp2p library.
cd transport-interop
npm install
npm test -- --help
Test Python Implementation
# Test Python alone (will fail if no other implementations available)
npm test -- --name-filter="python-v0.2.9"# Test against specific implementation
npm test -- --name-filter="python-v0.2.9 x js-v1.x"# Test bidirectional
npm test -- --name-filter="python-v0.2.9 x js-v1.x|js-v1.x x python-v0.2.9"
Cross-Implementation Testing
# Test Python as dialer vs other listeners
npm test -- --name-filter="python-v0.2.9 x js-v1.x|python-v0.2.9 x rust-v0.53|python-v0.2.9 x go-v0.42"# Test Python as listener vs other dialers
npm test -- --name-filter="js-v1.x x python-v0.2.9|rust-v0.53 x python-v0.2.9|go-v0.42 x python-v0.2.9"
Cross-Implementation Testing
Python vs JS-libp2p
# Build both imagescd transport-interop/impl/python/v0.2 && make image.json
cd transport-interop/impl/js/v2.x && make image.json
# Test Python Dialer → JS Listener
docker run --rm --network host \
-e transport=tcp -e muxer=yamux -e security=noise \
-e is_dialer=false -e test_timeout_secs=15 \
-e redis_addr=localhost:6379 node-js-v2.x
docker run --rm --network host \
-e transport=tcp -e muxer=yamux -e security=noise \
-e is_dialer=true -e redis_addr=localhost:6379 \
-e test_timeout_seconds=15 python-v0.2.9 python ping_test.py
Supported Combinations
Transport
Security
Muxer
Python
JS-libp2p
Status
TCP
Noise
Yamux
✅
✅
✅
TCP
Noise
Mplex
✅
✅
✅
TCP
Plaintext
Yamux
✅
✅
✅
TCP
Plaintext
Mplex
✅
✅
✅
Configuration
Environment Variables
Python Implementation
-e transport=tcp # Transport protocol
-e muxer=yamux|mplex # Multiplexer
-e security=noise|plaintext # Security protocol
-e is_dialer=true|false # Role (dialer/listener)
-e ip="0.0.0.0"# Listen IP (listener only)
-e redis_addr=localhost:6379 # Redis server address
-e test_timeout_seconds=15 # Test timeout in seconds
Automated Testing
export TIMEOUT=600 # Test timeout (seconds)export WORKER_COUNT=4 # Worker count for parallel executionexport VERBOSE=true # Enable verbose logging
Makefile Targets
make all # Build with cache (fast)
make force-rebuild # Build without cache (fresh git packages)
make verify-deps # Verify all dependencies are correctly installed
make image-info # Show image information (ID, size, creation date)
make test-run # Test run the ping test (without Redis)
make version-check # Check libp2p version in the image
make clean # Remove generated files and Docker image
make help# Show help message
Redis Coordination
Purpose
Redis serves as a coordination mechanism between dialer and listener components, enabling:
Service Discovery: Dialer finds listener's address
Message Broker: Reliable messaging for address exchange
Timeout Handling: Graceful failure when components unavailable
Process Flow
Listener Starts: Creates libp2p host, publishes address to Redis
self.redis_client.rpush("listenerAddr", addr_str)
Dialer Starts: Retrieves listener address from Redis
# Test with multiple concurrent connectionsforiin {1..10};do
docker run --rm --network host \
-e transport=tcp -e muxer=yamux -e security=noise \
-e is_dialer=true -e redis_addr=localhost:6379 \
python-v0.2.9-git python ping_test.py &done
Stress Testing
# Run tests for extended periodsforiin {1..100};doecho"Test iteration $i"# Run test
sleep 1
done
Automated Test Matrix
#!/bin/bash# Test matrix
transports=("tcp")
securities=("noise""plaintext")
muxers=("yamux""mplex")
roles=("python_js""js_python")
fortransportin"${transports[@]}";doforsecurityin"${securities[@]}";doformuxerin"${muxers[@]}";doforrolein"${roles[@]}";doecho"Testing: $transport + $security + $muxer ($role)"# Run test with current configuration# Store resultsdonedonedonedone
Continuous Monitoring
#!/bin/bashset -e
echo"Starting automated tests for python-v0.2.9"# Build implementationcd transport-interop/impl/python/v0.2
make
# Run testscd ../..
npm test -- --name-filter="python-v0.2.9"> results-$(date +%Y%m%d-%H%M%S).log
echo"Tests completed successfully"
Success Criteria
A successful test should demonstrate:
✅ Connection Establishment: Dialer successfully connects to listener
# Clean up test containers
docker kill$(docker ps -q --filter ancestor=python-v0.2.9-git)
docker rm $(docker ps -aq --filter ancestor=python-v0.2.9-git)# Clean up Redis
docker stop redis-test && docker rm redis-test
# Clean up test artifacts
rm -f test-results.log metrics.json test-report.*
Maintenance
# Clean up old images
docker image prune -f
# Clean up old containers
docker container prune -f
# Clean up old volumes
docker volume prune -f
Summary
This Python libp2p ping implementation provides:
Complete Interoperability: Works with other libp2p implementations
Flexible Testing: Supports manual, automated, and cross-implementation testing
Robust Coordination: Uses Redis for reliable service discovery
Comprehensive Debugging: Built-in logging and error handling
Performance Monitoring: Detailed timing and resource metrics
Easy Deployment: Docker-based with simple configuration
The implementation successfully demonstrates cross-implementation compatibility and provides a solid foundation for transport-interop testing across the libp2p ecosystem.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Transport-Interop Python Implementation - Complete Guide
Last review: August 2025
This document provides a comprehensive overview of the Python libp2p ping implementation for transport-interop testing, consolidating information from all documentation files.
Table of Contents
Overview
The Python libp2p ping implementation enables interoperability testing between different libp2p implementations. It supports:
Protocol Configuration
Where Protocol Lists Are Specified
The Python protocol list (TCP, Noise, Yamux, Mplex) is specified in two main locations:
1. Framework Configuration:
versionsInput.json
Location:
/transport-interop/versionsInput.json
This is the central configuration file that defines all supported protocols for each implementation. The framework uses this to:
2. Runtime Validation:
ping_test.py
Location:
/transport-interop/impl/python/v0.2/ping_test.py
This provides runtime validation to ensure only supported protocols are used.
Current Python Protocol Support
["tcp"]
["noise", "plaintext"]
["mplex", "yamux"]
Comparison with Other Implementations
Python has limited transport support compared to other implementations:
["tcp", "ws", "wss", "quic-v1", "webtransport", "webrtc-direct"]
["ws", "tcp", "quic-v1", "webrtc-direct"]
["tcp", "ws", "wss"]
["webtransport", "wss", "webrtc-direct", "webrtc"]
["tcp"]
← Only TCPAdding New Protocols
To add new protocols to Python, you would need to:
versionsInput.json
: Add new protocols to the Python configurationping_test.py
: Add validation and implementation for new protocolsThe protocol list is intentionally limited in Python compared to other implementations, likely due to the current capabilities of the py-libp2p library.
Architecture
Component Roles
Prerequisites
System Requirements
Docker Configuration
Network Pool Configuration
If you encounter "all predefined address pools have been fully subnetted" error:
Then restart Docker:
sudo systemctl restart docker
Quick Start
1. Build Python Implementation
cd transport-interop/impl/python/v0.2 make all
2. Start Redis
3. Test Listener (Terminal 1)
docker run --rm --network host \ -e transport=tcp -e muxer=mplex -e security=noise \ -e is_dialer=false -e ip="0.0.0.0" \ -e redis_addr=localhost:6379 -e test_timeout_seconds=15 \ python-v0.2.9-git python ping_test.py
4. Test Dialer (Terminal 2)
5. Cleanup
docker stop redis-test && docker rm redis-test
Testing Methods
Manual Testing
Basic Ping/Pong Test
Multiple Test Runs
Automated Testing
Framework Setup
Test Python Implementation
Cross-Implementation Testing
Cross-Implementation Testing
Python vs JS-libp2p
Supported Combinations
Configuration
Environment Variables
Python Implementation
Automated Testing
Makefile Targets
Redis Coordination
Purpose
Redis serves as a coordination mechanism between dialer and listener components, enabling:
Process Flow
Listener Starts: Creates libp2p host, publishes address to Redis
Dialer Starts: Retrieves listener address from Redis
Connection: Dialer connects to listener using retrieved address
Redis Commands
Data Structure
Troubleshooting
Common Issues
Issue 1: Redis Connection Failed
Symptoms:
Error: Error -2 connecting to redis:6379
Solutions:
Issue 2: Docker Image Not Found
Symptoms:
Unable to find image 'python-v0.2.9-git'
Solutions:
Issue 3: Port Already in Use
Symptoms:
Address already in use
errorsSolutions:
Issue 4: Timeout Waiting for Listener
Symptoms:
Error: Timeout waiting for listener address
Solutions:
Issue 5: Docker Network Pool Exhausted
Symptoms: "all predefined address pools have been fully subnetted"
Solutions:
Debug Mode
Enable Debug Logging
Debug Features
/tmp/
LIBP2P_DEBUG
is not setPerformance
Expected Metrics
Localhost Testing
Performance Benchmarks
Performance Testing
Advanced Features
Load Testing
Stress Testing
Automated Test Matrix
Continuous Monitoring
Success Criteria
A successful test should demonstrate:
Expected Test Results
Successful Test Output
Performance Benchmarks
Cleanup
Post-Test Cleanup
Maintenance
Summary
This Python libp2p ping implementation provides:
The implementation successfully demonstrates cross-implementation compatibility and provides a solid foundation for transport-interop testing across the libp2p ecosystem.
Beta Was this translation helpful? Give feedback.
All reactions