Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
a33003f
feat(kad-dht): implement IPNS validator for DHT record validation
asmit27rai Jan 25, 2026
c3f858a
Merge branch 'main' into IPNS
yashksaini-coder Jan 27, 2026
a206843
add official spec test vectors
asmit27rai Jan 27, 2026
9ed3b58
fix: resolve lint errors and add docs for IPNS module
asmit27rai Jan 27, 2026
0107de3
fix: CI compatibility issues
asmit27rai Jan 27, 2026
bbb9e7d
lint ci/cd
asmit27rai Jan 27, 2026
6531458
TestVector type
asmit27rai Jan 28, 2026
cc46182
linting
asmit27rai Jan 28, 2026
f3d181f
fix: resolve pyrefly type errors (bytes/str, None checks, key types)
asmit27rai Jan 28, 2026
974bbc3
Merge branch 'main' into IPNS
yashksaini-coder Jan 29, 2026
fec2d6e
fix: Assign self.validator to a local variable after the type guard.
yashksaini-coder Jan 29, 2026
f0a0de0
Merge branch 'main' into IPNS
yashksaini-coder Jan 29, 2026
ae34859
stricter IPNS validator with spec parity and upstream references
asmit27rai Jan 31, 2026
b935771
Revert "stricter IPNS validator with spec parity and upstream referen…
asmit27rai Jan 31, 2026
596d09f
Merge branch 'main' into IPNS
yashksaini-coder Feb 1, 2026
ab4f22d
Merge branch 'main' into IPNS
yashksaini-coder Feb 3, 2026
95b3f8e
Merge branch 'main' into IPNS
yashksaini-coder Feb 5, 2026
78398c9
enhance IPNS validator with stricter checks and new features
asmit27rai Feb 5, 2026
66a3645
Update duplicate names for Test classes
yashksaini-coder Feb 6, 2026
55e8afa
Merge branch 'main' into IPNS
yashksaini-coder Feb 7, 2026
cc1a6a6
Merge branch 'main' into IPNS
seetadev Feb 9, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions docs/libp2p.records.pb.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
libp2p.records.pb package
=========================

Submodules
----------

libp2p.records.pb.ipns\_pb2 module
----------------------------------

.. automodule:: libp2p.records.pb.ipns_pb2
:members:
:undoc-members:
:show-inheritance:

Module contents
---------------

.. automodule:: libp2p.records.pb
:members:
:undoc-members:
:show-inheritance:
24 changes: 24 additions & 0 deletions docs/libp2p.records.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ libp2p.records package
Submodules
----------

libp2p.records.ipns module
--------------------------

.. automodule:: libp2p.records.ipns
:members:
:undoc-members:
:show-inheritance:

libp2p.records.pubkey module
----------------------------

Expand Down Expand Up @@ -35,3 +43,19 @@ libp2p.records.validator module
:members:
:undoc-members:
:show-inheritance:

Subpackages
-----------

.. toctree::
:maxdepth: 4

libp2p.records.pb

Module contents
---------------

.. automodule:: libp2p.records
:members:
:undoc-members:
:show-inheritance:
23 changes: 16 additions & 7 deletions libp2p/kad_dht/kad_dht.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
PeerInfo,
)
from libp2p.peer.peerstore import env_to_send_in_RPC
from libp2p.records.ipns import IPNSValidator
from libp2p.records.pubkey import PublicKeyValidator
from libp2p.records.validator import NamespacedValidator, Validator
from libp2p.tools.async_service import (
Expand Down Expand Up @@ -269,15 +270,20 @@ def apply_fallbacks(self) -> None:
the default validator set hasn't been overridden.
"""
if not self.validator_changed:
# Ensure validator is a NamespacedValidator (cannot be None at this point)
if not isinstance(self.validator, NamespacedValidator):
raise ValueError(
"Default validator was changed without marking it True"
)

if "pk" not in self.validator._validators:
self.validator._validators["pk"] = PublicKeyValidator()
# Use a local variable to help type checker narrow the type
validator = self.validator

# TODO: Do the same thing for ipns, but need to implement first.
# Add missing default validators
if "pk" not in validator._validators:
validator._validators["pk"] = PublicKeyValidator()
if "ipns" not in validator._validators:
validator._validators["ipns"] = IPNSValidator()

def validate_config(self) -> None:
"""
Expand Down Expand Up @@ -305,15 +311,18 @@ def validate_config(self) -> None:

vmap = self.validator._validators

# TODO: Need to add ipns also in the check
if set(vmap.keys()) != {"pk"}:
# Check that both pk and ipns validators are present
required_validators = {"pk", "ipns"}
if not required_validators.issubset(set(vmap.keys())):
raise ValueError(f"{PROTOCOL_PREFIX} must have 'pk' and 'ipns' validators")

pk_validator = vmap.get("pk")
if not isinstance(pk_validator, PublicKeyValidator):
raise TypeError("'pk' namesapce must use PublicKeyValidator")
raise TypeError("'pk' namespace must use PublicKeyValidator")

# TODO: ipns checks
ipns_validator = vmap.get("ipns")
if not isinstance(ipns_validator, IPNSValidator):
raise TypeError("'ipns' namespace must use IPNSValidator")

def set_validator(self, val: NamespacedValidator) -> None:
"""
Expand Down
Loading
Loading