feat(remittance_split): harden import_snapshot validation pipeline#453
Merged
Baskarayelu merged 2 commits intoRemitwise-Org:mainfrom Apr 1, 2026
Merged
feat(remittance_split): harden import_snapshot validation pipeline#453Baskarayelu merged 2 commits intoRemitwise-Org:mainfrom
Baskarayelu merged 2 commits intoRemitwise-Org:mainfrom
Conversation
- Add new error variants: SnapshotNotInitialized (17), FutureTimestamp (18), OwnerMismatch (19), InvalidPercentageRange (20) with NatSpec doc comments - Add initialized flag guard (step 4) to import_snapshot - Replace inline percentage checks with validate_percentages delegation - Add future-timestamp guard (step 7) to import_snapshot - Add ownership mismatch guard (step 9) to import_snapshot - Update import_snapshot doc comment listing all 10 error variants - Harden verify_snapshot to mirror import_snapshot steps 2-7 - Update verify_snapshot doc comment listing all 6 error variants - Add 10 unit tests covering every rejection branch, state immutability, audit entries, schedule round-trip, and verify_snapshot parity - Fix pre-existing compile errors (SplitAuthPayload, clamp_limit, exported_at field, distribute_usdc signature in tests) - Update remittance_split/README.md with Snapshot Import Validation section Closes: remit-split-snapshot-import-hardening spec
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
Adds defensive validation to the snapshot import pipeline to reject malformed split data before it can corrupt split state. Invalid percentages, mismatched owners, and out-of-range fields are now caught and rejected at the import boundary — making the contract secure, auditable, and resilient to bad input.
Changes
remittance_split/src/lib.rsremittance_split/src/test.rsremittance_split/README.mdWhy This Matters
An unvalidated snapshot import is a direct path to corrupted split state — malformed percentages or mismatched owners could silently produce incorrect distributions. Catching these at the import boundary ensures state integrity is never contingent on the caller supplying clean data.
Test Output
Security Notes
How to Test
cargo test -p remittance_split— all tests must passUnauthorizedor equivalent errorChecklist
cargo test -p remittance_splitpassing with ≥95% coveragefeature/remit-split-snapshot-import-hardeningCloses #252