feat: implement resolution delay and dispute window system#296
Open
Villarley wants to merge 3 commits intoPredictify-org:masterfrom
Open
feat: implement resolution delay and dispute window system#296Villarley wants to merge 3 commits intoPredictify-org:masterfrom
Villarley wants to merge 3 commits intoPredictify-org:masterfrom
Conversation
- Introduced a mandatory dispute window between market resolution and payout distribution, allowing community members to challenge outcomes. - Added configurable dispute window duration (1-168 hours) for global and per-market settings. - Implemented proposal-based resolution, where outcomes are proposed and finalized after the dispute window closes. - Integrated dispute filing and resolution tracking, ensuring payouts are blocked until disputes are resolved. - Emitted events for resolution proposals, dispute window closures, and finalizations to enhance transparency and user interaction. - Updated relevant contract functions and tests to support the new resolution delay features.
Contributor
|
@Villarley resolve the conflicts |
Contributor
Author
Ready ! any compliments are well received |
- Added support for fallback oracle configuration as a vector to allow multiple configurations. - Updated error handling for circuit breaker and resolution processes to provide clearer error messages. - Refactored tests and contract functions to accommodate new oracle address handling and improved error categorization. - Introduced utility functions for managing fallback oracle configurations and streamlined market state management. - Ensured comprehensive test coverage for new features and error scenarios.
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.
Resolution Delay and Dispute Window Implementation
Summary
This PR implements a configurable resolution delay (dispute window) feature that adds a time buffer between market resolution and final payout. During this window, users and administrators can raise disputes before payouts are finalized. This enhancement significantly improves market security and fairness by allowing time for community oversight.
closes #263
Key Features
🔒 Security Enhancement
⚙️ Configuration Flexibility
📊 Resolution Workflow
Technical Implementation
New Files Created
src/resolution_delay.rsCore module implementing the dispute window logic:
ResolutionDelayManager: Main manager struct with all resolution delay operationssrc/resolution_delay_tests.rsComprehensive test suite covering:
Modified Files
src/types.rsResolutionDelayConfigstruct for configurationResolutionWindowstruct for tracking resolution stateMarketstruct with resolution tracking fields:resolution_proposed_outcomeresolution_proposed_atresolution_window_end_timeresolution_is_finalizedresolution_dispute_countresolution_sourcedispute_window_hoursis_resolution_finalized(),is_dispute_window_open(),is_resolution_proposed(),get_dispute_window_end_time()src/errors.rsLeveraged existing error codes to avoid exceeding the 50-variant limit:
Error::DisputeTimeoutNotExpired- Reused for "dispute window still open"Error::MarketNotResolved- Reused for "resolution not finalized"Error::DisputeVotingNotAllowed- Reused for "dispute window not open"Error::MarketAlreadyResolved- Reused for "resolution already finalized"Error::DisputeResolutionConditionsNotMet- Reused for "unresolved disputes"src/events.rsAdded three new event types:
ResolutionProposedEvent- Emitted when resolution is proposedDisputeWindowClosedEvent- Emitted when window expiresResolutionFinalizedEvent- Emitted when resolution is finalizedsrc/lib.rsAdded six new public contract functions:
Modified existing function:
claim_winnings()- Now checks if resolution is finalized before allowing claimssrc/resolution.rsMarketResolutionManager::resolve_market()to callpropose_resolution()instead of immediately settingwinning_outcomesrc/disputes.rsDisputeManager::process_dispute()to validate dispute windowResolutionDelayManager::record_dispute()Documentation Files
README.md(root) - Added Resolution Delay feature sectioncontracts/predictify-hybrid/README.md- Detailed feature documentation with flow diagramsAPI Changes
New Public Functions
Configuration
Resolution Management
Status & Disputes
Modified Functions
Breaking Changes
Before:
resolve_market()→ immediate payout availableAfter:
resolve_market()→propose_market_resolution()→ dispute window opens →finalize_market_resolution()→ payout availableMigration Impact:
resolve_market()will continue to work, but payouts will require an additionalfinalize_market_resolution()call after the dispute windowError::MarketNotResolvedEvent Emission
Three new events are emitted during the resolution lifecycle:
Testing
Test Coverage
Comprehensive test suite in
resolution_delay_tests.rs:✅ Window Configuration Tests (4 tests)
✅ Resolution Workflow Tests (8 tests)
✅ Dispute Filing Tests (6 tests)
✅ Finalization Tests (5 tests)
✅ Edge Cases (6 tests)
Total Test Cases: 29+ comprehensive tests
Build Status
✅ Compilation: Success
✅ No compilation errors
✅ WASM target builds successfully
Security Considerations
Attack Vectors Addressed
Admin Controls
Data Integrity
Documentation
Updated Documentation
Root README.md: Added feature overview and integration guide
Contract README.md: Detailed technical documentation with:
Inline Documentation: NatSpec-style comments on all new functions
Performance Considerations
Backwards Compatibility
Usage Example
Checklist
Related Issues
Closes #263
Breaking Changes Summary
While this PR maintains backwards compatibility with existing functionality, integrations should be aware of the new resolution workflow:
finalize_market_resolution()Deployment Notes
set_dispute_window_duration(admin, None, 72)ResolutionProposedEventandResolutionFinalizedEventfor resolution lifecycleFuture Enhancements
Potential improvements for future PRs:
Review Focus Areas:
Marketstruct