Skip to content

cluster: dedup definition peers by peer ID - #4635

Open
pinebit wants to merge 1 commit into
mainfrom
pinebit/dkg-duplicate-peer-fix
Open

cluster: dedup definition peers by peer ID#4635
pinebit wants to merge 1 commit into
mainfrom
pinebit/dkg-duplicate-peer-fix

Conversation

@pinebit

@pinebit pinebit commented Aug 10, 2026

Copy link
Copy Markdown
Collaborator

Deduplicate operators in Definition.Peers() by derived peer ID instead of by raw ENR string, and rename the error to definition contains duplicate peer ids.

Two distinct ENR strings can encode the same public key (e.g. different sequence numbers or extra fields), producing the same libp2p peer ID. Such definitions passed the previous ENR-string dedup and collapsed the peerMap built in dkg.Run (NodeIdx returns the first matching operator index), which made newFrostP2P panic with an index out-of-range when a surviving PeerIdx exceeded the map length. When the duplicated operator was last, the ceremony instead proceeded with an inconsistent peer map.

Peer-ID dedup subsumes the ENR-string check, since identical ENR strings always yield identical peer IDs. All callers of Peers() (dkg ceremony, node run, edit protocols) now reject such definitions with a clean error.

category: bug
ticket: none

Reject cluster definitions containing operators whose ENRs encode the
same public key. Peers previously deduplicated operators by ENR string
only, so distinct ENRs sharing a key (and thus a peer ID) passed
verification and collapsed the peer index map built during DKG setup,
causing an index out-of-range panic in newFrostP2P.

category: bug
ticket: none

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@sonarqubecloud

Copy link
Copy Markdown

@pinebit
pinebit requested a review from KaloyanTanev August 10, 2026 10:39
@codecov

codecov Bot commented Aug 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 57.84%. Comparing base (aea5631) to head (7d33e8a).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4635      +/-   ##
==========================================
- Coverage   58.16%   57.84%   -0.32%     
==========================================
  Files         247      247              
  Lines       34056    34056              
==========================================
- Hits        19807    19699     -108     
- Misses      11779    11910     +131     
+ Partials     2470     2447      -23     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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