-
Notifications
You must be signed in to change notification settings - Fork 22
Feat: Implement Emergency Circuit Breaker (Pause/Unpause) #45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Cedarich
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @gelluisaac, thanks for the PR! 👋
I reviewed the code, and it looks like this implementation addresses Issue #5 (Milestone-Based Escrow) rather than your assigned task, Issue #8 (Emergency Circuit Breaker).
While the milestone logic looks solid, we need to strictly follow the assigned issues to manage the project roadmap and avoid overlapping with other contributors.
Action Required:
Please strictly focus on the requirements for Issue #8 in this PR.
- Please stash or move your current Milestone code to a separate branch (e.g.,
feat/milestone-escrow) so it's safe for later. - On this branch, please revert the changes and implement the Circuit Breaker functionality as requested (Admin pause/unpause logic).
Let's get the Circuit Breaker merged first as planned. Thanks!
|
@Cedarich i think i missed up the issue earlier but i have updated it now |
|
Kindly resolve conflicts |
|
@Cedarich conflicts resolved |
|
@Cedarich PR ready |
|
@Cedarich PR awaiting your approval |
|
@Cedarich My PR has ready for a while now |
|
Hey @gelluisaac Thanks for working on this. You've got the core structure right with the ContractState enum and the admin function—that part looks solid. However, I ran into a few issues when I tried to test it locally that we need to fix before merging:
|
@Cedarich all test now are passing
|
|
@Cedarich you take a look at it |
Cedarich
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for contributing! LGTM

closes #39
This PR implements an Emergency Circuit Breaker (frequently known as a "Pausable" pattern) for the Vaultix smart contracts. This provides a vital safety layer, allowing administrators to freeze state-changing operations if a vulnerability is detected or during extreme market volatility.
PR Description: Emergency Circuit Breaker Implementation
🎯 Overview
This PR introduces the ability to pause and unpause contract functionality. By implementing an emergency stop mechanism, we mitigate the risk of fund loss during potential exploits, fulfilling the requirement for operational control over immutable code.
📋 Features Implemented
Storage Update: Added a ContractState enum (Active, Paused) to the contract's persistent storage.
Admin Control: Implemented set_paused(env, bool), restricted exclusively to the Admin via authentication checks.
Circuit Breaker Helper: Created an ensure_not_paused(env) helper function that validates the current state.
Function Level Security: Integrated the pause check into all state-changing operations:
create_escrow: Prevents new funds from entering the contract while paused.
release_funds / confirm_delivery: Freezes movement of existing assets during an investigation.
Non-Blocking Getters: All "view" or "getter" functions remain accessible while the contract is paused, ensuring users and external systems can still verify status and balances.
🏗️ Technical Implementation
Logic Flow
Auth: The set_paused function verifies the caller is the registered Admin.
Panic Mechanism: The check_active helper triggers a contract panic (revert) if the state is Paused, effectively blocking transaction completion.