Closed jonathanpwang closed 1 year ago
Previously the assembly block for snark verifier started mstore from memory offset 0. This does not respect Solidity's memory layout where 0x40 = 64 is reserved as a free memory pointer. See https://docs.soliditylang.org/en/latest/assembly.html#memory-safety
0
0x40 = 64
We make the assembly block memory safe by changing EvmLoader::new to start ptr from MEM_PTR_START = 0x80, and check in the assembly block preamble that mload(0x40) = 0x80. This means that the memory between 0 and 0x80 is never used.
EvmLoader::new
ptr
MEM_PTR_START = 0x80
mload(0x40) = 0x80
0x80
Previously the assembly block for snark verifier started mstore from memory offset
0
. This does not respect Solidity's memory layout where0x40 = 64
is reserved as a free memory pointer. See https://docs.soliditylang.org/en/latest/assembly.html#memory-safetyWe make the assembly block memory safe by changing
EvmLoader::new
to startptr
fromMEM_PTR_START = 0x80
, and check in the assembly block preamble thatmload(0x40) = 0x80
. This means that the memory between0
and0x80
is never used.