Commit 97433e28 authored by George Hotz's avatar George Hotz Committed by George Hotz

allow mips to overwrite the output

parent 954eea32
......@@ -92,9 +92,8 @@ ID=0 BLOCK=13284469 npx hardhat run scripts/assert.js --network hosthat
# compute real MIPS checkpoint
minigeth/go-ethereum 13284491 && mipsevm/mipsevm 13284491
# alternate fake MIPS checkpoint
# alternate fake MIPS checkpoint (will modify output file)
BASEDIR=/tmp/cannon_fault minigeth/go-ethereum 13284491 && OUTPUTFAULT=1 BASEDIR=/tmp/cannon_fault mipsevm/mipsevm 13284491
python3 -c 'f="/tmp/cannon_fault/0_13284491/output";o=b"\xba\xba\xba\xba"+open(f, "rb").read()[4:]; open(f, "wb").write(o)'
# start challenge
BASEDIR=/tmp/cannon_fault BLOCK=13284491 npx hardhat run scripts/challenge.js --network hosthat
......
package main
import (
"bytes"
"encoding/binary"
"fmt"
"io/ioutil"
"os"
......@@ -94,7 +96,27 @@ func main() {
}
if target == -1 {
output_filename := fmt.Sprintf("%s/output", root)
outputs, err := ioutil.ReadFile(output_filename)
check(err)
real := append([]byte{0x13, 0x37, 0xf0, 0x0d}, outputs...)
output := []byte{}
for i := 0; i < 0x44; i += 4 {
t := make([]byte, 4)
binary.BigEndian.PutUint32(t, ram[uint32(0x30000800+i)])
output = append(output, t...)
}
if bytes.Compare(real, output) != 0 {
fmt.Println("MISMATCH OUTPUT, OVERWRITING!!!")
ioutil.WriteFile(output_filename, output[4:], 0644)
} else {
fmt.Println("output match")
}
WriteCheckpoint(ram, fmt.Sprintf("%s/checkpoint_final.json", root), lastStep)
}
// step 2 (optional), validate each 1 million chunk in EVM
......
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