Add unified circuit-breaker safety layer: guardian-bot daemon, per-contract façade, auto-trip on health degradation, and zero-liquidity guard - #888
Merged
Conversation
…liquidity guard
- Introduce propchain-traits::circuit_breaker::{CircuitBreaker, PauseReason}
and migrate contracts off ad-hoc PauseFlags/set_pause_state
- Add guardian-bot.rs daemon watching oracle drift, auto-pausing bridge
on detected anomalies, with deployment docs
- Wire rate limiter to auto-trip on account_block_request_count and
failed_signatures_window_count thresholds, with cooldown/recovery
- Add guarded divide returning ZeroLiquidity error for empty-pool
DEX utilisation queries instead of aborting
Closes MettaChain#822, MettaChain#818, MettaChain#819, MettaChain#823
|
@jerrydanzaria5-svg 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.
Summary
This PR introduces a unified pause/circuit-breaker safety layer for
PropChain contracts. It consolidates previously ad-hoc pause governance into
a single trait-based façade, adds an off-chain guardian daemon that watches
oracle drift and chain health, wires automatic rate-limiter tripping into
that health signal, and hardens DEX liquidity queries against
division-by-zero on fresh/empty pools.
Changes
Circuit-breaker façade (
propchain-traits)propchain-traits::circuit_breaker::{CircuitBreaker, PauseReason}as a single uniform trait, replacing the per-contract
PauseFlags,set_pause_state, andc.is_pausedpatterns.behavior and monitoring are consistent across the codebase.
Guardian-bot daemon (
scripts/)scripts/guardian-bot.rsthat subscribes to chainevents, watches oracle price feeds, and pauses the bridge automatically on
detected drift.
operational expectations.
Automatic rate-limiter tripping
account_block_request_countandfailed_signatures_window_countand automatically trips into a pausedstate when thresholds are breached.
Zero-liquidity guard
guarded divide that returns an explicit
ZeroLiquidityerror instead ofpanicking/aborting on fresh or empty pools.
Closes
scripts/#822 — Ship a reference guardian-bot implementation inscripts/propchain-traits#818 — Add per-contract circuit-breaker façade inpropchain-traitsTesting
migrated contracts.
a pause.
ZeroLiquidityrather than aborting.