Commit 2c47146a authored by George Hotz's avatar George Hotz

test Challenge deployment, fix a golden minigeth

parent 31ce277a
......@@ -4,15 +4,15 @@ pragma solidity ^0.7.3;
import "./lib/Lib_RLPReader.sol";
interface IMIPS {
function Step(bytes32 stateHash) external view returns (bytes32);
function Step(bytes32 stateHash) external returns (bytes32);
function m() external pure returns (IMIPSMemory);
}
interface IMIPSMemory {
function ReadMemory(bytes32 stateHash, uint32 addr) external view returns (uint32);
function ReadBytes32(bytes32 stateHash, uint32 addr) external view returns (bytes32);
function WriteMemory(bytes32 stateHash, uint32 addr, uint32 val) external pure returns (bytes32);
function WriteBytes32(bytes32 stateHash, uint32 addr, bytes32 val) external pure returns (bytes32);
function WriteMemory(bytes32 stateHash, uint32 addr, uint32 val) external returns (bytes32);
function WriteBytes32(bytes32 stateHash, uint32 addr, bytes32 val) external returns (bytes32);
}
contract Challenge {
......@@ -87,7 +87,6 @@ contract Challenge {
// load starting info into the input oracle
// we both agree at the beginning
// the first instruction executed in MIPS should be an access of startState
bytes32 txhash = Lib_RLPReader.readBytes32(blockNp1[4]);
bytes32 coinbase = bytes32(uint256(Lib_RLPReader.readAddress(blockNp1[2])));
bytes32 unclehash = Lib_RLPReader.readBytes32(blockNp1[1]);
......@@ -98,9 +97,8 @@ contract Challenge {
bytes32 startState = GlobalStartState;
startState = mem.WriteBytes32(startState, 0xB0000000, inputHash);
// 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
// confirm the finalSystemHash asserts the state you claim and the machine is stopped
// you must load these trie nodes into MIPSMemory before calling this
require(mem.ReadMemory(finalSystemState, 0xC0000080) == 0x5EAD0000, "machine is not stopped in final state (PC == 0x5EAD0000)");
require(mem.ReadMemory(finalSystemState, 0xB0000800) == 0x1337f00d, "state is not outputted");
require(mem.ReadBytes32(finalSystemState, 0xB0000804) == assertionRoot, "you are claiming a different state root in machine");
......
......@@ -3,7 +3,7 @@
*/
require("@nomiclabs/hardhat-ethers");
//require("hardhat-gas-reporter");
require("hardhat-gas-reporter");
module.exports = {
solidity: {
......
......@@ -3,4 +3,4 @@ go-ethereum
sysroot
test/test
minigeth
minigeth.bin
/minigeth.bin
......@@ -31,7 +31,7 @@ func main() {
})
ZeroRegisters(ram)
LoadMappedFileUnicorn(mu, "../mipigo/minigeth.bin", ram, 0)
LoadMappedFileUnicorn(mu, "../mipigo/golden/minigeth.bin", ram, 0)
LoadMappedFileUnicorn(mu, fmt.Sprintf("%s/input", root), ram, 0xB0000000)
mu.Start(0, 0x5ead0004)
......
const { expect } = require("chai");
describe("Challenge contract", function () {
beforeEach(async function () {
// this mips can be reused for other challenges
const MIPS = await ethers.getContractFactory("MIPS")
const m = await MIPS.deploy()
const Challenge = await ethers.getContractFactory("Challenge")
// golden minigeth.bin hash
c = await Challenge.deploy(m.address, "0x9c15aa86416a3a9d3b15188fc9f9be59626c1f83a33e5d63b58ca1bf0f8cef71")
})
it("challenge contract deploys", async function() {
console.log("Challenge deployed at", c.address)
})
})
\ No newline at end of file
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