Skip to content

fix: emit self:peer:update on observed address removal#3483

Merged
tabcat merged 4 commits intolibp2p:mainfrom
tabcat:fix/remove-observed-addr-update
Apr 29, 2026
Merged

fix: emit self:peer:update on observed address removal#3483
tabcat merged 4 commits intolibp2p:mainfrom
tabcat:fix/remove-observed-addr-update

Conversation

@tabcat
Copy link
Copy Markdown
Member

@tabcat tabcat commented Apr 27, 2026

Description

AddressManager.removeObservedAddr had inverted polarity vs.
confirmObservedAddr: startingConfidence was initialised to false,
the inner guards used the wrong sign, and the final check was negated.
_updatePeerStoreAddresses() was never invoked from the removal path.

Effect: callers that mark an address unreachable —
packages/protocol-autonat-v2/src/client.ts,
packages/protocol-autonat/src/autonat.ts,
packages/transport-circuit-relay-v2/src/transport/listener.ts
removed the address from internal state but never patched the peer
store, so self:peer:update did not fire and downstream consumers
(DHT mode switching, identify-push, application subscribers) could not
react.

Fix mirrors the polarity used by confirmObservedAddr.

Notes & open questions

Change checklist

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation if necessary (this includes comments as well)
  • I have added tests that prove my fix is effective or that my feature works

tabcat and others added 2 commits April 27, 2026 22:08
Demonstrates that removeObservedAddr does not invoke
_updatePeerStoreAddresses, so self:peer:update never fires when an
address becomes unreachable. Fix follows in a separate commit.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Mirrors the pattern in confirmObservedAddr so _updatePeerStoreAddresses
runs when a previously verified address is removed, allowing
self:peer:update to fire.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@tabcat tabcat marked this pull request as ready for review April 27, 2026 16:25
@tabcat tabcat requested a review from a team as a code owner April 27, 2026 16:25
@tabcat tabcat marked this pull request as draft April 27, 2026 16:26
@tabcat tabcat marked this pull request as ready for review April 28, 2026 06:49
Comment thread packages/libp2p/test/addresses/address-manager.spec.ts Outdated
tabcat and others added 2 commits April 29, 2026 18:16
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@tabcat tabcat merged commit 3a5e46e into libp2p:main Apr 29, 2026
48 of 49 checks passed
@tabcat tabcat mentioned this pull request Apr 29, 2026
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.

2 participants