Skip to content

fix: cap governance timelocks#436

Draft
carrion256 wants to merge 2 commits into
spr/refactor/vault-ergonomics/4f330057from
audit/governance-a040
Draft

fix: cap governance timelocks#436
carrion256 wants to merge 2 commits into
spr/refactor/vault-ergonomics/4f330057from
audit/governance-a040

Conversation

@carrion256

@carrion256 carrion256 commented May 15, 2026

Copy link
Copy Markdown
Collaborator

Summary

Fixes governance timelock-model findings in governance-control-plane:

  • A-040 / Nexus 890b1bbf-ea61-47f3-ac17-383678f0d713: TimelockConfig could be raised to u64::MAX immediately, making later reductions practically unrecoverable.
  • A-092 / Nexus 98dbd8f7-6f6b-4096-b917-c01f9fd68e35: load_timelocks lazily materialized DataKey::Timelocks from the legacy scalar fallback during getter/view-style paths.

This PR keeps the timelock-model fixes consolidated in the existing governance timelock PR: it caps Soroban governance timelocks at 30 days, matching the NEAR vault governance upper bound, and makes legacy/fallback timelock reads side-effect-free while preserving explicit SetTimelock write behavior.

Changes

  • Replace Soroban governance MAX_TIMELOCK_NS = u64::MAX with 30 * DAY_NS.
  • Add regression test proving submit_set_timelock(..., TimelockKind::TimelockConfig, u64::MAX) returns GovernanceError::TimelockOutOfBounds and leaves the current TimelockConfig plus pending queue unchanged.
  • Make load_timelocks return Timelocks::from_default(default_ns) without writing DataKey::Timelocks when only the legacy DataKey::TimelockNs scalar exists.
  • Add regression test proving timelock_ns and timelocks getters do not materialize missing Timelocks storage.

Verification

Folded A-092 commit: 0358c07b9340ad820092dc8918a79238b8a241ec.

  • cargo test -p templar-soroban-governance timelock_config_rejects_u64_max_without_mutating_state -- --nocapture
  • cargo test -p templar-soroban-governance timelock_getters_do_not_materialize_missing_timelocks_storage -- --nocapture
  • cargo test -p templar-soroban-governance -- --nocapture (31 passed)
  • git diff --check origin/audit/governance-a040..HEAD
  • just -f contract/vault/soroban/justfile size-budget-check

RED evidence recorded locally before fixes:

  • A-040: focused regression failed with left: Ok(1), proving u64::MAX was accepted immediately.
  • A-092: focused getter regression failed because timelock_ns wrote DataKey::Timelocks storage while reading from fallback state.

Runtime deploy WASM size from current folded branch size gate:

  • 93961 bytes / 91.76 KiB
  • Budget: 131072 bytes / 128 KiB

This change is Reviewable

@coderabbitai

coderabbitai Bot commented May 15, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: e3b742eb-4bd1-4a78-9e25-ec1b9d10f0a3

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch audit/governance-a040

Comment @coderabbitai help to get the list of available commands and usage tips.

@carrion256 carrion256 force-pushed the audit/governance-a040 branch from 0358c07 to f9d5fb0 Compare May 18, 2026 14:43
@carrion256

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 18, 2026

Copy link
Copy Markdown
Contributor
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@carrion256 carrion256 force-pushed the audit/governance-a040 branch from f9d5fb0 to 7bf07e8 Compare May 19, 2026 08:28
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.

1 participant