Skip to content

feat(security): implement pause_transfers emergency circuit breaker (#2) - #190

Open
rupesh-kumar-sah wants to merge 1 commit into
Raegis-RWA:mainfrom
rupesh-kumar-sah:feat/pause-transfers-emergency-circuit-breaker
Open

rupesh-kumar-sah wants to merge 1 commit into
Raegis-RWA:mainfrom
rupesh-kumar-sah:feat/pause-transfers-emergency-circuit-breaker

Conversation

@rupesh-kumar-sah

Copy link
Copy Markdown

Summary

This PR implements an administrative emergency circuit breaker allowing authorized administrators to temporarily halt secondary market asset transfers (pause_transfers / resume_transfers) without disrupting administrative minting and issuance operations.

Key Changes

  • Storage State (src/lib.rs):
    • Added DataKey::IsPaused boolean flag to track transfer-specific pause state.
  • Administrative Circuit Breaker Controls (src/admin.rs):
    • pause_transfers(env, admin): Asserts admin authentication, prevents duplicate pause invocations, records DataKey::IsPaused = true, and emits transfers_paused event.
    • resume_transfers(env, admin): Asserts admin authentication, verifies currently paused, restores DataKey::IsPaused = false, and emits transfers_resumed event.
    • is_transfers_paused(env): Query helper reporting whether secondary market transfers are halted.
  • Transfer Gating (src/asset.rs):
    • Updated transfer function to assert !is_transfers_paused(&env) before balance mutations.
    • Verified mint_asset remains operational during transfer halts for administrative continuity.
  • Unit & Regression Tests (src/test.rs):
    • test_pause_transfers_succeeds_for_admin: Validates admin pause flow.
    • test_pause_transfers_reverts_for_non_admin: Confirms unauthorized callers are rejected.
    • test_pause_transfers_reverts_when_already_paused: Confirms idempotency guard (Error::AlreadyPaused).
    • test_resume_transfers_succeeds_for_admin: Validates resumption flow.
    • test_resume_transfers_reverts_when_not_paused: Confirms guard (Error::NotPaused).
    • test_transfer_blocked_and_mint_allowed_when_transfers_paused: Verifies transfers revert with Error::ContractPaused while mint_asset proceeds successfully.

Verification Proof

  • cargo test --lib: 227/227 tests passing 100% green.

Closes #2

- Add DataKey::IsPaused boolean to contract storage
- Implement pause_transfers and resume_transfers admin-guarded functions with events
- Assert transfer execution is blocked when transfers are paused
- Preserve mint_asset capability during transfer pauses for administrative operations
- Add 6 comprehensive unit tests in src/test.rs verifying full circuit breaker lifecycle

Closes Raegis-RWA#2
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.

Add a pause_transfers emergency circuit breaker

1 participant