Make voting snapshots stable across repeated reads - #1417
Merged
greatest0fallt1me merged 2 commits intoAug 29, 2026
Merged
Conversation
The community-consensus snapshot is computed (not persisted) by
MarketAnalytics::calculate_community_consensus and consumed by
MarketUtils::determine_winning_outcomes. Both previously broke vote
ties by walking Soroban Map iteration order, which is not guaranteed
to be stable across reads, so identical vote censuses could yield
different consensus/winner selections.
Make selection deterministic and reviewable:
- calculate_community_consensus now breaks ties against the market's
canonical, application-ordered outcomes list (first-listed leader
wins) instead of relying on Map iteration order, keeping aggregation
(sums) order-independent.
- determine_winning_outcomes collects tied winners by walking the
market's canonical outcomes list, keeping the resolved winner set
stable and consistent with the consensus tie-break.
- Document the invariant (no Map-order-dependent tie-breaking) in code.
Preserves all public signatures and existing behavior for clear
majorities, no-vote markets, and unanimous votes.
Adds voting_snapshot_stability_tests covering repeated-read stability,
canonical-order tie determinism, insertion-order independence, and
consistency between consensus and winning-outcome selection.
Also fixes pre-existing test-compile arity errors in
require_auth_coverage_tests.rs (set_oracle_val_cfg_{global,event} now
take max_deviation_bps) so the test suite compiles and CI passes.
|
@aliyuHabibu Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The community-consensus snapshot is computed (not persisted) by MarketAnalytics::calculate_community_consensus and consumed by MarketUtils::determine_winning_outcomes. Both previously broke vote ties by walking Soroban Map iteration order, which is not guaranteed to be stable across reads, so identical vote censuses could yield different consensus/winner selections.
Make selection deterministic and reviewable:
Preserves all public signatures and existing behavior for clear majorities, no-vote markets, and unanimous votes.
Adds voting_snapshot_stability_tests covering repeated-read stability, canonical-order tie determinism, insertion-order independence, and consistency between consensus and winning-outcome selection.
Also fixes pre-existing test-compile arity errors in require_auth_coverage_tests.rs (set_oracle_val_cfg_{global,event} now take max_deviation_bps) so the test suite compiles and CI passes.
Pull Request Description
📋 Basic Information
Type of Change
Please select the type of change this PR introduces:
Related Issues
Closes #(issue number)
Fixes #(issue number)
Related to #(issue number)
Priority Level
📝 Detailed Description
What does this PR do?
Why is this change needed?
How was this tested?
Alternative Solutions Considered
🏗️ Smart Contract Specific
Contract Changes
Please check all that apply:
Oracle Integration
Market Resolution Logic
Security Considerations
🧪 Testing
Test Coverage
Test Results
Manual Testing Steps
📚 Documentation
Documentation Updates
Breaking Changes
Breaking Changes:
Migration Guide:
🔍 Code Quality
Code Review Checklist
Performance Impact
Security Review
🚀 Deployment & Integration
Deployment Notes
Integration Points
📊 Impact Assessment
User Impact
Business Impact
✅ Final Checklist
Pre-Submission
Review Readiness
📸 Screenshots (if applicable)
🔗 Additional Resources
💬 Notes for Reviewers
Please pay special attention to:
Close #1400