feat: implement circuit breaker lock in Soroban contract#568
Open
Jennylila wants to merge 1 commit intoHahfyeex:Defaultfrom
Open
feat: implement circuit breaker lock in Soroban contract#568Jennylila wants to merge 1 commit intoHahfyeex:Defaultfrom
Jennylila wants to merge 1 commit intoHahfyeex:Defaultfrom
Conversation
|
@Jennylila 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! 🚀 |
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.
Overview
This PR implements a per-market circuit breaker for the Soroban prediction market contract to protect pools from anomalous betting activity. It adds persistent circuit-breaker state and rolling pool snapshots, blocks new bets once the breaker is triggered, emits an on-chain event for indexers, and provides admin recovery flows to reopen or force-resolve affected markets.
Related Issue
Closes #143
Changes
⚙️ Circuit Breaker Implementation
contracts/prediction_market/src/lib.rsDataKey::CircuitBreaker(u64)andDataKey::PoolSnapshot(u64)to contract storage.place_bet, compares the current pool against the snapshot from at least 60 seconds earlier.CIRCUIT_BREAKER_ACTIVEonce the breaker is active.breakercontract event with market ID, previous snapshot, current pool, and trigger timestamp.🛠️ Admin Recovery Functions
contracts/prediction_market/src/lib.rsreopen_market(market_id)to clear the breaker and refresh the snapshot baseline.force_resolve(market_id, outcome)to allow emergency admin resolution.🧪 Test Coverage
contracts/prediction_market/src/lib.rs📚 Documentation
README.md📦 Dependency / Audit Maintenance
contracts/prediction_market/Cargo.lockcargo auditpasses without high or critical advisories.Verification Results
CIRCUIT_BREAKER_ACTIVEafter triggerreopen_marketandforce_resolverequire admin auth and work correctlycargo auditpasses with zero high or critical advisoriesHow to Test