diff --git a/contracts/Challenge.sol b/contracts/Challenge.sol index df359b113f5dce4375dae43081dc4bca9653b6f3..c92a125c3650fbba7ab28a568c3cbf368a904e3b 100644 --- a/contracts/Challenge.sol +++ b/contracts/Challenge.sol @@ -36,13 +36,13 @@ contract Challenge { IMIPSMemory immutable mem; // State hash of the fault proof program's initial MIPS state. - bytes32 immutable GlobalStartState; + bytes32 immutable globalStartState; - constructor(IMIPS imips, bytes32 globalStartState) { + constructor(IMIPS _mips, bytes32 _globalStartState) { owner = msg.sender; - mips = imips; - mem = imips.m(); - GlobalStartState = globalStartState; + mips = _mips; + mem = _mips.m(); + globalStartState = _globalStartState; } struct ChallengeData { @@ -79,7 +79,7 @@ contract Challenge { event ChallengeCreated(uint256 challengeId); // helper function to determine what nodes we need - function CallWithTrieNodes(address target, bytes calldata dat, bytes[] calldata nodes) public { + function callWithTrieNodes(address target, bytes calldata dat, bytes[] calldata nodes) public { for (uint i = 0; i < nodes.length; i++) { mem.AddTrieNode(nodes[i]); } @@ -108,7 +108,7 @@ contract Challenge { /// @param stepCount The number of steps (MIPS instructions) taken to execute the fault proof /// program. /// @return The challenge identifier - function InitiateChallenge( + function initiateChallenge( uint blockNumberN, bytes calldata blockHeaderNp1, bytes32 assertionRoot, bytes32 finalSystemState, uint256 stepCount) external @@ -150,7 +150,7 @@ contract Challenge { } // Write input hash at predefined memory address. - bytes32 startState = GlobalStartState; + bytes32 startState = globalStartState; startState = mem.WriteBytes32(startState, 0x30000000, inputHash); // Confirm that `finalSystemState` asserts the state you claim and that the machine is stopped. @@ -198,7 +198,7 @@ contract Challenge { return c.assertedState[stepNumber]; } - function ProposeState(uint256 challengeId, bytes32 riscState) external { + function proposeState(uint256 challengeId, bytes32 riscState) external { ChallengeData storage c = challenges[challengeId]; require(c.challenger != address(0), "invalid challenge"); require(c.challenger == msg.sender, "must be challenger"); @@ -209,7 +209,7 @@ contract Challenge { c.assertedState[stepNumber] = riscState; } - function RespondState(uint256 challengeId, bytes32 riscState) external { + function respondState(uint256 challengeId, bytes32 riscState) external { ChallengeData storage c = challenges[challengeId]; require(c.challenger != address(0), "invalid challenge"); require(owner == msg.sender, "must be owner"); @@ -237,7 +237,7 @@ contract Challenge { event ChallengerLoses(uint256 challengeId); event ChallengerLosesByDefault(uint256 challengeId); - function ConfirmStateTransition(uint256 challengeId) external { + function confirmStateTransition(uint256 challengeId) external { ChallengeData storage c = challenges[challengeId]; require(c.challenger != address(0), "invalid challenge"); //require(c.challenger == msg.sender, "must be challenger"); @@ -253,7 +253,7 @@ contract Challenge { emit ChallengerWins(challengeId); } - function DenyStateTransition(uint256 challengeId) external { + function denyStateTransition(uint256 challengeId) external { ChallengeData storage c = challenges[challengeId]; require(c.challenger != address(0), "invalid challenge"); //require(owner == msg.sender, "must be owner"); diff --git a/demo/challenge_simple.sh b/demo/challenge_simple.sh index 61c5d37f1c0331bf91f88e984f97a21d3dc003df..35e468351418faebb46adc076bab07fc4421a477 100755 --- a/demo/challenge_simple.sh +++ b/demo/challenge_simple.sh @@ -15,7 +15,7 @@ # # (The input hash is automatically validated against the blockhash, so note that # in this demo the challenger has to provide the correct (`BLOCK`) input hash to -# the `InitiateChallenge` function of `Challenge.sol`, but will execute as +# the `initiateChallenge` function of `Challenge.sol`, but will execute as # though the input hash was the one derived from `WRONG_BLOCK`.) # # Because the challenger uses the wrong inputs, it will assert a post-state diff --git a/scripts/assert.js b/scripts/assert.js index 0300dd48a33aeafb29f32156e697ee6391769bcf..86685392eff13d1bd1a056f8f13bf7754244207c 100644 --- a/scripts/assert.js +++ b/scripts/assert.js @@ -18,11 +18,11 @@ async function main() { let cdat if (isChallenger) { // challenger declare victory - cdat = c.interface.encodeFunctionData("ConfirmStateTransition", [challengeId]) + cdat = c.interface.encodeFunctionData("confirmStateTransition", [challengeId]) } else { // defender declare victory // note: not always possible - cdat = c.interface.encodeFunctionData("DenyStateTransition", [challengeId]) + cdat = c.interface.encodeFunctionData("denyStateTransition", [challengeId]) } let startTrie = getTrieAtStep(blockNumberN, step) @@ -36,9 +36,9 @@ async function main() { let ret if (isChallenger) { - ret = await c.ConfirmStateTransition(challengeId) + ret = await c.confirmStateTransition(challengeId) } else { - ret = await c.DenyStateTransition(challengeId) + ret = await c.denyStateTransition(challengeId) } let receipt = await ret.wait() diff --git a/scripts/challenge.js b/scripts/challenge.js index d3894b0ef8cca6f5329668381c4772d985ce5ae9..a9fb39f4fd494b50c3f73210563d817782293b71 100644 --- a/scripts/challenge.js +++ b/scripts/challenge.js @@ -32,14 +32,14 @@ async function main() { const finalSystemState = finalTrie['root'] let args = [blockNumberN, blockNp1Rlp, assertionRoot, finalSystemState, finalTrie['step']] - let cdat = c.interface.encodeFunctionData("InitiateChallenge", args) + let cdat = c.interface.encodeFunctionData("initiateChallenge", args) let nodes = await getTrieNodesForCall(c, c.address, cdat, preimages) // run "on chain" for (n of nodes) { await mm.AddTrieNode(n) } - let ret = await c.InitiateChallenge(...args) + let ret = await c.initiateChallenge(...args) let receipt = await ret.wait() // ChallengeCreated event let challengeId = receipt.events[0].args['challengeId'].toNumber() diff --git a/scripts/lib.js b/scripts/lib.js index f7def035cc7cec2d2a7b46649f4e0a978353dbf8..72186a4aa736e8fd2c042606f4ebc7203261a532 100644 --- a/scripts/lib.js +++ b/scripts/lib.js @@ -71,8 +71,8 @@ async function getTrieNodesForCall(c, caddress, cdat, preimages) { while (1) { try { // TODO: make this eth call? - // needs something like InitiateChallengeWithTrieNodesj - let calldata = c.interface.encodeFunctionData("CallWithTrieNodes", [caddress, cdat, nodes]) + // needs something like initiateChallengeWithTrieNodesj + let calldata = c.interface.encodeFunctionData("callWithTrieNodes", [caddress, cdat, nodes]) ret = await ethers.provider.call({ to:c.address, data:calldata diff --git a/scripts/respond.js b/scripts/respond.js index 5ffbdf756e226f4fdce1e24dbeeb3f89e3dd3ab2..59e54648ee1791d7e925f0830d14dc271ce47cee 100644 --- a/scripts/respond.js +++ b/scripts/respond.js @@ -30,9 +30,9 @@ async function main() { let ret if (isProposing) { - ret = await c.ProposeState(challengeId, root) + ret = await c.proposeState(challengeId, root) } else { - ret = await c.RespondState(challengeId, root) + ret = await c.respondState(challengeId, root) } let receipt = await ret.wait() console.log("done", receipt.blockNumber) diff --git a/test/challenge_test.js b/test/challenge_test.js index 7fea1c10699065c0b79ba175e966bf0d1f69f2ec..59f31472b4a33a2dbfcedbcf5d939d769ef48fad 100644 --- a/test/challenge_test.js +++ b/test/challenge_test.js @@ -31,14 +31,14 @@ describe("Challenge contract", function () { const finalSystemState = finalTrie['root'] let args = [blockNumberN, blockNp1Rlp, assertionRoot, finalSystemState, finalTrie['step']] - let cdat = c.interface.encodeFunctionData("InitiateChallenge", args) + let cdat = c.interface.encodeFunctionData("initiateChallenge", args) let nodes = await getTrieNodesForCall(c, c.address, cdat, preimages) // run "on chain" for (n of nodes) { await mm.AddTrieNode(n) } - let ret = await c.InitiateChallenge(...args) + let ret = await c.initiateChallenge(...args) let receipt = await ret.wait() // ChallengeCreated event let challengeId = receipt.events[0].args['challengeId'].toNumber()