fix: strip motoko:stable-types section from wasm under --enhanced-migration#6073
Draft
alexandru-uta wants to merge 2 commits into
Draft
fix: strip motoko:stable-types section from wasm under --enhanced-migration#6073alexandru-uta wants to merge 2 commits into
alexandru-uta wants to merge 2 commits into
Conversation
…ration The `motoko:stable-types` custom section grows linearly with the migration chain (~280 KB at length 200, ~1.4 MB at length 1000) and duplicates the content of the `.most` file emitted under `--stable-types`. With enhanced orthogonal persistence the runtime system already enforces stable-type compatibility at upgrade time, so the embedded section is redundant for correctness and is now stripped from the wasm under `--enhanced-migration`. To keep compile-time validation (`validate_stab_sig`) and the `.most` file emit working when the wasm section is suppressed, the raw signature text is now carried in a separate, always-populated `stable_types_text` field on `motoko_sections`. This also fixes a pre-existing footgun on the classical codegen path where `--omit-metadata motoko:stable-types` silently disabled validation and the `.most` emit. The 3 lines of new logic live in the `metadata` helper in `compile_enhanced.ml`; everything else is plumbing for the decoupling. Verified with the full motoko test suite (1,221 tests across `fail/`, `run/`, `trap/`, `run-drun/`, `cmp/`) and against the long-rich benchmark at N=200/500/1000: wasm size shrinks by exactly the section size at every chain length, `.most` files are written with equivalent content, and compile time is unchanged. Made-with: Cursor
Contributor
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.
Strips the
motoko:stable-typescustom section from the wasm whenever--enhanced-migrationis active. The section grows linearly with the migration chain (~280 KB at length 200, ~1.4 MB at length 1000), duplicates the.mostfile content emitted under--stable-types, and under enhanced orthogonal persistence is redundant for upgrade safety because the runtime system already enforces stable-type compatibility at upgrade time. Long migration chains were pushing the wasm past the IC's ~1 MB metadata limits with this section alone.Behaviour preserved
validate_stab_sigstill runs (reads fromstable_types_text).--stable-typesstill writes.mostnext to the wasm (reads fromstable_types_text).js_compile_wasm) still returns the stable signature string.customModuleDecodemirrors the in-section text intostable_types_texton round-trip, so any consumer that loads a wasm that does embed the section still works unchanged.--enhanced-migrationbuilds keep embedding the section; behaviour there is unchanged.Made with Cursor