Skip to content

State Production: protocol-migrate current-state Command #516

@aristidesstaffieri

Description

@aristidesstaffieri

Summary

Implement the current-state migration subcommand that builds protocol current state from deployment ledger forward, converging with live ingestion via the shared current-state CAS cursor.

Scope

  • CLI: ./wallet-backend protocol-migrate current-state --protocol-id SEP50 --start-ledger 50000000
  • Phase 1 — Validate: Verify protocol exists, classification_status = 'success'. Set current_state_migration_status = 'in_progress'. Initialize protocol_{ID}_current_state_cursor = start_ledger - 1.
  • Phase 2 — Process batches to tip (loop): Same structure as history migration, but: CAS-advances current_state_cursor instead. Writes only current state (no state changes). Batches must be committed in order (current state is additive — state at ledger N depends on N-1).
  • Phase 3 — Complete: Set current_state_migration_status = 'success'. Clean up.
  • Error handling: same pattern as history — set status to 'failed', resume from cursor + 1 on retry.
  • Processes ALL ledgers from --start-ledger to tip (not just retention window).

Dependencies

Reference

docs/feature-design/data-migrations.md (State Production section, line 619+)

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions