Repository navigation
feat(service-disco): add registrar - #2275
Conversation
c82c531 to
0a3fb63
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #2275 +/- ##
==========================================
+ Coverage 72.56% 72.73% +0.17%
==========================================
Files 164 165 +1
Lines 20886 21266 +380
Branches 20 20
==========================================
+ Hits 15155 15468 +313
- Misses 5731 5798 +67
🚀 New features to boost your workflow:
|
vladopajic
left a comment
There was a problem hiding this comment.
in general lgtm, needs more tidying up before merge
| if serviceLowerBound > w: | ||
| w = serviceLowerBound | ||
|
|
||
| for addressInfo in ad.data.addresses: |
There was a problem hiding this comment.
ad.data.addresses.filterIPv4()
There was a problem hiding this comment.
We just want filtering IPv4's for iptree related stuff, service discovery supports ipv6. IPTree is a sybil attack mitigation for ipv4 advertisements
| doAssert res.isOk(), "sign failed in test helper" | ||
| t | ||
|
|
||
| proc createTestMultiAddress*(ip: string): MultiAddress = |
There was a problem hiding this comment.
aslo Test in name is unecessery
There was a problem hiding this comment.
since these are utilities that will be used everywhere better stick to same convention
There was a problem hiding this comment.
Sticking with createSwitch for simplicity (other tests use that name) and changing everything else to makeFoo
0fee4b6 to
1eeba32
Compare
be64b83 to
423c403
Compare
e4a3701 to
6700ef4
Compare
There was a problem hiding this comment.
Pull request overview
Implements the REGISTER side of the Logos service-discovery protocol by introducing a Registrar (admission control + retry ticket handling + ad cache/LRU + IP-tree scoring) and wiring it into ServiceDiscovery alongside consolidated protocol types/config.
Changes:
- Expanded
ServiceDiscoveryConfigwith defaults and moved/added core service-discovery types (registrar/cache-related types, routing-table manager types). - Added
registrar.nimwith cache management, waiting-time computation, retry-ticket validation, and advertisement acceptance logic. - Added comprehensive unit tests for registrar logic plus shared test helpers.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 12 comments.
Show a summary per file
| File | Description |
|---|---|
libp2p/protocols/service_discovery/types.nim |
Adds config defaults/constructor and consolidates service-discovery types (registrar + routing-table manager types). |
libp2p/protocols/service_discovery/registrar.nim |
New registrar implementation (waiting-time scoring, pruning/eviction, retry ticket processing, cache + metrics). |
libp2p/protocols/service_discovery/routing_table_manager.nim |
Removes moved type definitions and simplifies imports. |
libp2p/protocols/service_discovery.nim |
Adds ServiceDiscovery.new and wires in registrar + per-service routing manager; adds handler loop scaffolding. |
tests/libp2p/service_discovery/utils.nim |
Adds registrar/discovery construction helpers and advertisement/ticket builders for tests. |
tests/libp2p/service_discovery/test_registrar.nim |
Adds unit test coverage for registrar waiting-time, bounds, pruning, and retry-ticket processing. |
09bf42d to
dccfe2a
Compare
dccfe2a to
17e220a
Compare
1614eae to
5c12571
Compare
Summary
Implements the REGISTER flow for the Logos service-discovery protocol on top of per-service routing tables.
Adds the
Registrarwith anti-Sybil logic, retry-ticket validation, advertisement cache (LRU), and wires everything throughServiceDiscovery.new. Also consolidates types and expandsServiceDiscoveryConfiginto a full configuration with defaults.Changes
libp2p/protocols/service_discovery/types.nim:ServiceDiscoveryConfigwith full protocol parameters and constructor.ServiceStatusandServiceRoutingTableManagerhere.AdvertisementKey,Advertisement,Registrar,AdvertiseTask,Advertiser.registrarandrtManagertoServiceDiscovery; renamesdiscoveryConfig→discoConfig.Registrar.new,Advertiser.new,toAdvertisementKey,hashServiceId,advertisesService.libp2p/protocols/service_discovery/registrar.nim(new):adScore,insertAd,removeAdpruneExpiredAds,waitingTime,updateLowerBoundsvalidateRegisterMessage,processRetryTicketsendRegisterResponse,acceptAdvertisement(full admission + LRU + metrics)libp2p/protocols/service_discovery/routing_table_manager.nim:libp2p/protocols/service_discovery.nim:ServiceDiscovery.newand protocol handler loop (stubs forgetAds,register).Tests:
test_registrar.nim,utils.nim).Affected Areas
Peer Management / Discovery
Protocol Logic
Compatibility & Downstream Validation
ServiceDiscovery.discoveryConfig→discoConfig(breaking rename).ServiceDiscovery.newadded; object-literal construction may need updates.Impact on Library Users
discoveryConfig→discoConfig.registrar,rtManager.Registrar,Advertisement*,Advertiser.ServiceDiscovery.new.ServiceDiscoveryConfignow fully defined (constructor + defaults).routing_table_manager.nimtotypes.nim.Risk Assessment
adScore: now safely skipped (fix).References