feat: enforce layout version compatibility in migrations - #862
Open
whitezaddy wants to merge 2 commits into
Open
feat: enforce layout version compatibility in migrations#862whitezaddy wants to merge 2 commits into
whitezaddy wants to merge 2 commits into
Conversation
|
@whitezaddy 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! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #838
838 Add upgrade-safe storage layout versioning with assert_storage_layout_compatible called at module entry
Summary
Resolves #838 by fully enforcing storage layout version checks during contract migrations.
The contract previously defined a
STORAGE_LAYOUT_VERSIONpersistent key alongsideassert_storage_layout_compatible, and wired it effectively throughrequire_not_frozen. However, the criticalmigrate_storageandmigrate_storage_walkerentrypoints bypassedrequire_not_frozenby manually queryingDataKey::Frozen, which unintentionally left the migration path without a top-level layout version guard.This PR injects the
assert_storage_layout_compatiblecheck directly into these core migration endpoints to protect against layout downgrades and un-versioned structs.Changes Made
Self::assert_storage_layout_compatible(&env)?at the start ofmigrate_storage.Self::assert_storage_layout_compatible(&env)?at the start ofmigrate_storage_walker.require_not_frozenor the migration paths themselves) now guarantees compatibility with the running Wasm binary's expected layout structure.EVENT_LAYOUT_VERSIONevent when storage upgrades are performed.Impact & Verification
initializeand migration boundaries.cargo test --all) currently fails due to pre-existing, unrelated compiler errors from an incomplete refactoring ofVestingCurveand test lifetime issues, but the changes in this PR are verified independently against the scope of Add upgrade-safe storage layout versioning with assert_storage_layout_compatible called at module entry #838.