Document memory expansion tracking for MSTORE/MSTORE8#41
Merged
Conversation
Co-authored-by: tcrypt25519 <212655132+tcrypt25519@users.noreply.github.com>
Co-authored-by: tcrypt25519 <212655132+tcrypt25519@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Implement memory length tracking for Mstore and Mstore8
Document memory expansion tracking for MSTORE/MSTORE8
Feb 8, 2026
tcrypt25519
marked this pull request as ready for review
February 8, 2026 15:44
There was a problem hiding this comment.
Pull request overview
Adds a task write-up describing how Jet should correctly track EVM memory expansion (in bytes, word-rounded) so memory_len becomes reliable for runtime bounds checks and future opcode work (especially around MSTORE/MSTORE8).
Changes:
- Documents EVM memory expansion sizing rules (word rounding, MSIZE byte tracking, and cost formula reference).
- Describes Jet’s current
memory_ptr/memory_len/memory_capmodel and the gap (stores don’t updatememory_len). - Proposes a shared expansion helper + integration points across memory-touching opcodes, with suggested test cases.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
tcrypt25519
added a commit
that referenced
this pull request
Feb 9, 2026
Track EVM memory length correctly by expanding memory before writes and updating memory_len to match EVM semantics (32-byte word-aligned). Implementation: - Add jet_mem_expand builtin that: * Checks for offset + size overflow * Rounds up to 32-byte boundaries * Updates memory_len monotonically * Reallocates and zeros new memory if needed - Hook MSTORE (32 bytes) and MSTORE8 (1 byte) to call expansion before write - Add memory_len field to TestContractRun for validation Tests (all passing): - MSTORE at offsets 0, 31, 32 expands to 32, 64, 64 bytes - MSTORE8 at offsets 0, 31, 32 expands to 32, 32, 64 bytes - Memory expansion is word-aligned and monotonic Closes #41 Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
tcrypt25519
added a commit
that referenced
this pull request
Feb 10, 2026
* Add EXP. * style: apply rustfmt formatting 🤖 * fixes * ci: force LLVM cache invalidation for dynamic linking The cache was hitting old entries built for static linking, causing "unable to find library -lLLVM-21" errors after adding the llvm21-1-prefer-dynamic feature to inkwell. Adding v2 prefix to force a fresh LLVM installation with dynamic libraries. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> * fix: install libllvm21 for dynamic linking support The llvm-21-dev package only provides static libraries and headers. When inkwell uses llvm21-1-prefer-dynamic, the linker needs the shared library libLLVM-21.so, which comes from the libllvm21 package. This was causing intermittent "unable to find library -lLLVM-21" errors because the cached LLVM installations didn't include the shared library. Changes: - Add libllvm21 to apt-get install in scripts/install-llvm.sh - Bump CI cache key to v3 to force fresh installation with shared lib Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> * feat: implement memory expansion tracking for MSTORE and MSTORE8 Track EVM memory length correctly by expanding memory before writes and updating memory_len to match EVM semantics (32-byte word-aligned). Implementation: - Add jet_mem_expand builtin that: * Checks for offset + size overflow * Rounds up to 32-byte boundaries * Updates memory_len monotonically * Reallocates and zeros new memory if needed - Hook MSTORE (32 bytes) and MSTORE8 (1 byte) to call expansion before write - Add memory_len field to TestContractRun for validation Tests (all passing): - MSTORE at offsets 0, 31, 32 expands to 32, 64, 64 bytes - MSTORE8 at offsets 0, 31, 32 expands to 32, 32, 64 bytes - Memory expansion is word-aligned and monotonic Closes #41 Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> * ci: bump LLVM cache to v4 * fix: use div_ceil for memory expansion rounding * docs: Add process doc for adding opcodes. --------- Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
tcrypt25519
added a commit
that referenced
this pull request
Feb 16, 2026
* Initial plan * Add memory length tracking writeup Co-authored-by: tcrypt25519 <212655132+tcrypt25519@users.noreply.github.com> * Refine opcode naming in writeup Co-authored-by: tcrypt25519 <212655132+tcrypt25519@users.noreply.github.com> * Update docs/tasks/memory-length-tracking-mstore.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: tcrypt25519 <212655132+tcrypt25519@users.noreply.github.com> Co-authored-by: Tyler Smith <mail@tcry.pt> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
tcrypt25519
added a commit
that referenced
this pull request
Feb 16, 2026
* Add EXP. * style: apply rustfmt formatting 🤖 * fixes * ci: force LLVM cache invalidation for dynamic linking The cache was hitting old entries built for static linking, causing "unable to find library -lLLVM-21" errors after adding the llvm21-1-prefer-dynamic feature to inkwell. Adding v2 prefix to force a fresh LLVM installation with dynamic libraries. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> * fix: install libllvm21 for dynamic linking support The llvm-21-dev package only provides static libraries and headers. When inkwell uses llvm21-1-prefer-dynamic, the linker needs the shared library libLLVM-21.so, which comes from the libllvm21 package. This was causing intermittent "unable to find library -lLLVM-21" errors because the cached LLVM installations didn't include the shared library. Changes: - Add libllvm21 to apt-get install in scripts/install-llvm.sh - Bump CI cache key to v3 to force fresh installation with shared lib Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> * feat: implement memory expansion tracking for MSTORE and MSTORE8 Track EVM memory length correctly by expanding memory before writes and updating memory_len to match EVM semantics (32-byte word-aligned). Implementation: - Add jet_mem_expand builtin that: * Checks for offset + size overflow * Rounds up to 32-byte boundaries * Updates memory_len monotonically * Reallocates and zeros new memory if needed - Hook MSTORE (32 bytes) and MSTORE8 (1 byte) to call expansion before write - Add memory_len field to TestContractRun for validation Tests (all passing): - MSTORE at offsets 0, 31, 32 expands to 32, 64, 64 bytes - MSTORE8 at offsets 0, 31, 32 expands to 32, 32, 64 bytes - Memory expansion is word-aligned and monotonic Closes #41 Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> * ci: bump LLVM cache to v4 * fix: use div_ceil for memory expansion rounding * docs: Add process doc for adding opcodes. --------- Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
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.
The issue calls for a clear plan to implement correct EVM memory expansion tracking, especially around MSTORE/MSTORE8 so runtime bounds checks can rely on
memory_len. This PR adds a focused write-up that ties EVM semantics to Jet’s current runtime design.memory_lenupdates.Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.