Skip to content

feat: emit EmergencyPauseTriggered alert on circuit-breaker activatio… - #668

Merged
Sadeequ merged 3 commits into
StellarFlow-Network:mainfrom
AbuJulaybeeb:feat/613-emergency-pause-triggered-broadcast
Jul 27, 2026
Merged

Sadeequ merged 3 commits into
StellarFlow-Network:mainfrom
AbuJulaybeeb:feat/613-emergency-pause-triggered-broadcast

Conversation

@AbuJulaybeeb

Copy link
Copy Markdown
Contributor

What was done
src/events/alerts.rs (new)
Centralised emit_emergency_pause_triggered function that publishes a structured Soroban event with:

Topics: ("emrg_alrt", "paus_trig") — two-level hierarchy for flexible backend filtering
Data payload: (caller: Address, reason_code: u32, timestamp: u64) — full identity, reason, and tamper-proof ledger timestamp
src/events/mod.rs (new)
Module root declaring the alerts sub-module, following the established pattern in contracts/price-oracle/src/event_topics.rs.

src/admin.rs (modified)
Added PAUSED_KEY — dedicated Instance-storage constant for the circuit-breaker flag
Added is_paused() — pure read helper (already consumed by lib.rs:assert_contract_is_active)
Added set_paused() — atomic write to the pause flag
Exposed consume_admin_action_nonce as a pub(crate) alias for descriptive call-site naming
src/lib.rs (modified)
Declared pub mod events;
Added set_paused(caller, paused, reason_code, nonce) — the contract entry point that (1) verifies admin identity, (2) consumes a replay-proof per-action nonce, (3) emits the alert before mutating state, and (4) flips the circuit-breaker storage flag
Why
The two-level topic layout (emrg_alrt / paus_trig) satisfies the "immediately discoverable" acceptance criterion: backend alert monitoring services can subscribe to the broad severity class or the precise event type without scanning all transaction logs.

Emitting the event before storage mutation guarantees the signal is always published, matching the security-first pattern used across the codebase.

Verification
Event structure manually inspected against contracts/price-oracle/src/event_topics.rs pattern
set_paused(paused=true) flow traced: auth → nonce → event emit → storage write
set_paused(paused=false) skips the alert emission (lift events are not high-priority alerts per spec)
Closes #613

@drips-wave

drips-wave Bot commented Jul 25, 2026

Copy link
Copy Markdown

@AbuJulaybeeb 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! 🚀

Learn more about application limits

… from merge corruption

- Add ethnum-patched local directory (v1.5.0 with transmute fix) committed to
  repo so CI can resolve it without network git access
- Update [patch.crates-io] in Cargo.toml to point to local ethnum-patched path
- Remove duplicate ContractError variants (StaleSequence, InvalidVarianceConfig,
  StaleTelemetryPayload, InsufficientLiquidityDepth) caused by failed merge
- Remove duplicate function stubs in lib.rs (get_last_update_timestamp,
  is_data_fresh, add_corridor_fees, _resolve_feed_metrics, get_feed_stake,
  get_corridor_fee_pool, get_stake, vote_revocation)
- Remove duplicate imports and function definitions in admin.rs, consensus.rs,
  and storage.rs from the same merge corruption
- Fix unclosed delimiters in lib.rs, admin.rs, consensus.rs

Closes StellarFlow-Network#613 (partial: build fix)
@AbuJulaybeeb
AbuJulaybeeb force-pushed the feat/613-emergency-pause-triggered-broadcast branch from 088418f to adf2dd5 Compare July 26, 2026 01:15
@Noble-Devbase Noble-Devbase mentioned this pull request Jul 27, 2026
@Sadeequ
Sadeequ merged commit 77b43bf into StellarFlow-Network:main Jul 27, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🔔 Emergency-Alerts | Immediate EmergencyPauseTriggered Broadcast

2 participants