Skip to content

[Contract]: Timelock and multi-signer governance for sensitive admin operations #103

Description

@grantfox-oss

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

  • Sensitive operations can only take effect via queue-then-execute after the timelock
  • Optional M-of-N approvals enforced when signers are configured
  • Immediate-vs-timelocked operation split is documented and justified
  • Events emitted for queue/execute/cancel
  • Tests cover: early-execute rejection, threshold enforcement, cancel, full admin-rotation via governance, and pause/incident path
  • cargo test and cargo clippy --all-targets -- -D warnings pass

Pointers

Notes for contributors

Comment with the sensitive/immediate operation split and your timelock storage design before implementing. See CONTRIBUTING.md.

Metadata

Metadata

Labels

GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardThird CampaignCampaign: Third CampaignenhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions