Skip to content

🛑 Implement Emergency Circuit Breaker (Pause/Unpause) #39

@Cedarich

Description

@Cedarich

Description
Add security functionality allowing the Admin to pause contract operations in case of a discovered vulnerability or network issue.

Requirements and Context

  • Background: Smart contracts are immutable, but operational control is needed for emergencies.
  • Problem: If a bug is found, we cannot stop users from depositing funds.
  • Success Criteria:
    • Implement set_paused(env, bool) (Admin only).
    • Add a check ensure_not_paused(env) to all state-changing functions (create, release).
  • Impact: Critical risk mitigation feature.

Suggested Execution

  1. Add State enum to storage (Active, Paused).
  2. Implement set_pause function requiring Admin auth.
  3. Add a helper fn check_active(env) that panics if state is Paused.
  4. Call check_active at the start of create_escrow and confirm_delivery.

Test and Commit

  • Testing: Pause the contract and verify create_escrow fails. Unpause and verify it succeeds.
  • Commit Message: feat(contract): implement emergency circuit breaker

Guidelines

  • Read-only functions (getters) should likely remain accessible even when paused.
  • PR Requirement: Closes #issue

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions