Remove a word-alignment assumption from native EraVM assembly

Low-level code sometimes treats msize as the start of a fresh aligned buffer. Native EraVM measures memory expansion in bytes and can expose a high-water mark different from the EVM’s rounded word boundary.

Calculate the last byte touched

In a fixture with no higher prior allocation, storing a 32-byte word at offset 100 touches bytes 100 through 131. The native byte-granular end is 132; standard EVM word rounding produces 160. Keep the memory effect observable when testing because compiler optimization can remove unused operations.

mstore(100, 0)
let highWater := msize()

A helper expecting the next object at a multiple of 32 can therefore place data at an unexpected offset. Explicitly align the chosen pointer if the data format requires it and use the allocator conventions of the compiled code.

Measure on the compiled target

Existing Solidity memory allocation and optimization can already move the high-water mark. Compare minimal fixtures on the same compiler settings, and distinguish native EraVM assembly lowering from EVM bytecode executed by an interpreter. docs.zksync.io ZKsync documentation