Task: Dispute tally property tests & resolved outcome summary cache#564
Merged
greatest0fallt1me merged 2 commits intoMay 27, 2026
Conversation
…y property tests and cache resolved outcome summary for O(1) payout reads
|
@Dopezapha 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! 🚀 |
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.
Closes #553
Closes #547
Summary
Property tests forDisputeManager::calculate_dispute_outcome`Files changed:
property_based_tests.rs,tests/dispute_stake_tests.rsAdded a
proptestsuite and deterministic unit tests covering all required invariants forDisputeUtils::calculate_stake_weighted_outcomeandDisputeManager::calculate_dispute_outcome:deterministic_tallytie_resolves_to_rejectfalse(reject)monotonic_in_support_stakeempty_stakes_no_panicdispute_tally_single_voter_supportdispute_tally_all_equal_stakes_is_tieAll tests use real
DisputeVoting/DisputeVotetypes fromdisputes.rs.Edge cases covered: empty set, single voter, all-equal stakes, monotonic increase.
ResolvedOutcomeSummarycache inresolution.rsFiles changed:
resolution.rs,lib.rs,bets.rs,disputes.rsPrecomputes and persists a
ResolvedOutcomeSummarystruct(
winning_total,total_pool,num_winning_outcomes) once at resolution time viaResolutionOutcomeCache::refresh(), eliminating repeated full-bet-set iteration on everypayout/claim call.
Payout paths updated to O(1) cache reads:
lib.rs::distribute_payouts→ResolutionOutcomeCache::require()(line 3300)lib.rs::claim_winnings→ResolutionOutcomeCache::require()(line 1881)Cache invalidation:
ResolutionOutcomeCache::invalidate()called before admin outcome overridedisputes.rscallsrefresh()after dispute-driven outcome changerequire()includes a staleness guard: re-computes automatically iftotal_poolornum_winning_outcomesdrifts from cached values