Repository navigation
feat(service-disco): add advertiser - #2285
Merged
Merged
Conversation
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
gmelodie
force-pushed
the
feat/service-disco/registrar
branch
from
April 15, 2026 20:01
09bf42d to
dccfe2a
Compare
gmelodie
force-pushed
the
feat/service-disco/advertiser
branch
from
April 17, 2026 14:17
cf60e59 to
44876d1
Compare
vladopajic
approved these changes
Apr 17, 2026
gmelodie
enabled auto-merge
April 17, 2026 22:44
vladopajic
reviewed
Apr 18, 2026
vladopajic
reviewed
Apr 18, 2026
richard-ramos
approved these changes
Apr 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds the advertiser subsystem to
ServiceDiscovery, building on the registrar and per-service routing tables introduced in the parent branch.It wires up the
Advertisertype (already declared intypes.nim) into theServiceDiscoveryobject and implements the full outbound advertisement lifecycle:REGISTERmessagesConfirmed/Wait/Rejectedresponses with appropriate back-offaddProvidedServiceandremoveProvidedServiceare added as the primary API for managing which services a node actively advertises.Changes
libp2p/protocols/service_discovery/advertiser.nim(new)sendRegister
REGISTERmessage, and returns:(RegistrationStatus, Opt[Ticket], seq[PeerId])startAdvertising
peerInfo(if not externally supplied)Confirmed→ sleepadvertExpiryWait→ sleepmin(advertExpiry, tWaitFor)Rejected→ stopaddProvidedService
ProvidedinrtManager(seeded from main routing table)kRegisterstartAdvertisingtasks per non-empty bucketremoveProvidedService
rtManager.removeServiceclear
libp2p/protocols/service_discovery/types.nimadvertiser*: Advertiserfield toServiceDiscoverylibp2p/protocols/service_discovery.nimAdvertiserviaAdvertiser.new()in theServiceDiscoveryconstructortests/libp2p/service_discovery/test_advertiser.nim(new)addProvidedService(5 async)removeProvidedService(3 async)startAdvertising / stopAdvertising(4 sync)tests/libp2p/service_discovery/utils.nimpopulateRoutingTable(disco, n)populateAdvTable(disco, serviceId)routing_table_managerkademlia/routing_tableAffected Areas
addProvidedService/removeProvidedService)REGISTERsend pathCompatibility & Downstream Validation
All changes are additive relative to the registrar branch.
advertiserfield is initialized inServiceDiscovery.newDownstream projects (Nimbus, Waku, Codex) do not require validation unless they construct
ServiceDiscoveryvia object literals instead ofnewImpact on Library Users
ServiceDiscovery.advertiser: AdvertiseraddProvidedService(disco, service, add)removeProvidedService(disco, service)sendRegister(disco, peerId, serviceId, ad, ticket)startAdvertising(disco, serviceId, registrar, bucketIdx, ticket, add)Advertiser.clear()Risk Assessment
startAdvertising name collision
Task not started when upgrading Interest → Both
Interest, upgrading toProvidedreturns earlyNo task completion tracking
advertiser.runningis not cleaned up when tasks finish or errorReferences