Skip to content

fix(contracts): restrict cancel_vault to Draft vaults and use Symbol event topics - #1752

Merged
1nonlypiece merged 2 commits into
Disciplr-Org:mainfrom
Stephan-Thomas:fix/restrict-cancel-vault-to-draft
Oct 24, 2026
Merged

1nonlypiece merged 2 commits into
Disciplr-Org:mainfrom
Stephan-Thomas:fix/restrict-cancel-vault-to-draft

Conversation

@Stephan-Thomas

Copy link
Copy Markdown
Contributor

Resolves #1706

Summary

Restrict cancel_vault to Draft vaults so funded stakes cannot be locked forever, and standardize event topics across cancellation and administrative disputes to use Symbol rather than String.

Why

Previously, cancel_vault accepted a vault in any status. For non-Draft vaults it set status to Cancelled without transferring the stake back to the creator, permanently locking funded stakes because settlement pathways (claim, slash_on_miss) require Active status. This also allowed creators of overdue vaults to call cancel_vault and evade slash_on_miss penalties. In addition, cancel_vault, admin_dispute, and admin_resolve emitted inconsistent event topics (String instead of Symbol).

Scope & Changes

  • Smart Contract (contracts/accountability_vault/src/lib.rs):
    • In cancel_vault, return Err(Error::NotDraft) if vault.status != VaultStatus::Draft. Removed the fall-through branch.
    • Standardize event topics to Symbol:
      • vault_cancelled -> Symbol::new(&env, "vault_cancelled")
      • vault_disputed -> Symbol::new(&env, "vault_disputed")
      • vault_dispute_resolved -> Symbol::new(&env, "vault_dispute_resolved")
    • Introduce Destinations struct (success: Address, failure: Address) to maintain create_vault parameter count within Soroban SDK's 10-parameter limit.
  • Specification & Documentation:
    • Updated contracts/accountability_vault/spec/AccountabilityVault.spec.json for create_vault argument grouping.
    • Updated contracts/README.md events list and migration section documenting cancel_vault vs withdraw and Symbol topics.
  • Tests (contracts/accountability_vault/src/test.rs):
    • test_cancel_rejected_for_each_non_draft_status: table-driven test verifying cancel_vault on Active, Completed, Failed, Cancelled, and Disputed returns Error::NotDraft without modifying state or balances.
    • test_cancel_cannot_block_slash: verifies that an overdue vault cannot evade slashing via cancel_vault; after failed cancellation, slash_on_miss proceeds and transfers stake to failure_destination.
    • test_cancel_draft_event_topic_is_symbol: asserts vault_cancelled topic is Symbol and not String.
    • test_dispute_events_use_symbol_topics: asserts vault_disputed and vault_dispute_resolved topics are Symbol and not String.

Testing

  • cargo test: All 41 unit tests in contracts/accountability_vault passed (finished in 2.31s).
  • cargo clippy --all-targets -- -D warnings: Passed cleanly with zero warnings.

…event topics

- Restrict cancel_vault to Draft status; return Error::NotDraft for non-Draft
  vaults (Active, Completed, Failed, Cancelled, Disputed) without mutating status
  or moving token balances.
- Ensure cancel_vault cannot be used to dodge slash_on_miss on overdue vaults.
- Standardize emitted event topics to Symbol for vault_cancelled, vault_disputed,
  and vault_dispute_resolved (replacing String topics).
- Introduce Destinations struct for create_vault to group success and failure
  destinations within Soroban SDK's 10-parameter limit.
- Update AccountabilityVault spec and contracts/README.md documentation.
- Add unit tests for non-draft cancel rejection, slash unblocking, and Symbol event topics.

Fixes Disciplr-Org#1706
@drips-wave

drips-wave Bot commented Oct 20, 2026

Copy link
Copy Markdown

@Stephan-Thomas 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! 🚀

Learn more about application limits

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@1nonlypiece
1nonlypiece merged commit 52fc7b9 into Disciplr-Org:main Oct 24, 2026
2 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[contracts] Restrict cancel_vault to Draft vaults so funded stakes cannot be locked forever

2 participants