fix(service-disco): advertise a caller-supplied XPR - #99
Merged
Conversation
gmelodie
force-pushed
the
fix/service-disco/advertise-full-xpr
branch
from
August 6, 2026 12:54
cc83a90 to
4771153
Compare
2 tasks
gmelodie
force-pushed
the
fix/service-disco/advertise-full-xpr
branch
from
August 6, 2026 13:10
4771153 to
b0deb0a
Compare
gmelodie
force-pushed
the
fix/service-disco/advertise-full-xpr
branch
from
August 6, 2026 14:02
b0deb0a to
8ff6384
Compare
gmelodie
marked this pull request as ready for review
August 6, 2026 15:07
vladopajic
approved these changes
Aug 7, 2026
vladopajic
reviewed
Aug 7, 2026
2 tasks
gmelodie
force-pushed
the
fix/service-disco/advertise-full-xpr
branch
from
August 10, 2026 13:26
df0a2eb to
0e54afa
Compare
richard-ramos
approved these changes
Aug 11, 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.
Closes #98.
startAdvertisingnow takes the advertisement to publish, so a consuming module that runs on its own switch advertises its own peer ID and addresses. Before, the module encodedserviceInfointo an XPR built from its own connectable address, and discoverers reached the wrong node.discoStartAdvertising(serviceId, serviceData, advertisement):advertisementis a base64 signed XPR, the same encodingcreateXprreturns anddecodeXpraccepts. An empty string keeps the current behaviour, and the node advertises its own record. The module decodes the base64 and passes the bytes through; nim-libp2p'svalidateAdvertrejects a record that fails to decode, exceedsMaxXPRSize, or does not list the service, and the reason reaches the caller.The
libp2pinput stays onmasterand moves to00cab64, the merge of vacp2p/nim-libp2p#2917, which adds theadvertisement: seq[byte]field toStartAdvertisingRequestand makesstartAdvertisingreturnResult[void, string].That bump also picks up a week of nim-libp2p master, which renamed the generated entry points for
{.ffiStatic.}procs. Two unrelated call sites follow the rename:libp2p_ctx_collect_metricsbecomeslibp2p_static_collect_metrics, andlibp2p_ctx_new_private_keybecomeslibp2p_static_new_private_key. Both keepcallSyncWith, so the existing context requirement does not change.Tests:
disco_advertise_foreign_xprbuilds an XPR on a node that mounts no service discovery, advertises it from a second node, and asserts that the discoverer resolves the first node's peer ID and address.disco_advertise_rejects_bad_xprcovers bad base64, an XPR for a different service, and a tampered signature.startDiscoPeer.Verified locally:
nix build .#lgxsucceeds on the mergedmasterpin. The integration suite ran earlier on the pre-merge branch pin, whose cbind API is identical, and reported 84 passed, 3 failed. All disco and XPR tests pass, including the two new ones.Two pre-existing issues found while verifying, both out of scope here:
tests/CMakeLists.txtlooks forlibp2p.soin../lib, the test derivation does not vendor it, and every job logs[Libp2pTests] libp2p not found in ../lib — skipping integration tests. The suite has to be built by hand to run at all.custom_handlers_mount_without_emit_event_ok,protocol_bridge_request_accept_roundtripandprotocol_bridge_request_no_responseall callmountProtocolon a node with noemitEvent, whichsrc/custom_handlers.cpp:9rejects by design. The tests contradict the implementation and nothing has been running them.createXpris missing from the generated LIDL contract because its declaration inplugin.hspans three lines and the header parser drops those.