feat: add dispute resolution window configuration#218
Merged
nafiuishaaq merged 3 commits intoApr 29, 2026
Conversation
- Add set_dispute_window(window_ledgers: u32) function with admin-only access - Add get_dispute_window() view function returning u32 ledgers - Set default window value to 1000 ledgers (DEFAULT_DISPUTE_WINDOW_LEDGERS) - Add DisputeWindowUpdated event with old/new window values and admin info - Update dispute window logic to use ledger-based timing instead of seconds - Add validation for dispute window range (10-100,000 ledgers) - Add comprehensive tests for dispute window configuration - Update init function to accept dispute_window_ledgers parameter - Export DisputeWindowUpdated event from events module
Resolved conflicts: - Updated dispute window logic to use ledger-based timing across all modules - Fixed type mismatches between u32 (ledgers) and u64 (timestamps) - Integrated new upstream error codes and features - Maintained dispute window configuration functionality
Resolved conflicts: - Maintained ledger-based dispute window logic across all modules - Fixed duplicate module declarations - Removed duplicate code in acquire_lock function - Kept DisputeWindowUpdated event and configuration functionality
|
@ScriptedBro 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.
Add Dispute Resolution Window Configuration
Overview
This PR implements configurable dispute resolution time windows, allowing admins to adjust the period during which disputes can be raised after session completion.
Changes
New Features
set_dispute_window(window_ledgers: u32): Admin-only function to configure the dispute resolution windowDisputeWindowUpdatedevent on successful updateget_dispute_window() -> u32: View function to retrieve the current dispute windowDisputeWindowUpdatedEvent: New event emitted when dispute window is updatedold_window_ledgersandnew_window_ledgersupdated_by(admin address) andtimestampImplementation Details
DEFAULT_DISPUTE_WINDOW_LEDGERS)DISPUTE_WINDOW_MIN_LEDGERS)DISPUTE_WINDOW_MAX_LEDGERS)init()function to acceptdispute_window_ledgers: u32parameterlock_funds()to calculate dispute deadline using ledger sequencesauto_refund()to check dispute window using ledger sequencesTesting
Added comprehensive test coverage:
test_get_dispute_window_returns_default- Verifies default valuetest_set_dispute_window_updates_value- Tests successful updatetest_set_dispute_window_emits_event- Verifies event emissiontest_set_dispute_window_rejects_too_small- Validates minimum constrainttest_set_dispute_window_rejects_too_large- Validates maximum constrainttest_set_dispute_window_requires_admin- Ensures admin-only accesstest_set_dispute_window_accepts_minimum_value- Tests boundary conditiontest_set_dispute_window_accepts_maximum_value- Tests boundary conditiontest_dispute_window_persists_across_calls- Verifies persistenceFiles Modified
crates/contracts/core/src/events.rs- AddedDisputeWindowUpdatedeventcrates/contracts/core/src/lib.rs- Implemented dispute window functions and updated logiccrates/contracts/core/src/oracle.rs- Fixed error type referencescrates/contracts/core/src/test.rs- Added comprehensive test suiteAcceptance Criteria
set_dispute_window(window_ledgers: u32)function implementedget_dispute_window()view function implementedDisputeWindowUpdatedeventBreaking Changes
init()function signature has changed:init(env, admin, platform_fee_bps, treasury_address, dispute_window_secs: u64)init(env, admin, platform_fee_bps, treasury_address, dispute_window_ledgers: u32)Existing deployments will need to update initialization calls to use ledgers instead of seconds.
Build Status
✅ Release build successful
✅ All new tests passing
Related Issues
Closes #121
Checklist