Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Cleaned up names
  • Loading branch information
hswick committed Mar 28, 2018
commit 760648b9a81388ec03a61375a8233ecbee071a7d
10 changes: 5 additions & 5 deletions contracts/BasicVerificationGame.sol
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ contract BasicVerificationGame {


//Should probably replace preValue and postValue with preInstruction and postInstruction
function performStepVerification(bytes32 gameId, bytes32[3] preStepState, bytes32[3] postStepState, bytes proof) public {
function performStepVerification(bytes32 gameId, bytes32[3] lowStepState, bytes32[3] highStepState, bytes proof) public {
VerificationGame storage game = games[gameId];

require(game.state == State.Unresolved);
Expand All @@ -207,13 +207,13 @@ contract BasicVerificationGame {
require(game.lowStep + 1 == game.highStep);
// ^ must be at the end of the binary search according to the smart contract

require(game.vm.merklizeState(preStepState) == game.lowHash);
require(game.vm.merklizeState(postStepState) == game.highHash);
require(game.vm.merklizeState(lowStepState) == game.lowHash);
require(game.vm.merklizeState(highStepState) == game.highHash);

//require that the next instruction be included in the program merkle root
require(checkProofOrdered(proof, game.programMerkleRoot, keccak256(postStepState[0]), game.highStep));
require(checkProofOrdered(proof, game.programMerkleRoot, keccak256(highStepState[0]), game.highStep));

bytes32[3] memory newState = game.vm.runStep(preStepState, game.highStep, postStepState[0]);
bytes32[3] memory newState = game.vm.runStep(lowStepState, game.highStep, highStepState[0]);

if (game.vm.merklizeState(newState) == game.highHash) {
game.state = State.SolverWon;
Expand Down
14 changes: 7 additions & 7 deletions test/basic_verification_game.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,18 +81,18 @@ contract('BasicVerificationGame query to high step', function(accounts) {
})

it("should perform step verification", async () => {
let preState = toResult(await simpleAdderVM.runSteps.call(program, step-1)).state
let lowStepState = toResult(await simpleAdderVM.runSteps.call(program, step-1)).state

let postStepNum = step
let postStepIndex = postStepNum-1
let postState = await simpleAdderVM.runStep.call(preState, postStepNum, program[postStepIndex])
let highStep = step
let highStepIndex = step-1
let highStepState = await simpleAdderVM.runStep.call(lowStepState, highStep, program[highStepIndex])

let proof = mtree.getProofOrdered(hashes[postStepIndex], postStepNum)
let proof = mtree.getProofOrdered(hashes[highStepIndex], highStep)
const newProof = '0x' + proof.map(e => e.toString('hex')).join('')

assert(await checkProofOrderedSolidity(proof, root, hashes[postStepIndex], postStepNum))
assert(await checkProofOrderedSolidity(proof, root, hashes[highStepIndex], highStep))

tx = await basicVerificationGame.performStepVerification(gameId, preState, postState, newProof, {from: accounts[1]})
tx = await basicVerificationGame.performStepVerification(gameId, lowStepState, highStepState, newProof, {from: accounts[1]})
assert.equal(1, (await basicVerificationGame.status.call(gameId)).toNumber())
})
})