Skip to content

Commit 2cd567d

Browse files
author
Dave Grantham
committed
Updating to latest py-libp2p to try to make this tests work.
Merge branch 'main' into dhuseby/fix/set-up-interop-testing
2 parents 093d4eb + 3ea5881 commit 2cd567d

File tree

115 files changed

+17828
-667
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

115 files changed

+17828
-667
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ coverage.xml
4545
*.cover
4646
.pytest_cache/
4747

48+
# Test result files
49+
tests/**/results/*.json
50+
tests/**/results/*.xml
51+
tests/**/results/*.html
52+
4853
# Translations
4954
*.mo
5055
*.pot

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@
310310
"tests.factories",
311311
# Mocked ONLY for Sphinx/autodoc: this module does not exist in the codebase
312312
# but some doc tools may try to import it. No real code references this import.
313-
"libp2p.relay.circuit_v2.lib"
313+
"libp2p.relay.circuit_v2.lib",
314314
]
315315

316316
# Documents to append as an appendix to all manuals.

docs/examples.interop.rst

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
Interoperability Testing
2+
========================
3+
4+
This example provides a standalone console script for testing libp2p ping functionality
5+
without Docker or Redis dependencies. It supports both listener and dialer roles and
6+
measures ping RTT and handshake times.
7+
8+
Usage
9+
-----
10+
11+
Run as listener (waits for connection):
12+
13+
.. code-block:: console
14+
15+
$ python -m examples.interop.local_ping_test --listener --port 8000
16+
Listener ready, listening on:
17+
/ip4/127.0.0.1/tcp/8000/p2p/Qm...
18+
Waiting for dialer to connect...
19+
20+
Run as dialer (connects to listener):
21+
22+
.. code-block:: console
23+
24+
$ python -m examples.interop.local_ping_test --dialer --destination /ip4/127.0.0.1/tcp/8000/p2p/Qm...
25+
Connecting to listener at: /ip4/127.0.0.1/tcp/8000/p2p/Qm...
26+
Connected successfully
27+
Performing ping test
28+
{"handshakePlusOneRTTMillis": 15.2, "pingRTTMilllis": 2.1}
29+
30+
Options
31+
-------
32+
33+
- ``--listener``: Run as listener (wait for connection)
34+
- ``--dialer``: Run as dialer (connect to listener)
35+
- ``--destination ADDR``: Destination multiaddr (required for dialer)
36+
- ``--port PORT``: Port number (0 = auto-select)
37+
- ``--transport {tcp,ws,quic-v1}``: Transport protocol (default: tcp)
38+
- ``--muxer {mplex,yamux}``: Stream muxer (default: mplex)
39+
- ``--security {noise,plaintext}``: Security protocol (default: noise)
40+
- ``--test-timeout SECONDS``: Test timeout in seconds (default: 180)
41+
- ``--debug``: Enable debug logging
42+
43+
The full source code for this example is below:
44+
45+
.. literalinclude:: ../examples/interop/local_ping_test.py
46+
:language: python
47+
:linenos:

docs/examples.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Examples
1111
examples.echo
1212
examples.echo_quic
1313
examples.ping
14+
examples.interop
1415
examples.pubsub
1516
examples.bitswap
1617
examples.circuit_relay

docs/libp2p.security.pnet.rst

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
libp2p.security.pnet package
2+
================================
3+
4+
Submodules
5+
----------
6+
7+
libp2p.security.pnet.protector module
8+
-------------------------------------
9+
10+
.. automodule:: libp2p.security.pnet.protector
11+
:members:
12+
:undoc-members:
13+
:show-inheritance:
14+
15+
libp2p.security.pnet.psk_conn module
16+
------------------------------------
17+
18+
.. automodule:: libp2p.security.pnet.psk_conn
19+
:members:
20+
:undoc-members:
21+
:show-inheritance:
22+
23+
Module contents
24+
---------------
25+
26+
.. automodule:: libp2p.security.pnet
27+
:members:
28+
:undoc-members:
29+
:show-inheritance:

docs/libp2p.security.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Subpackages
99

1010
libp2p.security.insecure
1111
libp2p.security.noise
12+
libp2p.security.pnet
1213
libp2p.security.secio
1314
libp2p.security.tls
1415

docs/libp2p.transport.quic.rst

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,55 @@
11
libp2p.transport.quic package
22
=============================
33

4+
Connection ID Management
5+
------------------------
6+
7+
The QUIC transport implementation uses a sophisticated Connection ID (CID) management system
8+
inspired by the `quinn` Rust QUIC library. This system ensures proper packet routing and
9+
handles connection migration scenarios.
10+
11+
Key Features
12+
~~~~~~~~~~~~
13+
14+
**Sequence Number Tracking**
15+
Each Connection ID is assigned a sequence number, starting at 0 for the initial CID.
16+
Sequence numbers are used to ensure proper retirement ordering per the QUIC specification.
17+
18+
**Initial vs. Established CIDs**
19+
Initial CIDs (used during handshake) are tracked separately from established connection CIDs.
20+
This separation allows for efficient packet routing and proper handling of handshake packets.
21+
22+
**Fallback Routing**
23+
When packets arrive with new Connection IDs before ``ConnectionIdIssued`` events are processed,
24+
the system uses O(1) fallback routing based on address mappings. This handles race conditions
25+
gracefully and ensures packets are routed correctly.
26+
27+
**Retirement Ordering**
28+
Connection IDs are retired in sequence order, ensuring compliance with the QUIC specification.
29+
The ``ConnectionIDRegistry`` maintains sequence number mappings to enable proper retirement.
30+
31+
Architecture
32+
~~~~~~~~~~~~
33+
34+
The ``ConnectionIDRegistry`` class manages all Connection ID routing state:
35+
36+
- **Established connections**: Maps Connection IDs to ``QUICConnection`` instances
37+
- **Pending connections**: Maps Connection IDs to ``QuicConnection`` (aioquic) instances during handshake
38+
- **Initial CIDs**: Separate tracking for handshake packet routing
39+
- **Sequence tracking**: Maps Connection IDs to sequence numbers and connections to sequence ranges
40+
- **Address mappings**: Bidirectional mappings between Connection IDs and addresses for O(1) fallback routing
41+
42+
Performance Monitoring
43+
~~~~~~~~~~~~~~~~~~~~~~
44+
45+
The registry tracks performance metrics including:
46+
47+
- Fallback routing usage count
48+
- Sequence number distribution
49+
- Operation timings (when debug mode is enabled)
50+
51+
These metrics can be accessed via the ``get_stats()`` method and reset using ``reset_stats()``.
52+
453
Submodules
554
----------
655

examples/interop/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"""Interoperability examples for py-libp2p."""

0 commit comments

Comments
 (0)