Repository navigation
feat: implement claims processor contract with batch auto-processing … - #64
Merged
nonsobethel0-dev merged 1 commit intoJun 28, 2026
Conversation
…and oracle staleness validation
|
@Oluwasuyi-Timilehin 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! 🚀 |
nonsobethel0-dev
merged commit Jun 28, 2026
d880eaf
into
Parashield-Protocol:main
1 of 2 checks passed
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 #15
Description
Fixes a critical vulnerability in the claims-processor contract where auto_process lacked an initial idempotency guard.
Previously, if a keeper triggered auto_process multiple times simultaneously or sequentially for the same policy, the contract would skip internal state checks and repeatedly execute the evaluation pipeline. If downstream guards in the Policy Engine were ever altered or bypassed, this would result in duplicate claim entries, multiple cross-contract calls, and potential double-payouts/escrow draining.
This PR introduces a defensive persistent storage lookup at the absolute top of the auto_process pipeline, tracking the state natively within the claims-processor workspace.
Fix Details
claims-processor/src/types.rs: Added the AlreadyProcessed variant to the ClaimResult enum.
claims-processor/src/lib.rs:
Injected a strict persistent storage guard checking StorageKey::PolicyClaim(policy_id) at the entry point of auto_process.
Early-returns ClaimResult::AlreadyProcessed if an active or settled claim record already exists for the given policy ID.
claims-processor/src/test_integration.rs: Brought the soroban_sdk::testutils::Ledger trait into scope to resolve cross-contract time-warping compilation issues (.with_mut()).
claims-processor/src/test.rs: Updated test_double_process_idempotent to assert the newly expected, explicit AlreadyProcessed result instead of downstream result codes.
Related Issues
Closes #15
Testing Checklist
[x] Verified via local unit and integration tests.
[x] Compilation warnings cleared (unused variables handled).
Bash
Output from localized verification run:
running 11 tests
test test::test_expired_policy_no_payout ... ok
test test::test_good_rainfall_no_payout ... ok
test test::test_double_process_idempotent ... ok
test test::test_double_submit_claim_panics - should panic ... ok
test test::test_non_policyholder_cannot_submit_claim - should panic ... ok
test test::test_drought_trigger_pays_out ... ok
test test_integration::batch_processes_multiple_pending_claims ... ok
test test::test_manual_claim_flow ... ok
test test_integration::batch_skips_non_pending_claims ... ok
test test_integration::test_stale_oracle_data_rejected - should panic ... ok
test test_integration::test_fresh_oracle_data_accepted ... ok
test result: ok. 11 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.51s
Storage & Security Considerations
Uses the persistent storage tier to prevent expiration of claim records, ensuring the idempotency guard remains durable over long operational timelines.
Adheres to Soroban contract-isolation best practices by making the contract responsible for validation of its own internal process state.
#closes