Skip to content

fix: use the same peer id to load and store peer records#3570

Open
tabcat wants to merge 1 commit into
libp2p:mainfrom
tabcat:fix/peer-store-address-handling
Open

fix: use the same peer id to load and store peer records#3570
tabcat wants to merge 1 commit into
libp2p:mainfrom
tabcat:fix/peer-store-address-handling

Conversation

@tabcat

@tabcat tabcat commented Jul 16, 2026

Copy link
Copy Markdown
Member

Description

consumePeerRecord() uses two different peer ids. It derives one from the
envelope public key and uses it to load the stored peer and compare sequence
numbers, then stores the addresses under the peer id from the record payload.

A PeerRecord names the peer it describes, so for anything produced by
RecordEnvelope.seal() the two agree and this is invisible. Nothing checks it
though, and when they differ the sequence number comparison is made against a
different peer to the one being written, so it no longer orders that peer's
records and an older record can replace a newer one.

Ignore records where the two do not match.

Notes & open questions

Returns false like the neighbouring expectedPeer check rather than throwing.

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

consumePeerRecord compared sequence numbers against the peer id from the
envelope public key, but stored the addresses under the peer id from the
record payload. Ignore records where the two do not match.
@tabcat
tabcat marked this pull request as ready for review July 16, 2026 17:10
@tabcat
tabcat requested a review from a team as a code owner July 16, 2026 17:10
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.

1 participant