Skip to content

Commit 7c20140

Browse files
Merge branch 'libp2p:main' into bugfix/kbucket_split_fix
2 parents 37df8d6 + 90f143c commit 7c20140

File tree

21 files changed

+218
-155
lines changed

21 files changed

+218
-155
lines changed

Makefile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ PYI = $(PB:.proto=_pb2.pyi)
6969
## Set default to `protobufs`, otherwise `format` is called when typing only `make`
7070
all: protobufs
7171

72+
.PHONY: protobufs clean-proto
73+
7274
protobufs: $(PY)
7375

7476
%_pb2.py: %.proto
@@ -77,6 +79,11 @@ protobufs: $(PY)
7779
clean-proto:
7880
rm -f $(PY) $(PYI)
7981

82+
# Force protobuf regeneration by making them always out of date
83+
$(PY): FORCE
84+
85+
FORCE:
86+
8087
# docs commands
8188

8289
docs: check-docs

README.md

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@
1212
[![Build Status](https://img.shields.io/github/actions/workflow/status/libp2p/py-libp2p/tox.yml?branch=main&label=build%20status)](https://github.com/libp2p/py-libp2p/actions/workflows/tox.yml)
1313
[![Docs build](https://readthedocs.org/projects/py-libp2p/badge/?version=latest)](http://py-libp2p.readthedocs.io/en/latest/?badge=latest)
1414

15-
> ⚠️ **Warning:** py-libp2p is an experimental and work-in-progress repo under development. We do not yet recommend using py-libp2p in production environments.
15+
> py-libp2p has moved beyond its experimental roots and is steadily progressing toward production readiness. The core features are stable, and we’re focused on refining performance, expanding protocol support, and ensuring smooth interop with other libp2p implementations. We welcome contributions and real-world usage feedback to help us reach full production maturity.
1616
1717
Read more in the [documentation on ReadTheDocs](https://py-libp2p.readthedocs.io/). [View the release notes](https://py-libp2p.readthedocs.io/en/latest/release_notes.html).
1818

1919
## Maintainers
2020

21-
Currently maintained by [@pacrob](https://github.com/pacrob), [@seetadev](https://github.com/seetadev) and [@dhuseby](https://github.com/dhuseby), looking for assistance!
21+
Currently maintained by [@pacrob](https://github.com/pacrob), [@seetadev](https://github.com/seetadev) and [@dhuseby](https://github.com/dhuseby). Please reach out to us for collaboration or active feedback. If you have questions, feel free to open a new [discussion](https://github.com/libp2p/py-libp2p/discussions). We are also available on the libp2p Discord — join us at #py-libp2p [sub-channel](https://discord.gg/d92MEugb).
2222

2323
## Feature Breakdown
2424

@@ -34,47 +34,47 @@ ______________________________________________________________________
3434
| -------------------------------------- | :--------: | :---------------------------------------------------------------------------------: |
3535
| **`libp2p-tcp`** || [source](https://github.com/libp2p/py-libp2p/blob/main/libp2p/transport/tcp/tcp.py) |
3636
| **`libp2p-quic`** | 🌱 | |
37-
| **`libp2p-websocket`** | | |
38-
| **`libp2p-webrtc-browser-to-server`** | | |
39-
| **`libp2p-webrtc-private-to-private`** | | |
37+
| **`libp2p-websocket`** | 🌱 | |
38+
| **`libp2p-webrtc-browser-to-server`** | 🌱 | |
39+
| **`libp2p-webrtc-private-to-private`** | 🌱 | |
4040

4141
______________________________________________________________________
4242

4343
### NAT Traversal
4444

45-
| **NAT Traversal** | **Status** |
46-
| ----------------------------- | :--------: |
47-
| **`libp2p-circuit-relay-v2`** | |
48-
| **`libp2p-autonat`** | |
49-
| **`libp2p-hole-punching`** | |
45+
| **NAT Traversal** | **Status** | **Source** |
46+
| ----------------------------- | :--------: | :-----------------------------------------------------------------------------: |
47+
| **`libp2p-circuit-relay-v2`** | | [source](https://github.com/libp2p/py-libp2p/tree/main/libp2p/relay/circuit_v2) |
48+
| **`libp2p-autonat`** | | [source](https://github.com/libp2p/py-libp2p/tree/main/libp2p/host/autonat) |
49+
| **`libp2p-hole-punching`** | | [source](https://github.com/libp2p/py-libp2p/tree/main/libp2p/relay/circuit_v2) |
5050

5151
______________________________________________________________________
5252

5353
### Secure Communication
5454

5555
| **Secure Communication** | **Status** | **Source** |
5656
| ------------------------ | :--------: | :---------------------------------------------------------------------------: |
57-
| **`libp2p-noise`** | 🌱 | [source](https://github.com/libp2p/py-libp2p/tree/main/libp2p/security/noise) |
58-
| **`libp2p-tls`** | | |
57+
| **`libp2p-noise`** | | [source](https://github.com/libp2p/py-libp2p/tree/main/libp2p/security/noise) |
58+
| **`libp2p-tls`** | 🌱 | |
5959

6060
______________________________________________________________________
6161

6262
### Discovery
6363

64-
| **Discovery** | **Status** |
65-
| -------------------- | :--------: |
66-
| **`bootstrap`** | |
67-
| **`random-walk`** | |
68-
| **`mdns-discovery`** | |
69-
| **`rendezvous`** | |
64+
| **Discovery** | **Status** | **Source** |
65+
| -------------------- | :--------: | :--------------------------------------------------------------------------------: |
66+
| **`bootstrap`** | | [source](https://github.com/libp2p/py-libp2p/tree/main/libp2p/discovery/bootstrap) |
67+
| **`random-walk`** | 🌱 | |
68+
| **`mdns-discovery`** | | [source](https://github.com/libp2p/py-libp2p/tree/main/libp2p/discovery/mdns) |
69+
| **`rendezvous`** | 🌱 | |
7070

7171
______________________________________________________________________
7272

7373
### Peer Routing
7474

75-
| **Peer Routing** | **Status** |
76-
| -------------------- | :--------: |
77-
| **`libp2p-kad-dht`** | |
75+
| **Peer Routing** | **Status** | **Source** |
76+
| -------------------- | :--------: | :--------------------------------------------------------------------: |
77+
| **`libp2p-kad-dht`** | | [source](https://github.com/libp2p/py-libp2p/tree/main/libp2p/kad_dht) |
7878

7979
______________________________________________________________________
8080

@@ -89,18 +89,18 @@ ______________________________________________________________________
8989

9090
### Stream Muxers
9191

92-
| **Stream Muxers** | **Status** | **Status** |
93-
| ------------------ | :--------: | :----------------------------------------------------------------------------------------: |
94-
| **`libp2p-yamux`** | 🌱 | |
95-
| **`libp2p-mplex`** | 🛠️ | [source](https://github.com/libp2p/py-libp2p/blob/main/libp2p/stream_muxer/mplex/mplex.py) |
92+
| **Stream Muxers** | **Status** | **Source** |
93+
| ------------------ | :--------: | :-------------------------------------------------------------------------------: |
94+
| **`libp2p-yamux`** | | [source](https://github.com/libp2p/py-libp2p/tree/main/libp2p/stream_muxer/yamux) |
95+
| **`libp2p-mplex`** | | [source](https://github.com/libp2p/py-libp2p/tree/main/libp2p/stream_muxer/mplex) |
9696

9797
______________________________________________________________________
9898

9999
### Storage
100100

101101
| **Storage** | **Status** |
102102
| ------------------- | :--------: |
103-
| **`libp2p-record`** | |
103+
| **`libp2p-record`** | 🌱 |
104104

105105
______________________________________________________________________
106106

libp2p/crypto/pb/crypto_pb2.py

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

libp2p/crypto/pb/crypto_pb2.pyi

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class _KeyTypeEnumTypeWrapper(google.protobuf.internal.enum_type_wrapper._EnumTy
2828
Secp256k1: _KeyType.ValueType # 2
2929
ECDSA: _KeyType.ValueType # 3
3030
ECC_P256: _KeyType.ValueType # 4
31+
X25519: _KeyType.ValueType # 5
3132

3233
class KeyType(_KeyType, metaclass=_KeyTypeEnumTypeWrapper): ...
3334

@@ -36,6 +37,7 @@ Ed25519: KeyType.ValueType # 1
3637
Secp256k1: KeyType.ValueType # 2
3738
ECDSA: KeyType.ValueType # 3
3839
ECC_P256: KeyType.ValueType # 4
40+
X25519: KeyType.ValueType # 5
3941
global___KeyType = KeyType
4042

4143
@typing.final

libp2p/identity/identify/pb/identify_pb2.py

Lines changed: 6 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 47 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,49 @@
1-
from google.protobuf.internal import containers as _containers
2-
from google.protobuf import descriptor as _descriptor
3-
from google.protobuf import message as _message
4-
from typing import ClassVar as _ClassVar, Iterable as _Iterable, Optional as _Optional
1+
"""
2+
@generated by mypy-protobuf. Do not edit manually!
3+
isort:skip_file
4+
"""
55

6-
DESCRIPTOR: _descriptor.FileDescriptor
6+
import builtins
7+
import collections.abc
8+
import google.protobuf.descriptor
9+
import google.protobuf.internal.containers
10+
import google.protobuf.message
11+
import typing
712

8-
class Identify(_message.Message):
9-
__slots__ = ("protocol_version", "agent_version", "public_key", "listen_addrs", "observed_addr", "protocols", "signedPeerRecord")
10-
PROTOCOL_VERSION_FIELD_NUMBER: _ClassVar[int]
11-
AGENT_VERSION_FIELD_NUMBER: _ClassVar[int]
12-
PUBLIC_KEY_FIELD_NUMBER: _ClassVar[int]
13-
LISTEN_ADDRS_FIELD_NUMBER: _ClassVar[int]
14-
OBSERVED_ADDR_FIELD_NUMBER: _ClassVar[int]
15-
PROTOCOLS_FIELD_NUMBER: _ClassVar[int]
16-
SIGNEDPEERRECORD_FIELD_NUMBER: _ClassVar[int]
17-
protocol_version: str
18-
agent_version: str
19-
public_key: bytes
20-
listen_addrs: _containers.RepeatedScalarFieldContainer[bytes]
21-
observed_addr: bytes
22-
protocols: _containers.RepeatedScalarFieldContainer[str]
23-
signedPeerRecord: bytes
24-
def __init__(self, protocol_version: _Optional[str] = ..., agent_version: _Optional[str] = ..., public_key: _Optional[bytes] = ..., listen_addrs: _Optional[_Iterable[bytes]] = ..., observed_addr: _Optional[bytes] = ..., protocols: _Optional[_Iterable[str]] = ..., signedPeerRecord: _Optional[bytes] = ...) -> None: ...
13+
DESCRIPTOR: google.protobuf.descriptor.FileDescriptor
14+
15+
@typing.final
16+
class Identify(google.protobuf.message.Message):
17+
DESCRIPTOR: google.protobuf.descriptor.Descriptor
18+
19+
PROTOCOL_VERSION_FIELD_NUMBER: builtins.int
20+
AGENT_VERSION_FIELD_NUMBER: builtins.int
21+
PUBLIC_KEY_FIELD_NUMBER: builtins.int
22+
LISTEN_ADDRS_FIELD_NUMBER: builtins.int
23+
OBSERVED_ADDR_FIELD_NUMBER: builtins.int
24+
PROTOCOLS_FIELD_NUMBER: builtins.int
25+
SIGNEDPEERRECORD_FIELD_NUMBER: builtins.int
26+
protocol_version: builtins.str
27+
agent_version: builtins.str
28+
public_key: builtins.bytes
29+
observed_addr: builtins.bytes
30+
signedPeerRecord: builtins.bytes
31+
@property
32+
def listen_addrs(self) -> google.protobuf.internal.containers.RepeatedScalarFieldContainer[builtins.bytes]: ...
33+
@property
34+
def protocols(self) -> google.protobuf.internal.containers.RepeatedScalarFieldContainer[builtins.str]: ...
35+
def __init__(
36+
self,
37+
*,
38+
protocol_version: builtins.str | None = ...,
39+
agent_version: builtins.str | None = ...,
40+
public_key: builtins.bytes | None = ...,
41+
listen_addrs: collections.abc.Iterable[builtins.bytes] | None = ...,
42+
observed_addr: builtins.bytes | None = ...,
43+
protocols: collections.abc.Iterable[builtins.str] | None = ...,
44+
signedPeerRecord: builtins.bytes | None = ...,
45+
) -> None: ...
46+
def HasField(self, field_name: typing.Literal["agent_version", b"agent_version", "observed_addr", b"observed_addr", "protocol_version", b"protocol_version", "public_key", b"public_key", "signedPeerRecord", b"signedPeerRecord"]) -> builtins.bool: ...
47+
def ClearField(self, field_name: typing.Literal["agent_version", b"agent_version", "listen_addrs", b"listen_addrs", "observed_addr", b"observed_addr", "protocol_version", b"protocol_version", "protocols", b"protocols", "public_key", b"public_key", "signedPeerRecord", b"signedPeerRecord"]) -> None: ...
48+
49+
global___Identify = Identify

libp2p/kad_dht/pb/kademlia_pb2.py

Lines changed: 14 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

libp2p/network/connection/swarm_connection.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323

2424

2525
"""
26-
Reference: https://github.com/libp2p/go-libp2p-swarm/blob/04c86bbdafd390651cb2ee14e334f7caeedad722/swarm_conn.go
26+
Reference: https://github.com/libp2p/go-libp2p-swarm/blob/
27+
04c86bbdafd390651cb2ee14e334f7caeedad722/swarm_conn.go
2728
"""
2829

2930

@@ -43,6 +44,21 @@ def __init__(
4344
self.streams = set()
4445
self.event_closed = trio.Event()
4546
self.event_started = trio.Event()
47+
# Provide back-references/hooks expected by NetStream
48+
try:
49+
setattr(self.muxed_conn, "swarm", self.swarm)
50+
51+
# NetStream expects an awaitable remove_stream hook
52+
async def _remove_stream_hook(stream: NetStream) -> None:
53+
self.remove_stream(stream)
54+
55+
setattr(self.muxed_conn, "remove_stream", _remove_stream_hook)
56+
except Exception as e:
57+
logging.warning(
58+
f"Failed to set optional conveniences on muxed_conn "
59+
f"for peer {muxed_conn.peer_id}: {e}"
60+
)
61+
# optional conveniences
4662
if hasattr(muxed_conn, "on_close"):
4763
logging.debug(f"Setting on_close for peer {muxed_conn.peer_id}")
4864
setattr(muxed_conn, "on_close", self._on_muxed_conn_closed)

0 commit comments

Comments
 (0)