Skip to content

feat(revenue_pool): expire and protect pending emergency drain proposals (#1160) - #1382

Closed
lienhoatienphung-svg wants to merge 1 commit into
CalloraOrg:mainfrom
lienhoatienphung-svg:feature/1160-emergency-drain-expiry
Closed

lienhoatienphung-svg wants to merge 1 commit into
CalloraOrg:mainfrom
lienhoatienphung-svg:feature/1160-emergency-drain-expiry

Conversation

@lienhoatienphung-svg

Copy link
Copy Markdown

Closes #1160

Summary

Protects pending emergency drain proposals from remaining executable indefinitely or being silently overwritten:

  1. Adds EMERGENCY_DRAIN_GRACE_PERIOD_SECONDS (24 hours) and expires_at: u64 to PendingEmergencyDrain.
  2. Emits a drain_replaced event carrying (previous_drain, new_drain) whenever propose_emergency_drain replaces an existing pending proposal without prior cancellation.
  3. Rejects execution after expires_at with RevenuePoolError::EmergencyDrainExpired (code 26), treats expired proposals as inactive in get_pending_emergency_drain, and provides expire_emergency_drain to purge expired proposals from instance storage with an emergency_drain_expired audit event.

Acceptance Criteria Mapping

  • Second propose without cancel fails or emits replacement event: propose_emergency_drain emits drain_replaced with (previous, new) when overwriting an existing proposal (reproposal_emits_drain_replaced_event).
  • Execution after expiry fails and clears the proposal: execute_emergency_drain fails with RevenuePoolError::EmergencyDrainExpired once now > drain.expires_at, get_pending_emergency_drain returns None, and expire_emergency_drain purges the expired snapshot (execute_after_expiry_fails_and_clears_proposal).
  • PendingEmergencyDrain exposes expiry: pub expires_at: u64 is stored and returned by get_pending_emergency_drain.
  • Tests cover both behaviours: Added unit tests in contracts/revenue_pool/src/test_emergency.rs and updated test_error_codes.rs / docs/ERROR_CODES.md.

Validation

  • cargo test -p callora-revenue-pool emergency

Payout Wallet (Base Mainnet USDC / EVM): 0x3806cd592a508d1992Ed007C2F53de251C2E7452

@lienhoatienphung-svg
lienhoatienphung-svg force-pushed the feature/1160-emergency-drain-expiry branch from b18f48a to 763e0c5 Compare October 16, 2026 07:47
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.

Expire and protect pending emergency drain proposals

2 participants