feat(escrow): add admin cooldown for escrow critical actions - #975
Open
Miraclechukwuemeka wants to merge 2 commits into
Open
feat(escrow): add admin cooldown for escrow critical actions#975Miraclechukwuemeka wants to merge 2 commits into
Miraclechukwuemeka wants to merge 2 commits into
Conversation
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.
|
@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! 🚀 |
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
Implements a per-action cool-off window on the new
callora-escrowcontract to prevent rapid sequential abuse of a compromised or careless admin key holding escrowed funds.Changes
contracts/escrow/— newcallora-escrowcrate with:src/admin.rs— pure cooldown engine (get/set/guard/remaining/is_ready), identical design to thehotcontractsrc/errors.rs— 7 stable error codes (EscrowError)src/events.rs— topic Symbol constructorssrc/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 notesCargo.toml— addcontracts/escrowto workspace members/default-members; also addcontracts/adminto members (fixes pre-existing workspace gap)Design highlights
release,pause,unpause,rotateis independently cooled via aSymboltag, so an emergency pause is never blocked by a recent key rotation[1s, 30d], default 1 h; admin-controlledset_cooldownunwrap()on production pathsadmin.rsis pure bookkeeping;require_authlives inlib.rsentrypointsTesting
All checks pass:
cargo fmt --check,cargo clippy -- -D warnings,cargo test.Closes #914