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
acd3fa6f
Commit
acd3fa6f
authored
Mar 07, 2022
by
Nicolas "Norswap" Laurent
Committed by
norswap
Mar 17, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
move function
parent
483bca00
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
24 deletions
+30
-24
Challenge.sol
contracts/Challenge.sol
+30
-24
No files found.
contracts/Challenge.sol
View file @
acd3fa6f
...
@@ -69,30 +69,8 @@ contract Challenge {
...
@@ -69,30 +69,8 @@ contract Challenge {
// create challenge
// create challenge
uint256 public lastChallengeId = 0;
uint256 public lastChallengeId = 0;
// Emitted when a new challenge is created.
event ChallengeCreate(uint256 challengeId);
event ChallengeCreate(uint256 challengeId);
function newChallengeTrusted(uint256 blockNumberN, bytes32 startState, bytes32 finalSystemState, uint256 stepCount) internal returns (uint256) {
uint256 challengeId = lastChallengeId;
Chal storage c = challenges[challengeId];
lastChallengeId += 1;
// the challenger arrives
c.challenger = msg.sender;
// the state is set
c.blockNumberN = blockNumberN;
// NOTE: if they disagree on the start, 0->1 will fail
c.assertedState[0] = startState;
c.defendedState[0] = startState;
c.assertedState[stepCount] = finalSystemState;
// init the binary search
c.L = 0;
c.R = stepCount;
// find me later
emit ChallengeCreate(challengeId);
return challengeId;
}
// helper function to determine what nodes we need
// 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 {
...
@@ -180,6 +158,34 @@ contract Challenge {
...
@@ -180,6 +158,34 @@ contract Challenge {
return newChallengeTrusted(blockNumberN, startState, finalSystemState, stepCount);
return newChallengeTrusted(blockNumberN, startState, finalSystemState, stepCount);
}
}
function newChallengeTrusted(
uint256 blockNumberN, bytes32 startState, bytes32 finalSystemState, uint256 stepCount)
internal
returns (uint256)
{
uint256 challengeId = lastChallengeId;
Chal storage c = challenges[challengeId];
lastChallengeId += 1;
// the challenger arrives
c.challenger = msg.sender;
// the state is set
c.blockNumberN = blockNumberN;
// NOTE: if they disagree on the start, 0->1 will fail
c.assertedState[0] = startState;
c.defendedState[0] = startState;
c.assertedState[stepCount] = finalSystemState;
// init the binary search
c.L = 0;
c.R = stepCount;
// find me later
emit ChallengeCreate(challengeId);
return challengeId;
}
// binary search
// binary search
function isSearching(uint256 challengeId) view public returns (bool) {
function isSearching(uint256 challengeId) view public returns (bool) {
...
@@ -252,7 +258,7 @@ contract Challenge {
...
@@ -252,7 +258,7 @@ contract Challenge {
// pay out bounty!!
// pay out bounty!!
(bool sent, ) = c.challenger.call{value: address(this).balance}("");
(bool sent, ) = c.challenger.call{value: address(this).balance}("");
require(sent, "Failed to send Ether");
require(sent, "Failed to send Ether");
emit ChallengerWins(challengeId);
emit ChallengerWins(challengeId);
}
}
...
...
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