Commit e7cf0dfd authored by Nicolas "Norswap" Laurent's avatar Nicolas "Norswap" Laurent Committed by norswap

uncapitalize variable & function names in Challenge.sol

parent e218c6b0
......@@ -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");
......
......@@ -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
......
......@@ -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()
......
......@@ -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()
......
......@@ -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
......
......@@ -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)
......
......@@ -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()
......
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