🔴 Critical · contracts/token-factory/src/lib.rs:831-849
Description
CURRENT_SCHEMA_VERSION is 1, and migrate's only branch is if on_chain_version < CURRENT_SCHEMA_VERSION stamping the version onto pre-versioned state. The README's own "Adding a new migration" section documents the intended pattern for a future N → N+1 step, but that pattern has never actually been exercised in this codebase because there has only ever been one version. The very first real schema change will be the first time this migration framework is tested against anything beyond the trivial 0→1 bootstrap case, which is exactly the wrong time to discover the pattern doesn't compose (e.g., does calling migrate on a contract that's 2 versions behind correctly apply both incremental steps, or does the if on_chain_version < CURRENT_SCHEMA_VERSION structure as documented actually only support a single flat jump, silently skipping intermediate per-version logic if future contributors follow the README's if on_chain_version < N+1 { ... } pattern literally and stack multiple such blocks without chaining on_chain_version reads correctly between them)?
Tasks
Acceptance Criteria
🔴 Critical ·
contracts/token-factory/src/lib.rs:831-849Description
CURRENT_SCHEMA_VERSIONis1, andmigrate's only branch isif on_chain_version < CURRENT_SCHEMA_VERSIONstamping the version onto pre-versioned state. The README's own "Adding a new migration" section documents the intended pattern for a futureN → N+1step, but that pattern has never actually been exercised in this codebase because there has only ever been one version. The very first real schema change will be the first time this migration framework is tested against anything beyond the trivial 0→1 bootstrap case, which is exactly the wrong time to discover the pattern doesn't compose (e.g., does callingmigrateon a contract that's 2 versions behind correctly apply both incremental steps, or does theif on_chain_version < CURRENT_SCHEMA_VERSIONstructure as documented actually only support a single flat jump, silently skipping intermediate per-version logic if future contributors follow the README'sif on_chain_version < N+1 { ... }pattern literally and stack multiple such blocks without chainingon_chain_versionreads correctly between them)?Tasks
#[cfg(test)]-only "version 2" migration step totest.rs(not shipped in productionlib.rs) that adds a hypothetical new field, to prove out the multi-step migration pattern end-to-end without committing to a real schema change prematurely.0(pre-versioning) and assertsmigratecorrectly walks through both the 0→1 and the synthetic 1→2 steps in one call, ending at the synthetic version 2 with all fields correctly defaulted.1and confirmsmigrateapplies only the remaining 1→2 step, not re-running 0→1 logic.ifblock must read and compare against the currenton_chain_versionat the time it runs, not a value captured before any migration step executed).Acceptance Criteria