Description
Today there is no programmatic check that an upgrade does not regress major version. Encode CONTRACT_VERSION semver and have migrate_storage reject upgrades whose to.major < from.major.
Requirements and context
- Must be secure, tested, and documented
- Should be efficient and easy to review
- Relevant code:
Revora-Contracts/src/lib.rs, Revora-Contracts/src/test_storage_layout_version.rs
- Use a
(u32, u32, u32) triple for semver to avoid string parsing
Suggested execution
- Fork the repo and create a branch
git checkout -b feat/semver-upgrade-guard
- Implement changes
- Replace
CONTRACT_VERSION: u32 with (MAJOR, MINOR, PATCH)
- Add
assert_semver_forward(from, to) helper
- Reject downgrade with
VersionDowngrade
- Validate security and correctness assumptions
Test and commit
- Run tests
- Cover edge cases
- Same-version migration must reject
NoOpMigration
- Include test output and security notes
Example commit message
feat: enforce semver forward-only contract upgrades
Guidelines
- Minimum 95 percent test coverage
- Clear documentation
- Timeframe: 96 hours
Description
Today there is no programmatic check that an upgrade does not regress major version. Encode
CONTRACT_VERSIONsemver and havemigrate_storagereject upgrades whoseto.major < from.major.Requirements and context
Revora-Contracts/src/lib.rs,Revora-Contracts/src/test_storage_layout_version.rs(u32, u32, u32)triple for semver to avoid string parsingSuggested execution
git checkout -b feat/semver-upgrade-guardCONTRACT_VERSION: u32with(MAJOR, MINOR, PATCH)assert_semver_forward(from, to)helperVersionDowngradeTest and commit
cargo test --allNoOpMigrationExample commit message
feat: enforce semver forward-only contract upgradesGuidelines