Skip to content

Comments

fix: deterministic tie-breaking in mode() and identical aggregators#1845

Draft
wentzeld wants to merge 4 commits intomainfrom
ndFix
Draft

fix: deterministic tie-breaking in mode() and identical aggregators#1845
wentzeld wants to merge 4 commits intomainfrom
ndFix

Conversation

@wentzeld
Copy link
Contributor

Summary

  • Fix mode() tie-breaking in reduce_aggregator.go:464-483 — sort SHA keys before selecting winner
  • Fix collectHighestCounts() in identical.go:78-88 — use SHA comparison as deterministic tiebreaker
  • Add 6 non-determinism regression tests

Root Cause

Go map iteration order is randomized. When multiple values tie for highest frequency (mode) or equal count (identical), different nodes pick different
winners, causing PrepareSignature verification failures.

Test plan

  • All 6 non-determinism tests pass (previously 5/6 failing)
  • All 30 existing aggregator tests pass (zero regressions)

wentzeld and others added 3 commits February 14, 2026 16:04
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
  Resolve non-deterministic map iteration in mode() (reduce_aggregator.go)
  and collectHighestCounts() (identical.go) that caused cross-node consensus
  failures with 'PrepareSignature failed to verify' errors.
@github-actions
Copy link

github-actions bot commented Feb 18, 2026

✅ API Diff Results - No breaking changes


📄 View full apidiff report

Copy link
Contributor

@bolekk bolekk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of those are for V1 consensus, not used in CRE.

modeKeys = append(modeKeys, sha)
}
}
sort.Slice(modeKeys, func(i, j int) bool {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file is part of V1 consensus, not used in CRE.

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