You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
torrust_tracker_primitives::peer::Peer derives PartialEq, Eq and Hash over all seven fields, but implements Ord by peer_id only (PartialOrd delegates to it). For a seeder a and a copy b with left = 5, a == b is false while a.cmp(&b) is Ordering::Equal. This violates the Ord/Eq contract (cmp must be Equal if and only if ==) in a published crate.
Impact
Latent today: no production code sorts, min/maxes or puts Peer in a BTreeSet; the swarm keys by PeerId in a BTreeMap<PeerId, Arc<Peer>>. PeerList and Torrent in torrent-repository-benchmarking derive Ord and inherit the defect through Arc<Peer>, but nothing orders them either. External users of the crate who sort or deduplicate peers are exposed.
Reproduction
Reproduced with a temporary unit test: a == b: false, a.cmp(&b): Equal.
Plan
Investigate why Eq is whole-struct and Ord is id-only and classify every call site (the peer id is chosen by clients, so an implicit id-only comparison can hide bugs or collisions), then fix per the options in the spec (A remove Ord, B id-only Eq, C order by all fields with peer_id first, D document only; C is the tentative recommendation). Add a regression test proven red before the fix.
Full specification: docs/issues/drafts/peer-ord-inconsistent-with-eq/ISSUE.md on the spec branch (to be moved to docs/issues/open/ once this issue has a number).
Activity
docs(issues): [torrust#2798] address review round 1 of the Peer Ord spec
docs(issues): [torrust#2798] stamp start and end of each reproduction…
docs(pr-reviews): [torrust#2798] record the PR 2800 review audit
docs(pr-reviews): [torrust#2798] record the round 2 thread resolutions
docs(pr-reviews): [torrust#2798] quote the pickaxe command in one cod…
docs(pr-reviews): [torrust#2798] append a log correction for the firs…
docs(pr-reviews): [torrust#2798] record the round 3 findings
docs(pr-reviews): [torrust#2798] record the round 3 thread resolutions
docs(issues): move Peer Ord spec to open for #2798
Merge #2800: docs(issues): [#2798] spec for Peer Ord inconsistent wit…
test(primitives): [torrust#2798] also guard against a PartialOrd-only…
fix(primitives): [torrust#2798] remove the Ord impl of Peer that disa…
docs(issues): [torrust#2798] mark T4 to T6 done and record the final …
test(primitives): [torrust#2798] also guard against a PartialOrd-only…
docs(issues): [torrust#2798] name the code state and green output in …
1 remaining item
docs(pr-reviews): [torrust#2798] record the PR 2811 review audit
docs(pr-reviews): [torrust#2798] record the round 1 thread resolutions
docs(issues): [torrust#2798] state only the red runs that happened fo…
docs(issues): [torrust#2798] list the versioning ADR under Related ADRs
docs(issues): [torrust#2798] record the retrospective rationale and t…
docs(pr-reviews): [torrust#2798] remove commit ids from the PR 2811 a…
docs(pr-reviews): [torrust#2798] add the Completion Rules section to …
docs(pr-reviews): [torrust#2798] record the PR 2811 round 2 findings
docs(pr-reviews): [torrust#2798] record the round 2 thread resolutions
docs(pr-reviews): [torrust#2798] add the PR 2811 review retrospective
docs(issues): [#2798] record the T1 findings for the Peer Ord spec
Merge torrust#2811: fix(primitives): [torrust#2798] remove the Ord im…
Merge #2827: refactor(primitives): [#2823] remove unused AddAssign fo…
Merge #2828: docs(issues): [#2824] add issue specification for primit…