feat(global): add admin-controlled circuit breaker to payout contracts#72
Merged
Kaylahray merged 5 commits intoMay 31, 2026
Merged
Conversation
|
@Oluwasuyi-Timilehin 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! 🚀 |
Kaylahray
requested changes
May 31, 2026
Contributor
Kaylahray
left a comment
There was a problem hiding this comment.
Hi @Oluwasuyi-Timilehin Please kindly delete all the .md files
Contributor
Author
|
@Kaylahray I already deleted the .md files |
Kaylahray
approved these changes
May 31, 2026
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 #52
Assignment: #52 [Global] Contract circuit breaker (emergency pause)
✅ IMPLEMENTATION COMPLETE
All requirements have been successfully implemented and tested. The circuit breaker (emergency pause) feature is now active in both RewardPool and QuestEngine contracts.
What Was Implemented
1. RewardPool Contract
File: contracts/reward-pool/src/types.rs
IsPausedto DataKey enum for emergency pause state storageFile: contracts/reward-pool/src/lib.rs
New Function:
set_pause(admin: Address, status: bool)true= paused,false= unpausedUpdated Function:
distribute_reward()2. QuestEngine Contract
File: contracts/quest-engine/src/types.rs
Adminto DataKey enum for admin storageIsPausedto DataKey enum for emergency pause state storageFile: contracts/quest-engine/src/lib.rs
Updated Function:
initialize()adminparameter:initialize(env: Env, admin: Address, token: Address, reward_pool: Address)New Function:
set_pause(admin: Address, status: bool)Updated Function:
review_submission()File: contracts/quest-engine/src/test.rs
adminparameter toinitialize()Test Results
RewardPool Tests: ✅ 22/22 PASSED
QuestEngine Tests: ✅ 22/22 PASSED
Total: 44/44 tests PASSED ✅
Acceptance Criteria Verification
✅ Requirement 1: All payouts fail instantly when is_paused is true
Implementation Details:
set_pause(admin, true)is called, the pause flag is set to truedistribute_reward()orreview_submission():let is_paused: bool = env.storage().instance().get(&DataKey::IsPaused).unwrap_or(false);assert!(!is_paused, "Contract is paused");✅ Requirement 2: Only the official Admin can toggle the pause
Implementation Details:
set_pause()verifies caller matches stored admin:admin.require_auth();File Modifications Summary
contracts/reward-pool/src/types.rsIsPausedto DataKeycontracts/reward-pool/src/lib.rsset_pause(), pause check indistribute_reward()contracts/quest-engine/src/types.rsAdminandIsPausedto DataKeycontracts/quest-engine/src/lib.rsinitialize(), addedset_pause(), pause check inreview_submission()contracts/quest-engine/src/test.rsHow to Test Your Implementation
Phase 1: Build Verification
Expected Result: Build succeeds with no errors
Phase 2: Run All Tests
Expected Result: All 44 tests pass ✅
Phase 3: Manual Verification (Example Scenarios)
Scenario A: Pause Blocks Payouts
set_pause(admin, true)distribute_reward()orreview_submission()Scenario B: Unpause Allows Payouts
set_pause(admin, true)→ Pausedset_pause(admin, false)→ Unpauseddistribute_reward()orreview_submission()Scenario C: Only Admin Can Pause
set_pause(Address B, true)where B ≠ ABranch Information
feat/circuit-breakerfeat(global): add admin-controlled circuit breaker to payout contractsDocumentation
A comprehensive testing guide has been created at:
CIRCUIT_BREAKER_TESTING_GUIDE.mdThis guide contains:
Code Quality
Security Features Implemented
✅ Admin-only access control with require_auth()
✅ Immediate panic on invalid operations
✅ No state corruption on failed calls
✅ Comprehensive error messages
✅ Proper storage isolation (Instance vs Persistent)
Code Style
✅ Follows Soroban SDK conventions
✅ Comprehensive inline comments
✅ Consistent with existing codebase
✅ Proper error handling
Testing Coverage
✅ 44 unit tests all passing
✅ Positive and negative test cases
✅ Edge cases covered
✅ Integration scenarios tested
#closes