Repository navigation
feat(contracts): restrict dispute_milestone to active states and rese… - #1759
Merged
1nonlypiece merged 2 commits intoOct 24, 2026
Merged
1nonlypiece merged 2 commits into
1nonlypiece merged 2 commits into
Conversation
…t approvals - Restrict dispute_milestone to vaults in Active status (Error::NotActive) - Reject disputing while vault is paused (Error::Paused) - Reject disputing milestones already released (Error::MilestoneAlreadyReleased) - Require check-in record for dispute; reject missing records with Error::MilestoneNotDisputable - Clear DataKey::MilestoneApprovals(index) and DataKey::CheckIn(index) on dispute to reset M-of-N round - Emit milestone_disputed event with milestone index and cleared approvals count - Bundle destinations into Destinations struct to adhere to Soroban 10-parameter limit - Add comprehensive 2-of-3 threshold unit tests covering dispute and re-approval - Document dispute invariants, re-approval workflow, and dispute capping decision in README.md
…nflicts Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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 #1716
Summary
Closes #[ISSUE_NUMBER]
This PR resolves an issue in
contracts/accountability_vaultwheredispute_milestonecould be invoked on vaults in non-active or terminal states (Completed,Failed,Cancelled,Draft,Disputed), on milestones that had already been paid out (released = true), or while the vault was paused. Additionally,dispute_milestonepreviously left theMilestoneApprovals(index)storage intact, causing subsequent re-verification attempts by verifiers to permanently fail withError::AlreadyApproved(leading to unavoidable slash upon deadline expiration). Finally, missingCheckIn(index)records previously fell back to timestamp 0 instead of rejecting un-disputable milestones.Changes Made
State & Lifecycle Guards in
dispute_milestone:vault.status == VaultStatus::Active; rejects other statuses (Draft,Disputed,Cancelled,Failed,Completed) withError::NotActive.!Self::is_paused(&vault, now)); returnsError::Paused.milestone.released == truewithError::MilestoneAlreadyReleased.CheckIn(index): if absent, rejects withError::MilestoneNotDisputable(error code 32) instead of falling back to timestamp 0.now > verified_at + dispute_window -> Error::DeadlinePassed).Approval Round & Check-in Reset:
DataKey::MilestoneApprovals(index)andDataKey::CheckIn(index)upon successful dispute.milestone.verified = false, allowing verifiers to check in anew without encounteringError::AlreadyApproved.Event Emission:
milestone_disputedwith topics(Symbol::new(&env, "milestone_disputed"), creator)and data(index, cleared_count).SDK Parameter Limit Compliance:
success_destinationandfailure_destinationinto aDestinationsstruct (success: Address, failure: Address) forcreate_vault, keeping parameter count at 10 to comply with Soroban SDK's 10-parameter limit.Documentation & Architecture Notes:
Verification & Testing
1. Unit Tests (
cargo test --lib -p accountability_vault)All 42 tests in
accountability_vaultpass, including the 5 dedicated test scenarios using a 2-of-3 threshold setup:test_dispute_then_reverify: Verifies milestone → creator disputes → verifiers 0 and 1 check in again withoutAlreadyApproved→claim_milestonereleases funds tosuccess_destination.test_dispute_released_milestone_rejected: Releasing a milestone on an active multi-milestone vault prevents subsequent disputes withError::MilestoneAlreadyReleased.test_dispute_on_terminal_vault_rejected: Tests rejection withError::NotActiveacrossDraft,Disputed,Cancelled,Failed, andCompletedvaults.test_dispute_when_paused_rejected: Rejects dispute while emergency paused withError::Paused.test_dispute_without_checkin_record_rejected: Rejects dispute on milestones lacking aCheckInrecord withError::MilestoneNotDisputable.2. Linter & Formatter
cargo fmt --manifest-path contracts/Cargo.toml -- --checkpasses cleanly.cargo clippy --manifest-path contracts/Cargo.toml --target x86_64-pc-windows-gnu -- -D warningspasses without warnings.Testnet Evidence
Demonstration of contract deployment and invocation on Stellar Testnet: