0xMiden / 0xMiden/compiler

Wasm memory.size/memory.grow use Miden heap state instead of the module memory declaration

Open
#1,184 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
115
Forks
84
Avg merge
1d 8h
Merged PRs (30d)
15

Description

## Summary

The Wasm translator maps `memory.size` and `memory.grow` to Miden heap intrinsics. This can make a Wasm module observe heap page state rather than the module's declared linear memory size and max.

Affected commit checked: `17eb665e52f3c2a519f8aa58c7dff1335ba63887` on `next`.

## Steps to reproduce

Public repro:

https://github.com/Kuhai9801/miden-int32-to-uint-ci/actions/runs/27597467547

The repro models a Wasm memory declared with one page and compares that with the current zero-initialized heap-backed size.

## Expected behavior

For a module with one declared memory page, `memory.size` should report `1`. `memory.grow` should respect the Wasm memory maximum.

## Actual behavior

The heap-backed path reports `0` for the same initial state in the repro, and growth is checked against heap capacity rather than the Wasm memory declaration.

## Notes

`frontend/wasm/src/code_translator/mod.rs` maps `Operator::MemorySize` and `Operator::MemoryGrow` to `builder.mem_size` / `builder.mem_grow`. The parsed Wasm memory declaration appears not to be the source of truth for these operations.

Contributor guide

Open the contributing guide

Research direction

The issue is in `frontend/wasm/src/code_translator/mod.rs` where `Operator::MemorySize` and `Operator::MemoryGrow` are mapped to `builder.mem_size` and `builder.mem_grow`. First, examine the Wasm memory declaration parsing to understand the intended size and max. Then, modify the translation to use these declared values instead of the Miden heap state. The repro test linked shows the expected behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust, wasm
Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
65/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.