Skip to content

security: stamp SchemaVersion at init to distinguish fresh v2 deploys - #52

Merged
mikewheeleer merged 1 commit into
Agentpay-Org:mainfrom
Jagadeeshftw:security/contracts-init-stamps-schema-version
Jun 24, 2026
Merged

security: stamp SchemaVersion at init to distinguish fresh v2 deploys#52
mikewheeleer merged 1 commit into
Agentpay-Org:mainfrom
Jagadeeshftw:security/contracts-init-stamps-schema-version

Conversation

@Jagadeeshftw

Copy link
Copy Markdown
Contributor

Summary

init now stamps the current storage schema version (CURRENT_SCHEMA = 2) into DataKey::SchemaVersion. A freshly deployed contract reports get_schema_version() == 2 without ever running a migration, while legacy v1 deployments still carry the implicit v1 default (get_schema_version's unwrap_or(1) is unchanged) and must run migrate_v1_to_v2(). Running that migration on a fresh v2 deploy correctly panics with MigrationVersionMismatch.

Closes #44

Test output

test result: ok. 25 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

Security notes

Stamping the schema version at init removes the ambiguity between a fresh v2 deploy and an un-migrated v1 state, preventing an accidental migration re-run from silently mutating a current-schema contract.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@Jagadeeshftw
Jagadeeshftw force-pushed the security/contracts-init-stamps-schema-version branch from 60f70e8 to 616ea63 Compare June 24, 2026 02:26
@mikewheeleer

Copy link
Copy Markdown
Contributor

smart — stamping SchemaVersion at init removes the pre-migration ambiguity. merging 👍

@mikewheeleer
mikewheeleer merged commit d02c983 into Agentpay-Org:main Jun 24, 2026
1 check failed
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.

Stamp SchemaVersion at init so fresh deploys are not mistaken for pre-migration v1

2 participants