Commit f6c7fa5b authored by clabby's avatar clabby

Fix offset bug when loading `exited` and `exitCode`

parent 98bfbd81
This diff is collapsed.
This diff is collapsed.
......@@ -103,9 +103,9 @@ contract MIPS {
from, to := copyMem(from, to, 4) // lo
from, to := copyMem(from, to, 4) // hi
from, to := copyMem(from, to, 4) // heap
let exitCode := shr(248, mload(from))
let exitCode := mload(from)
from, to := copyMem(from, to, 1) // exitCode
let exited := shr(248, mload(from))
let exited := mload(from)
from, to := copyMem(from, to, 1) // exited
from, to := copyMem(from, to, 8) // step
from := add(from, 32) // offset to registers
......@@ -137,7 +137,7 @@ contract MIPS {
// Compute the hash of the resulting MIPS state
out_ := keccak256(start, sub(to, start))
out_ := or(shl(248, status), and(not(shl(248, 0xff)), out_))
out_ := or(and(not(shl(248, 0xFF)), out_), shl(248, status))
}
}
......
......@@ -1558,7 +1558,7 @@ contract MIPS_Test is CommonTest {
/// 1. Exited with success (Invalid)
/// 2. Exited with failure (Panic)
/// 3. Unfinished
function vmStatus(MIPS.State memory state) internal pure returns (uint8 out_) {
function vmStatus(MIPS.State memory state) internal pure returns (uint256 out_) {
if (state.exited) {
if (state.exitCode == 0) {
return 0;
......@@ -1574,7 +1574,7 @@ contract MIPS_Test is CommonTest {
function outputState(MIPS.State memory state) internal pure returns (bytes32 out_) {
bytes memory enc = encodeState(state);
uint8 status = vmStatus(state);
uint256 status = vmStatus(state);
assembly {
out_ := keccak256(add(enc, 0x20), 226)
out_ := or(and(not(shl(248, 0xFF)), out_), shl(248, status))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment