Skip to content

Conversation

@asmit27rai
Copy link
Contributor

Fix #1070 - Validate all DHT records if a record validator exists.

  • Add parameter to KadDHT (default: False)
  • Add class as permissive fallback for non-namespaced keys
  • Add exception for strict validation failures
  • Update to support strict/permissive modes
  • Update tests to cover both validation modes

When strict_validation=True, all records must use registered namespaces (aligns with go-libp2p/rust-libp2p behavior). When False (default), non-namespaced keys are implicitly accepted for backward compatibility.

Usage

# Permissive mode (default, backward compatible)
dht = KadDHT(host, ...)

# Strict mode
dht = KadDHT(host, strict_validation=True)

# Toggle at runtime
dht.validator.strict_validation = True

asmit27rai and others added 2 commits January 16, 2026 00:36
Implements libp2p#1070 - Validate all DHT records if a record validator exists.

- Add  parameter to KadDHT (default: False)
- Add  class as permissive fallback for non-namespaced keys
- Add  exception for strict validation failures
- Update  to support strict/permissive modes
- Update tests to cover both validation modes

When strict_validation=True, all records must use registered namespaces
(aligns with go-libp2p/rust-libp2p behavior). When False (default),
non-namespaced keys are implicitly accepted for backward compatibility.
@seetadev
Copy link
Contributor

@asmit27rai : Thanks for the detailed update, Asmit — this is a strong and well-thought-through contribution 👏

The overall approach makes a lot of sense:

  • Introducing strict_validation as an opt-in flag keeps us backward compatible by default while enabling stronger correctness guarantees.
  • Aligning strict mode behavior with go-libp2p / rust-libp2p is exactly the right long-term direction.
  • The permissive fallback for non-namespaced keys is a good transitional mechanism.
  • Clear exception semantics for strict validation failures improve debuggability.
  • Test coverage for both strict and permissive modes is much appreciated — that clarity really helps reviewers.

Before we move this forward, could you please fix the current CI/CD failures on the PR?
A few checks are still red, and we’d like to make sure everything is green so we’re not merging unrelated breakages.

Once CI is passing, I’m happy to take another look and help drive this through final review and merge. Thanks again for pushing this forward — this is an important step toward stricter, more interoperable DHT behavior 🚀

CCing @sumanjeet0012 and @acul71.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Validate all DHT records if a record validator exists

2 participants