Skip to content

feat(escrow): add admin cooldown for escrow critical actions - #975

Open
Miraclechukwuemeka wants to merge 2 commits into
CalloraOrg:mainfrom
Miraclechukwuemeka:feat/escrow-admin-cooldown-914
Open

feat(escrow): add admin cooldown for escrow critical actions#975
Miraclechukwuemeka wants to merge 2 commits into
CalloraOrg:mainfrom
Miraclechukwuemeka:feat/escrow-admin-cooldown-914

Conversation

@Miraclechukwuemeka

Copy link
Copy Markdown

Summary

Implements a per-action cool-off window on the new callora-escrow contract to prevent rapid sequential abuse of a compromised or careless admin key holding escrowed funds.

Changes

  • contracts/escrow/ — new callora-escrow crate with:
    • src/admin.rs — pure cooldown engine (get/set/guard/remaining/is_ready), identical design to the hot contract
    • src/errors.rs — 7 stable error codes (EscrowError)
    • src/events.rs — topic Symbol constructors
    • src/lib.rs — contract entrypoints with 4 cooldown-guarded critical actions: release, pause, unpause, rotate_signer; plus two-step admin rotation (set_admin/accept_admin)
    • src/test.rs — 32 focused tests (bounds, isolation, window enforcement, auth gating, rotation)
  • docs/ESCROW_ADMIN_COOLDOWN.md — full API table, error codes, events, cool-off semantics, security notes
  • Cargo.toml — add contracts/escrow to workspace members/default-members; also add contracts/admin to members (fixes pre-existing workspace gap)

Design highlights

  • Per-action tracking — each of release, pause, unpause, rotate is independently cooled via a Symbol tag, so an emergency pause is never blocked by a recent key rotation
  • Configurable window[1s, 30d], default 1 h; admin-controlled set_cooldown
  • Overflow-safe — all arithmetic is saturating; no unwrap() on production paths
  • Auth at the edgeadmin.rs is pure bookkeeping; require_auth lives in lib.rs entrypoints

Testing

cargo test --package callora-escrow
running 32 tests ... test result: ok. 32 passed; 0 failed

All checks pass: cargo fmt --check, cargo clippy -- -D warnings, cargo test.

Closes #914

Implement per-action cool-off window on the escrow contract to prevent
rapid sequential abuse of a compromised or careless admin key.

- Add contracts/escrow/ crate (callora-escrow) modelled after the hot
  contract: same StorageKey/error/event layout, same cooldown engine.
- Critical actions guarded: release, pause, unpause, rotate_signer.
  Each action is independently cooled so blocking one never blocks
  another (e.g. a recent rotate cannot delay an emergency pause).
- Cooldown window is configurable [1s, 30d], default 1 h; admin-only
  set_cooldown with two view helpers (cooldown_remaining, is_ready).
- Two-step admin rotation (set_admin / accept_admin) unchanged from hot.
- 32 focused tests covering bounds, per-action isolation, window
  enforcement, auth gating, and two-step rotation.
- docs/ESCROW_ADMIN_COOLDOWN.md documents the full API, error codes,
  events, cool-off semantics, and security rationale.
- Add contracts/admin to workspace members (fixes pre-existing gap).

Closes CalloraOrg#914
Resolve Cargo.toml conflict: keep upstream's full members list and add
contracts/escrow to both members and default-members.
Accept upstream Cargo.lock and regenerate to include callora-escrow.
@drips-wave

drips-wave Bot commented Jul 28, 2026

Copy link
Copy Markdown

@Miraclechukwuemeka 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

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.

Add admin cooldown for escrow critical actions [b#089]

1 participant