-
Notifications
You must be signed in to change notification settings - Fork 1.2k
fix(peerstore): replace stale addrs on newer signed peer record #3487
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -475,8 +475,8 @@ func testCertifiedAddresses(m pstore.AddrBook, clk *mockClock.Mock) func(*testin | |
| t.Error("unable to retrieve signed routing record from addrbook") | ||
| } | ||
|
|
||
| // Adding a new envelope should clear existing certified addresses. | ||
| // Only the newly-added ones should remain | ||
|
Comment on lines
-478
to
-479
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ℹ️ intention was documented, but never implemented. this PR aims to implement it this PR does not purge all addrs, only one matching previous signed record, but we could also pivot it to do full clean so only signed addrs remain (not feeling strongly, whatever feels better)
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. replacing it makes sense. The full purge is a bigger riskier change I think |
||
| // A newer signed record drops addrs the peer no longer advertises. | ||
| // Unsigned addrs (added via plain AddAddrs) are retained. | ||
| certifiedAddrs = certifiedAddrs[:3] | ||
| rec4 := peer.NewPeerRecord() | ||
| rec4.PeerID = id | ||
|
|
@@ -488,8 +488,9 @@ func testCertifiedAddresses(m pstore.AddrBook, clk *mockClock.Mock) func(*testin | |
| if !accepted { | ||
| t.Error("expected peer record to be accepted") | ||
| } | ||
| // AssertAddressesEqual(t, certifiedAddrs, m.Addrs(id)) | ||
| AssertAddressesEqual(t, allAddrs, m.Addrs(id)) | ||
| expectedAfterRec4 := append([]multiaddr.Multiaddr{}, certifiedAddrs...) | ||
| expectedAfterRec4 = append(expectedAfterRec4, uncertifiedAddrs...) | ||
| AssertAddressesEqual(t, expectedAfterRec4, m.Addrs(id)) | ||
|
|
||
| // update TTL on signed addrs to -1 to remove them. | ||
| // the signed routing record should be deleted | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A very minor nit: if you return an iter.Seq you avoid this allocation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd lean toward keeping the slice here: caller gates on
len(superseded) > 0anddeleteInPlaceiterates the set per surviving entry, soiter.Seqwould just push the alloc intodeleteAddrsor force a signature change.. feels like not worth the noise.