refactor(provider): remove dependency on probe-lab/go-libdht@v0.4.0#1202
refactor(provider): remove dependency on probe-lab/go-libdht@v0.4.0#1202
Conversation
Co-authored-by: Dennis Trautwein <dennis.trautwein@posteo.de>
Kad Import
Adding NodeFilter to TrieRT
fix: add to immutable trie returns original trie if no changes made
Version 0.1.0
* chore: add or force update .github/workflows/stale.yml * chore: add or force update .github/workflows/generated-pr.yml
BREAKING CHANGE: Updating the Go version to 1.23
* feat: Trie.AddMany * lint
* feat(key/bit256): memory optimized constructor * tests * minor quality improvements
imports Kademlia key abstractions, XOR trie, and test utilities from github.com/probe-lab/go-libdht@v0.4.0 to remove external dependency rationale: - removes dependency on external package (probe-lab/go-libdht) - minimizes maintenance surface by importing only used components - ~1,800 LOC of well-tested, stable code worth maintaining locally - full control over implementation without risk of upstream breaking changes this commit preserves full git history with original authors and commits files imported to provider/internal/kad/: - kad/kad.go → key.go (Key[K] interface - core Kademlia key abstraction) - kad/key/ → key/ - key/bit256/ (256-bit fixed-length key implementation) - key/bitstr/ (variable-length bit string key implementation) - key/util.go (key utilities: Equal, CommonPrefixLength, BitString, etc.) - key/test/ (test helpers for key implementations) - kad/trie/ → trie/ (XOR trie data structure with tests) - kad/kadtest/ → kadtest/ (test utilities: Key32, Key8, RandomKey, benchmarking helpers) (required by trie tests) files NOT imported (unused by provider, not maintaining): - kad/triert/ (trie-based routing table - provider uses different structure) - kad/doc.go (package-level documentation) license compatibility: - go-libdht: Permissive License Stack (Apache-2.0 OR MIT) - go-libp2p-kad-dht: MIT - imported code now under go-libp2p-kad-dht MIT license
updates all internal imports in provider/internal/kad/ from github.com/probe-lab/go-libdht/kad to github.com/libp2p/go-libp2p-kad-dht/provider/internal/kad all tests pass
…ackage updates all imports in provider/ from github.com/probe-lab/go-libdht/kad to github.com/libp2p/go-libp2p-kad-dht/provider/internal/kad all tests pass
dependency successfully replaced with internal provider/internal/kad package
gammazero
left a comment
There was a problem hiding this comment.
No problem with this PR, LGTM.
Too bad we will give up the change history as there were many changes made to this code as part of the sweeping reprovide work. If there is any particularly informative change history (as identified by @guillaumemichel) from the old repo, then that can be made into documentation in the new repo. No need to block waiting for that.
|
Triage notes:
|
|
@lidel @gammazero I've just made you admins for the |
|
Thank you @dennis-tra <3 This solves the problem at hand. Closing this for now – we may reuse this strategy in the future to consolidate repos if/when kad-dht has to be moved out of libp2p (entire IPFS-specific provide code lives here now), but that is a topic for 2026. |
Warning
Opening this to kick-off discussion – we need to make decision here before Kubo 0.39 (ipfs/kubo#10946) ships by end of November.
@guillaumemichel @gammazero @aschmahmann for visibility/feedback. >
TBD if we do this. We may work with probe-lab to share maintenance rights with shipyard instead, as mid-term solution.
Removes external dependency on
github.com/probe-lab/go-libdht@v0.4.0by importing required Kademlia utilities intoprovider/internal/kad/.Motivation
The provider sweep system relies on key abstractions and XOR trie structures from go-libdht. With sweep becoming the default provider strategy in Kubo 0.39, this external dependency creates maintenance risk for critical infrastructure.
Rationale & Alternative
@guillaumemichel still had maintenance permissions from the time probelab and shipyard were the same entitty, but other shipyard members are not able to do the same.
Internalizing ~1,800 LOC of stable, well-tested code gives us full control without upstream breaking change risk (low) and potential ciritcal bugfix releases being blocked by lack of maintenance permissions (high). Alternative would be granting shipyard team maintenance rights to https://github.com/probe-lab/go-libdht.
Changes
Imported to
provider/internal/kad/kad/key.go-Key[K]interface (Kademlia key abstraction)kad/key/- bit256, bitstr implementations + utilitieskad/trie/- XOR trie data structurekad/kadtest/- test utilities (required by trie tests)Not Imported
kad/triert/- routing table implementation (unused, probably used only by probe-lab/zikade)Imports Updated
Git History
Full commit history from go-libdht@v0.4.0 preserved using
git subtree add. Original authors and timestamps maintained forgit blameandgit log.Using subtree ensures the history is exactly the same, but we could rewrite history if we want things like " #2 " to link to proper issue/pr in correct repository.
TODO
tmp/go-libdhtprovider/internal/kad, remove the restgo test ./...)License
go-libdht uses Permissive License Stack (Apache-2.0 OR MIT), compatible with go-libp2p-kad-dht's MIT license.