Skip to content

Commit

Permalink
Import VMStatus from DisputeTypes.sol
Browse files Browse the repository at this point in the history
  • Loading branch information
ImTei committed Mar 22, 2024
1 parent c72af6a commit f4648d4
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions rvsol/test/RISCV.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ import {Test} from "forge-std/Test.sol";
import {RISCV} from "src/RISCV.sol";
import {PreimageOracle} from "@optimism/src/cannon/PreimageOracle.sol";
import {CommonTest} from "./CommonTest.sol";
// FIXME: somehow this import gives a multiple declaration error
// This import is for the VMStatus
// import "@optimism/src/libraries/DisputeTypes.sol";
import "@optimism/src/libraries/DisputeTypes.sol";

contract RISCV_Test is CommonTest {
/// @notice Stores the VM state.
Expand Down Expand Up @@ -2385,22 +2383,21 @@ contract RISCV_Test is CommonTest {
/// 1. Exited with success (Invalid)
/// 2. Exited with failure (Panic)
/// 3. Unfinished
// TODO: import DisputeTypes.sol. For some reason, import is not working
function vmStatus(State memory state) internal pure returns (uint8 out_) {
function vmStatus(State memory state) internal pure returns (VMStatus out_) {
if (!state.exited) {
return 3; // VMStatuses.UNFINISHED
return VMStatuses.UNFINISHED;
} else if (state.exitCode == 0) {
return 0; // VMStatuses.VALID
return VMStatuses.VALID;
} else if (state.exitCode == 1) {
return 1; // VMStatuses.INVALID
return VMStatuses.INVALID;
} else {
return 2; // VMStatuses.PANIC
return VMStatuses.PANIC;
}
}

function outputState(State memory state) internal pure returns (bytes32 out_) {
bytes memory enc = encodeState(state);
uint8 status = vmStatus(state);
VMStatus status = vmStatus(state);
assembly {
out_ := keccak256(add(enc, 0x20), 362)
out_ := or(and(not(shl(248, 0xFF)), out_), shl(248, status))
Expand Down

0 comments on commit f4648d4

Please sign in to comment.