Commit bd158ea4 authored by George Hotz's avatar George Hotz

we responded and the bsearch went left

parent b71f7661
...@@ -63,8 +63,15 @@ minigeth/go-ethereum 1171895 ...@@ -63,8 +63,15 @@ minigeth/go-ethereum 1171895
npx hardhat run scripts/deploy.js npx hardhat run scripts/deploy.js
BLOCK=1171895 npx hardhat run scripts/challenge.js BLOCK=1171895 npx hardhat run scripts/challenge.js
# "attacker" is block 1171896
minigeth/go-ethereum 1171896
ID=0 npx hardhat run scripts/respond.js
(cd mipsevm && ./mipsevm 1171896 11226379) (cd mipsevm && ./mipsevm 1171896 11226379)
ID=0 BLOCK=1171896 npx hardhat run scripts/respond.js ID=0 BLOCK=1171896 PROPOSE=1 npx hardhat run scripts/respond.js
# "defender" is real block 1171896
(cd mipsevm && ./mipsevm 1171895 11226379)
ID=0 BLOCK=1171895 RESPOND=1 npx hardhat run scripts/respond.js
``` ```
## State Oracle API ## State Oracle API
......
...@@ -149,6 +149,12 @@ contract Challenge { ...@@ -149,6 +149,12 @@ contract Challenge {
return (c.L+c.R)/2; return (c.L+c.R)/2;
} }
function getProposedState(uint256 challengeId) view public returns (bytes32) {
Chal storage c = challenges[challengeId];
require(c.challenger != address(0), "invalid challenge");
return c.assertedState[stepNumber];
}
function ProposeState(uint256 challengeId, bytes32 riscState) external { function ProposeState(uint256 challengeId, bytes32 riscState) external {
Chal storage c = challenges[challengeId]; Chal storage c = challenges[challengeId];
require(c.challenger != address(0), "invalid challenge"); require(c.challenger != address(0), "invalid challenge");
......
...@@ -4,19 +4,30 @@ const { deployed, getTrieNodesForCall } = require("../scripts/lib") ...@@ -4,19 +4,30 @@ const { deployed, getTrieNodesForCall } = require("../scripts/lib")
async function main() { async function main() {
let [c, m, mm] = await deployed() let [c, m, mm] = await deployed()
const blockNumberN = parseInt(process.env.BLOCK)
const challengeId = parseInt(process.env.ID) const challengeId = parseInt(process.env.ID)
let step = (await c.getStepNumber(challengeId)).toNumber() let step = (await c.getStepNumber(challengeId)).toNumber()
console.log("searching step", step, "in block", blockNumberN) console.log("searching step", step)
// see if it's proposed or not
//await c.getProposedState(challengeId)
const blockNumberN = parseInt(process.env.BLOCK)
let thisTrie = JSON.parse(fs.readFileSync("/tmp/cannon/0_"+blockNumberN.toString()+"/checkpoint_"+step.toString()+".json")) let thisTrie = JSON.parse(fs.readFileSync("/tmp/cannon/0_"+blockNumberN.toString()+"/checkpoint_"+step.toString()+".json"))
const root = thisTrie['root'] const root = thisTrie['root']
console.log("new root", root) console.log("new root", root)
let ret = await c.ProposeState(challengeId, root) if (process.env.PROPOSE == "1") {
let receipt = await ret.wait() let ret = await c.ProposeState(challengeId, root)
console.log(receipt) let receipt = await ret.wait()
console.log(receipt)
}
if (process.env.RESPOND == "1") {
let ret = await c.RespondState(challengeId, root)
let receipt = await ret.wait()
console.log(receipt)
}
} }
main() main()
......
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