Security: contract migration runbook does not document rollback limitations [SEC-H05] #443
Labels
No labels
agent:fix_bugfix
agent:fix_conflicts
agent:fix_security
agent:gap_analysis
agent:implement
agent:implement
agent:implement
agent:open_issues
agent:ready
agent:research
agent:security_audit
agent:verify
architecture
backend
blocker:hybrid
blocker:launch
blocker:limit-orders
blocker:v2
block:log_only
block:security
bug
ci
contracts
correctness
deploy
dev
devops
docs
documentation
duplicate
e2e
enhancement
epic
feature
frontend
functional-completion
gas
good first issue
governance
help wanted
high-risk
hooks
hybrid
indexer
infra
infrastructure
integrators
invalid
launch-blocker
limit-orders
localnet
localterra
low priority
missing-implementation
needs-design
ops
performance
priority
high
priority
medium
product
qa
QA
question
ready
ready
research
scripts
security
security-hardening
smartcontracts
tech-debt
testing
ux
UX
v2
verification
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
code/cl8y-dex-terraclassic#443
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
smartcontracts/tests/src/migration_tests.rsprovides migration state-preservation tests that simulate upgrades via cw2 version downgrade, covering factory, pair, and fee-discount. These satisfy the "rehearsed" component. However,docs/runbooks/wasm-admin-migration.mdhas no "rollback limitations" section. The runbook covers pre-flight, migration steps, automated regression, and admin rotation, but does not document what operators cannot do after a migration: e.g., that rolling back requires migrating to the prior code ID (if still stored on chain), that a failed migration with cleared admin cannot be undone, or that indexer DB migrations have separate down.sql files underindexer/migrations/revert/. Thedocs/runbooks/launch-checklist.mdrollback section says only "CosmWasm upgrades/migrations are out of band for this runbook; document admin keys and wasm migration policy separately."What Was Checked
smartcontracts/tests/src/migration_tests.rslines 1-57: confirms migration tests exist, use cw2 version downgrade simulation (not archived prior wasm), and cover factory, pair, fee-discount. Tests run viamake test-contracts.docs/runbooks/wasm-admin-migration.mdread in full: sections are Pre-flight, Migration/upgrade steps, Automated regression, Commands, Admin rotation, References. No Rollback or Rollback limitations section exists.docs/runbooks/launch-checklist.mdrollback section (lines 177-181): 2 lines only. Acknowledges CosmWasm migrations are out of band and says to pause via factory for incidents. No rollback limitation detail.docs/testing.md: mentionsindexer/migrations/revert/down.sql files for indexer DB migrations. Not cross-linked from wasm-admin-migration.md.Expected (per checklist)
The migration runbook includes a "rollback limitations" note covering:
(1) contract migration can be reversed by migrating back to the prior code ID if admin is retained and code ID is still on-chain;
(2) if admin is cleared or code ID is purged, the contract cannot be rolled back;
(3) indexer DB migrations have separate down.sql files under
indexer/migrations/revert/for manual rollback;(4) what to do if a migration is partially applied (e.g., factory migrated but pair not yet).
Actual
No rollback limitations are documented in the wasm-admin-migration.md runbook or the launch-checklist.md rollback section. Operators encountering a failed or bad migration have no documented guidance on what can or cannot be reversed.
Evidence
docs/runbooks/wasm-admin-migration.md: no rollback or rollback-limitations sectiondocs/runbooks/launch-checklist.mdlines 177-181: only "pause via factory" and "out of band" acknowledgement for CosmWasm migrationsSuggested Fix
Add a Rollback and limitations section to
docs/runbooks/wasm-admin-migration.mdcovering:(1) contract migration reversal path (migrate back to prior code ID using stored code, confirm code ID is still on chain with
terrad query wasm code <id>);(2) irrecoverable cases (admin cleared, code ID purged, or governance key lost);
(3) indexer DB migration rollback using
indexer/migrations/revert/down.sql files (referencedocs/testing.md);(4) partial-migration recovery steps when only some contracts have been migrated. Cross-link from
docs/runbooks/launch-checklist.mdrollback section.Verification Checklist
docs/runbooks/wasm-admin-migration.mdcontains a rollback limitations section covering contract migration reversal and irrecoverable casesindexer/migrations/revert/docs/runbooks/launch-checklist.mdrollback section cross-links to the wasm-admin-migration rollback limitationsLabels
security,pre-launchCc: @PlasticDigits
mentioned in issue #381
mentioned in merge request !975
mentioned in commit
5058c61b95mentioned in commit
c0bd454668Went through the SEC-H05 rollback-limitations MR (
8c71c202, !975) — the runbook content holds up and the verification all passes for me.make verify-issue-443→ 8/8 PASS, including the livemake test-contracts(the SEC-C14 state-preservation rehearsal stays green; the migration_tests.rs change is a comment-only re-point to the new#rollback-and-limitations-sec-h05anchor, so no behavior change there).Walked the actual rollback section in wasm-admin-migration.md, not just the grep markers — it covers everything the issue asked:
terrad query wasm code), confirm you still hold admin (contract_info.admin), migrate back to the prior code_idOne thing before it lands: the MR is cannot_be_merged right now, but it's just a rebase — the conflict is the Makefile .PHONY/target-list line (it and !976 both add their verify-issue / check-docs targets to the same region, and main moved on since the branch was cut). The two SEC-H05/H09 MRs will also collide with each other on that line, so they want sequential rebasing. Content-wise, good to merge / good to close from my side once it's rebased.
@PlasticDigits
Verification — GitLab #443 (SEC-H05)
Result: PASS — all acceptance criteria satisfied; no repo changes required.
Checklist
wasm-admin-migration.mdrollback limitations section (reversal + irrecoverable cases)make verify-issue-443step "rollback section covers contract reversal path" + "rollback section documents irrecoverable cases"; manual read ofdocs/runbooks/wasm-admin-migration.md§ Rollback and limitations (SEC-H05)indexer/migrations/revert/down.sqlmake verify-issue-443step "rollback section references indexer revert down.sql"; confirmed 3.down.sqlfiles exist underindexer/migrations/revert/launch-checklist.mdrollback section cross-links migration limitationsmake verify-issue-443step "launch runbook rollback cross-links migration limitations"; manual read ofdocs/runbooks/launch-checklist.md§ Rollback / incident (line 199)make verify-issue-443—make test-contracts(388 tests passed)make check-wasm-migration-rollback-docsviamake verify-issue-443skills/AGENTS_WASM_MIGRATION_ROLLBACK.mdexistsCommand
Coverage confirmed in docs
code_idwhen admin intact and wasm still on chain (terrad query wasm code <id>)..down.sqlunderindexer/migrations/revert/, cross-linked todocs/testing.md.Closing as verified.
mentioned in commit
9313da2fb4mentioned in merge request !976