Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nebula
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
exchain
nebula
Commits
a5abe5f6
Commit
a5abe5f6
authored
Mar 07, 2022
by
Nicolas "Norswap" Laurent
Committed by
norswap
Mar 17, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rename Chal to ChallengeData
parent
8c2b0368
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
10 deletions
+10
-10
Challenge.sol
contracts/Challenge.sol
+10
-10
No files found.
contracts/Challenge.sol
View file @
a5abe5f6
...
@@ -45,7 +45,7 @@ contract Challenge {
...
@@ -45,7 +45,7 @@ contract Challenge {
GlobalStartState = globalStartState;
GlobalStartState = globalStartState;
}
}
struct Chal {
struct Chal
lengeData
{
// Left bound of the binary search: challenger & defender agree on all steps <= L.
// Left bound of the binary search: challenger & defender agree on all steps <= L.
uint256 L;
uint256 L;
// Right bound of the binary search: challenger & defender disagree on all steps >= R.
// Right bound of the binary search: challenger & defender disagree on all steps >= R.
...
@@ -60,7 +60,7 @@ contract Challenge {
...
@@ -60,7 +60,7 @@ contract Challenge {
uint256 blockNumberN;
uint256 blockNumberN;
}
}
mapping(uint256 => Chal) challenges;
mapping(uint256 => Chal
lengeData
) challenges;
// Allow sending money to the contract (without calldata).
// Allow sending money to the contract (without calldata).
receive() external payable {}
receive() external payable {}
...
@@ -162,7 +162,7 @@ contract Challenge {
...
@@ -162,7 +162,7 @@ contract Challenge {
"the final MIPS machine state asserts a different state root than your challenge");
"the final MIPS machine state asserts a different state root than your challenge");
uint256 challengeId = lastChallengeId++;
uint256 challengeId = lastChallengeId++;
Chal storage c = challenges[challengeId];
Chal
lengeData
storage c = challenges[challengeId];
// A NEW CHALLENGER APPEARS
// A NEW CHALLENGER APPEARS
c.challenger = msg.sender;
c.challenger = msg.sender;
...
@@ -180,26 +180,26 @@ contract Challenge {
...
@@ -180,26 +180,26 @@ contract Challenge {
// binary search
// binary search
function isSearching(uint256 challengeId) view public returns (bool) {
function isSearching(uint256 challengeId) view public returns (bool) {
Chal storage c = challenges[challengeId];
Chal
lengeData
storage c = challenges[challengeId];
require(c.challenger != address(0), "invalid challenge");
require(c.challenger != address(0), "invalid challenge");
return c.L + 1 != c.R;
return c.L + 1 != c.R;
}
}
function getStepNumber(uint256 challengeId) view public returns (uint256) {
function getStepNumber(uint256 challengeId) view public returns (uint256) {
Chal storage c = challenges[challengeId];
Chal
lengeData
storage c = challenges[challengeId];
require(c.challenger != address(0), "invalid challenge");
require(c.challenger != address(0), "invalid challenge");
return (c.L+c.R)/2;
return (c.L+c.R)/2;
}
}
function getProposedState(uint256 challengeId) view public returns (bytes32) {
function getProposedState(uint256 challengeId) view public returns (bytes32) {
Chal storage c = challenges[challengeId];
Chal
lengeData
storage c = challenges[challengeId];
require(c.challenger != address(0), "invalid challenge");
require(c.challenger != address(0), "invalid challenge");
uint256 stepNumber = getStepNumber(challengeId);
uint256 stepNumber = getStepNumber(challengeId);
return c.assertedState[stepNumber];
return c.assertedState[stepNumber];
}
}
function ProposeState(uint256 challengeId, bytes32 riscState) external {
function ProposeState(uint256 challengeId, bytes32 riscState) external {
Chal storage c = challenges[challengeId];
Chal
lengeData
storage c = challenges[challengeId];
require(c.challenger != address(0), "invalid challenge");
require(c.challenger != address(0), "invalid challenge");
require(c.challenger == msg.sender, "must be challenger");
require(c.challenger == msg.sender, "must be challenger");
require(isSearching(challengeId), "must be searching");
require(isSearching(challengeId), "must be searching");
...
@@ -210,7 +210,7 @@ contract Challenge {
...
@@ -210,7 +210,7 @@ contract Challenge {
}
}
function RespondState(uint256 challengeId, bytes32 riscState) external {
function RespondState(uint256 challengeId, bytes32 riscState) external {
Chal storage c = challenges[challengeId];
Chal
lengeData
storage c = challenges[challengeId];
require(c.challenger != address(0), "invalid challenge");
require(c.challenger != address(0), "invalid challenge");
require(owner == msg.sender, "must be owner");
require(owner == msg.sender, "must be owner");
require(isSearching(challengeId), "must be searching");
require(isSearching(challengeId), "must be searching");
...
@@ -238,7 +238,7 @@ contract Challenge {
...
@@ -238,7 +238,7 @@ contract Challenge {
event ChallengerLosesByDefault(uint256 challengeId);
event ChallengerLosesByDefault(uint256 challengeId);
function ConfirmStateTransition(uint256 challengeId) external {
function ConfirmStateTransition(uint256 challengeId) external {
Chal storage c = challenges[challengeId];
Chal
lengeData
storage c = challenges[challengeId];
require(c.challenger != address(0), "invalid challenge");
require(c.challenger != address(0), "invalid challenge");
//require(c.challenger == msg.sender, "must be challenger");
//require(c.challenger == msg.sender, "must be challenger");
require(!isSearching(challengeId), "binary search not finished");
require(!isSearching(challengeId), "binary search not finished");
...
@@ -254,7 +254,7 @@ contract Challenge {
...
@@ -254,7 +254,7 @@ contract Challenge {
}
}
function DenyStateTransition(uint256 challengeId) external {
function DenyStateTransition(uint256 challengeId) external {
Chal storage c = challenges[challengeId];
Chal
lengeData
storage c = challenges[challengeId];
require(c.challenger != address(0), "invalid challenge");
require(c.challenger != address(0), "invalid challenge");
//require(owner == msg.sender, "must be owner");
//require(owner == msg.sender, "must be owner");
require(!isSearching(challengeId), "binary search not finished");
require(!isSearching(challengeId), "binary search not finished");
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment