Skip to content

Feat/storage walker upgrade#510

Open
dev-RAM11 wants to merge 4 commits into
RevoraOrg:masterfrom
dev-RAM11:feat/storage-walker-upgrade
Open

Feat/storage walker upgrade#510
dev-RAM11 wants to merge 4 commits into
RevoraOrg:masterfrom
dev-RAM11:feat/storage-walker-upgrade

Conversation

@dev-RAM11

Copy link
Copy Markdown
Contributor

Closes #467

Description

This PR introduces a secure, authenticated migrate_storage(from_version, to_version) path to handle explicit storage layout upgrades without relying on an implicit background walker.

The implementation respects Soroban's state management paradigms by acting as an explicitly triggered, version-aware dispatch table that rewrites legacy keys to new formats.

Changes Made

  • src/lib.rs:
    • Appended migrate_storage tightly gated by issuer.require_auth().
    • Implemented replay protection using a new LastMigrationCompletedAt data key.
    • Added a dispatch table architecture allowing targeted (from, to) version migrations.
    • Emits a mig_step event upon successful iteration for off-chain indexer auditing.
  • src/test_storage_layout_version.rs:
    • Created a dedicated test suite verifying successful migration runs.
    • Added explicit panic/error testing to ensure MigrationAlreadyApplied fires if an issuer attempts a replay.

Security & Execution Notes

  • Replay Protection: The LastMigrationCompletedAt state is permanently persisted after a successful run, mathematically blocking a second invocation of the same migration path.
  • Auditability: The event emission satisfies the requirement for indexer tracking without bloating the contract's on-chain storage footprint.
  • Test Coverage: Tested explicitly against the custom RevoraRevenueShare struct to avoid scoping errors.

Acceptance Criteria Met

  • Implemented migrate_storage(from, to) gated by issuer authentication.
  • Persisted last_migration_completed_at to block replays.
  • Added per-version migrators via a match-based dispatch table.
  • Included mig_step event emissions.
  • Built and passed the test suite covering both success and edge cases (MigrationAlreadyApplied).

dev-RAM11 added 4 commits May 30, 2026 19:07
- Add mod test_time_windows to lib.rs so tests are compiled and run
- Move set_report_window, set_claim_window, get_report_window,
  get_claim_window, and claim into contractimpl block
- Fix test_time_windows.rs compatibility issues
- All 41 boundary matrix tests passing

Closes RevoraOrg#374
test: cover report window inclusive boundaries and zero-width slot
@drips-wave

drips-wave Bot commented Jun 29, 2026

Copy link
Copy Markdown

@dev-RAM11 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

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.

Add contract-upgrade path with explicit storage walker to migrate legacy keys

1 participant