Commit eb492186 authored by George Hotz's avatar George Hotz

getting not stopped in final state, need to sync regs i think

parent f9ef6ce0
...@@ -32,6 +32,7 @@ func main() { ...@@ -32,6 +32,7 @@ func main() {
ZeroRegisters(ram) ZeroRegisters(ram)
LoadMappedFileUnicorn(mu, "../mipigo/golden/minigeth.bin", ram, 0) LoadMappedFileUnicorn(mu, "../mipigo/golden/minigeth.bin", ram, 0)
WriteCheckpoint(ram, root, -1)
LoadMappedFileUnicorn(mu, fmt.Sprintf("%s/input", root), ram, 0xB0000000) LoadMappedFileUnicorn(mu, fmt.Sprintf("%s/input", root), ram, 0xB0000000)
mu.Start(0, 0x5ead0004) mu.Start(0, 0x5ead0004)
......
const { expect } = require("chai"); const { expect } = require("chai");
const fs = require("fs");
// golden minigeth.bin hash // golden minigeth.bin hash
const goldenRoot = "0x9c15aa86416a3a9d3b15188fc9f9be59626c1f83a33e5d63b58ca1bf0f8cef71" const goldenRoot = "0xff382489fd6109b9dc2dcee3f6e202e6ae2a5e7029cd9eb4b1f931dff51ca725"
describe("Challenge contract", function () { describe("Challenge contract", function () {
beforeEach(async function () { beforeEach(async function () {
// this mips can be reused for other challenges // this mips can be reused for other challenges
const MIPS = await ethers.getContractFactory("MIPS") const MIPS = await ethers.getContractFactory("MIPS")
const m = await MIPS.deploy() const m = await MIPS.deploy()
mm = await ethers.getContractAt("MIPSMemory", await m.m())
const Challenge = await ethers.getContractFactory("Challenge") const Challenge = await ethers.getContractFactory("Challenge")
c = await Challenge.deploy(m.address, goldenRoot) c = await Challenge.deploy(m.address, goldenRoot)
...@@ -25,11 +28,33 @@ describe("Challenge contract", function () { ...@@ -25,11 +28,33 @@ describe("Challenge contract", function () {
const blockNp1 = blockchain._data._blocksByNumber.get(blockNumberN+1) const blockNp1 = blockchain._data._blocksByNumber.get(blockNumberN+1)
const blockNp1Rlp = blockNp1.header.serialize() const blockNp1Rlp = blockNp1.header.serialize()
const assertionRoot = "0x1337133713371337133713371337133713371337133713371337133713371337" const assertionRoot = "0x9e0261efe4509912b8862f3d45a0cb8404b99b239247df9c55871bd3844cebbd"
// TODO: compute a valid one of these
const finalSystemState = "0x1337133713371337133713371337133713371337133713371337133713371337" const finalSystemState = "0xa9aaac45d9ccaeab0b97eff2d7ce6050948f8322c869c0a8f94a0d7013c31824"
let startTrie = JSON.parse(fs.readFileSync("/tmp/eth/13284469/checkpoint_-1.json"))
let finalTrie = JSON.parse(fs.readFileSync("/tmp/eth/13284469/checkpoint_85042025.json"))
await c.InitiateChallenge(blockNumberN, blockNp1Rlp, assertionRoot, finalSystemState, 1) while (1) {
try {
await c.InitiateChallenge(blockNumberN, blockNp1Rlp, assertionRoot, finalSystemState, 1)
} catch(e) {
const missing = e.toString().split("'")[1]
if (missing.length == 64) {
console.log("requested node", missing)
let node = startTrie['preimages']["0x"+missing]
if (node === undefined) {
node = finalTrie['preimages']["0x"+missing]
}
expect(node).to.not.be.an('undefined')
const bin = Uint8Array.from(Buffer.from(node, 'base64').toString('binary'), c => c.charCodeAt(0))
await mm.AddTrieNode(bin)
continue
} else {
console.log(e)
break
}
}
}
//const blockHeaderNp1 = getBlockRlp(await ethers.provider.getBlock(blockNumberN+1)); //const blockHeaderNp1 = getBlockRlp(await ethers.provider.getBlock(blockNumberN+1));
//console.log(blockNumberN, blockHeaderNp1); //console.log(blockNumberN, blockHeaderNp1);
......
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