feat: Recovery dry_run mode#770
Merged
greatest0fallt1me merged 3 commits intoJun 29, 2026
Merged
Conversation
Add read-only Recovery::dry_run for ops verification. Returns the recovery plan without executing any side effects or requiring admin authentication. Changes: - Add DryRunResult type (contracttype) with integrity_ok, can_recover, issues_detected, planned_actions, and state_description fields - Add RecoveryManager::recovery_dry_run() mirroring recover_market_state logic but read-only: no storage writes, no events, no auth - Add PredictifyHybrid::recovery_dry_run() contract entrypoint - Add 8 focused tests covering market not found, valid market, closed market, cancelled market, total_staked mismatch, stakes sum correctness, no-auth-required path, and struct field validation - Use checked_add with overflow detection for diagnostic accuracy Closes Predictify-org#708
|
@Osifowora 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! 🚀 |
The sed-based insertion corrupted the file, causing an unclosed delimiter error. Replaced with a reliable Python-based insert.
4 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.
Summary
Add
Recovery::dry_run— a read-only entrypoint that returns the recovery plan without executing any side effects. Useful for ops verification before executing a live recovery.Closes #708
Changes
contracts/predictify-hybrid/src/recovery.rsNew type:
DryRunResult(contracttype) with fields:integrity_ok: bool— whether the validator passescan_recover: bool— whether reconstruction is possibleissues_detected: Vec<String>— detected problems (e.g.negative_total_staked,total_staked_mismatch,stake_overflow,too_few_outcomes,zero_end_time)planned_actions: Vec<String>— whatrecover_market_statewould do (e.g.no_action_needed,reconstruct_totals,skip_cannot_reconstruct_closed_or_cancelled)state_description: String— human-readable market stateNew function:
RecoveryManager::recovery_dry_run(env, market_id) -> Result<DryRunResult, Error>recover_market_statelogic but is strictly read-onlychecked_addwith explicit overflow detection for stake summationcontracts/predictify-hybrid/src/lib.rsPredictifyHybrid::recovery_dry_run(env, market_id) -> DryRunResultRecoveryManagerand panics on error (e.g. market not found)Tests (8 new tests in
recovery.rstest module)test_recovery_dry_run_market_not_foundtest_recovery_dry_run_valid_marketintegrity_ok = true,no_action_neededtest_recovery_dry_run_closed_marketcan_recover = falsetest_recovery_dry_run_cancelled_marketcan_recover = falsetest_recovery_dry_run_total_staked_mismatchtest_recovery_dry_run_stakes_map_sums_correctlyintegrity_oktest_recovery_dry_run_no_auth_requiredtest_dry_run_result_struct_fields