Commit 4d4cb63b authored by George Hotz's avatar George Hotz

use a sentinel to confirm output happened

parent 13727ecb
......@@ -110,7 +110,9 @@ 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(mem.ReadBytes32(finalSystemState, 0x30000800) == assertionRoot, "you are claiming a different state root in machine");
require(mem.ReadMemory(finalSystemState, 0x30000800) == 0x1337f00d, "state is not outputted");
require(mem.ReadBytes32(finalSystemState, 0x30000804) == assertionRoot, "you are claiming a different state root in machine");
require(mem.ReadMemory(finalSystemState, 0xC0000080) == 0x5EAD0000, "machine is not stopped in final state (PC == 0x5EAD0000)");
return newChallengeTrusted(startState, finalSystemState, stepCount);
......
......@@ -57,10 +57,12 @@ func Halt() {
}
func Output(output common.Hash, receipts common.Hash) {
ret := byteAt(0x30000800, 0x20)
ret := byteAt(0x30000804, 0x20)
copy(ret, output.Bytes())
rret := byteAt(0x30000820, 0x20)
rret := byteAt(0x30000824, 0x20)
copy(rret, receipts.Bytes())
magic := byteAt(0x30000800, 4)
copy(magic, []byte{0x13, 0x37, 0xf0, 0x0d})
Halt()
}
......
......@@ -295,8 +295,11 @@ except unicorn.UcError:
if not died_well:
raise Exception("program exitted early")
magic = struct.unpack(">I", mu.mem_read(0x30000800, 4))[0]
assert magic == 0x1337f00d
real_hash = binascii.hexlify(inputs[-0x40:-0x20])
compare_hash = binascii.hexlify(mu.mem_read(0x30000800, 0x20))
compare_hash = binascii.hexlify(mu.mem_read(0x30000804, 0x20))
print("compare", real_hash, "to computed", compare_hash)
if real_hash != compare_hash:
......
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