Commit 0b3a5180 authored by George Hotz's avatar George Hotz

don't keep calling m()

parent cc62f79f
......@@ -19,6 +19,7 @@ contract Challenge {
// the mips machine state transition function
IMIPS immutable mips;
IMIPSMemory immutable mem;
// the program start state
bytes32 immutable GlobalStartState;
......@@ -35,6 +36,7 @@ contract Challenge {
constructor(IMIPS imips, bytes32 globalStartState) {
owner = msg.sender;
mips = imips;
mem = imips.m();
GlobalStartState = globalStartState;
}
......@@ -52,7 +54,7 @@ contract Challenge {
for (uint32 i = 0; i < 32; i += 4) {
uint256 tv = uint256(val>>(224-(i*8)));
stateHash = mips.m().WriteMemory(stateHash, addr+i, uint32(tv));
stateHash = mem.WriteMemory(stateHash, addr+i, uint32(tv));
}
return stateHash;
}
......@@ -108,8 +110,8 @@ contract Challenge {
// confirm the finalSystemHash asserts the state you claim (in $t0-$t7) and the machine is stopped
// you must load these proofs into MIPS before calling this
// we disagree at the end
require(mips.m().ReadBytes32(finalSystemState, 0x30000800) == assertionRoot, "you are claiming a different state root in machine");
require(mips.m().ReadMemory(finalSystemState, 0xC0000080) == 0xDEAD0000, "machine is not stopped in final state (PC == 0xDEAD0000)");
require(mem.ReadBytes32(finalSystemState, 0x30000800) == assertionRoot, "you are claiming a different state root in machine");
require(mem.ReadMemory(finalSystemState, 0xC0000080) == 0xDEAD0000, "machine is not stopped in final state (PC == 0xDEAD0000)");
return newChallengeTrusted(startState, finalSystemState, stepCount);
}
......
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