Every privileged action in CleverVault (pause, add_asset, remove_asset, set_stale_threshold, set_max_active_tasks, update_admin, and any future upgrade/set_fee) is gated by a single admin key with immediate effect. A compromised or rushed admin key can whitelist a malicious asset, change parameters, or (with upgradeability) swap the WASM instantly, with no delay for users to react. For a contract custodying user funds, sensitive operations should pass through a timelock (and ideally require multiple signers), which is standard practice and a substantial governance feature.
Goal
Introduce a governance layer that routes a defined set of sensitive operations through a queue-then-execute timelock, with an optional M-of-N approval, while leaving routine operations responsive.
Proposed surface (signatures only)
queue_action(env, signer, action: GovAction, eta: u64) -> u64 returning an action id
execute_action(env, signer, action_id) — only after eta, only if approvals met
cancel_action(env, signer, action_id)
- Optional multi-sig:
set_signers(env, admin, signers: Vec<Address>, threshold: u32), and per-action approve_action(env, signer, action_id)
GovAction enum covering the sensitive set (pause config, asset whitelist changes, threshold/cap changes, admin rotation, upgrade, fee changes)
ActionQueuedEvent, ActionExecutedEvent, ActionCancelledEvent
Requirements and constraints
- A configurable minimum delay (e.g.
>= 1 hour, admin-set with a floor) between queue and execute.
- Decide and document which operations are "sensitive" (timelocked) vs "safe/immediate" (e.g.
pause may need to stay immediate for incident response; if so, keep pause immediate but timelock unpause, and justify).
- If multi-sig is included,
execute_action must verify threshold distinct approvals.
- Backwards compatibility: provide a migration/opt-in so the current single-admin deployment keeps working until governance is configured.
- All existing per-operation auth checks remain as the inner authorization.
Edge cases
- Execute before
eta (reject).
- Execute an already-executed or cancelled action (reject).
- Threshold not met (reject).
- Re-queue of an identical action (allowed, distinct ids).
- Admin rotation routed through governance must not lock the contract out (test the full rotation path).
Acceptance criteria
Pointers
Notes for contributors
Comment with the sensitive/immediate operation split and your timelock storage design before implementing. See CONTRIBUTING.md.
Every privileged action in CleverVault (
pause,add_asset,remove_asset,set_stale_threshold,set_max_active_tasks,update_admin, and any futureupgrade/set_fee) is gated by a single admin key with immediate effect. A compromised or rushed admin key can whitelist a malicious asset, change parameters, or (with upgradeability) swap the WASM instantly, with no delay for users to react. For a contract custodying user funds, sensitive operations should pass through a timelock (and ideally require multiple signers), which is standard practice and a substantial governance feature.Goal
Introduce a governance layer that routes a defined set of sensitive operations through a queue-then-execute timelock, with an optional M-of-N approval, while leaving routine operations responsive.
Proposed surface (signatures only)
queue_action(env, signer, action: GovAction, eta: u64) -> u64returning an action idexecute_action(env, signer, action_id)— only aftereta, only if approvals metcancel_action(env, signer, action_id)set_signers(env, admin, signers: Vec<Address>, threshold: u32), and per-actionapprove_action(env, signer, action_id)GovActionenum covering the sensitive set (pause config, asset whitelist changes, threshold/cap changes, admin rotation, upgrade, fee changes)ActionQueuedEvent,ActionExecutedEvent,ActionCancelledEventRequirements and constraints
>= 1 hour, admin-set with a floor) between queue and execute.pausemay need to stay immediate for incident response; if so, keep pause immediate but timelockunpause, and justify).execute_actionmust verifythresholddistinct approvals.Edge cases
eta(reject).Acceptance criteria
cargo testandcargo clippy --all-targets -- -D warningspassPointers
contracts/agent-vault/src/lib.rs: all admin-gated functions,VaultError,DataKey.Notes for contributors
Comment with the sensitive/immediate operation split and your timelock storage design before implementing. See CONTRIBUTING.md.