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
8c2b0368
Commit
8c2b0368
authored
Mar 07, 2022
by
Nicolas "Norswap" Laurent
Committed by
norswap
Mar 17, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
merge InitChallenge with newChallengeTrusted
parent
acd3fa6f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
17 deletions
+8
-17
Challenge.sol
contracts/Challenge.sol
+8
-17
No files found.
contracts/Challenge.sol
View file @
8c2b0368
...
...
@@ -46,11 +46,17 @@ contract Challenge {
}
struct Chal {
// Left bound of the binary search: challenger & defender agree on all steps <= L.
uint256 L;
// Right bound of the binary search: challenger & defender disagree on all steps >= R.
uint256 R;
// Maps step numbers to asserted state hashes for the challenger.
mapping(uint256 => bytes32) assertedState;
// Maps step numbers to asserted state hashes for the defender.
mapping(uint256 => bytes32) defendedState;
// Address of the challenger.
address payable challenger;
// Block number preceding the challenged block.
uint256 blockNumberN;
}
...
...
@@ -155,33 +161,18 @@ contract Challenge {
require(mem.ReadBytes32(finalSystemState, 0x30000804) == assertionRoot,
"the final MIPS machine state asserts a different state root than your challenge");
return newChallengeTrusted(blockNumberN, startState, finalSystemState, stepCount);
}
function newChallengeTrusted(
uint256 blockNumberN, bytes32 startState, bytes32 finalSystemState, uint256 stepCount)
internal
returns (uint256)
{
uint256 challengeId = lastChallengeId;
uint256 challengeId = lastChallengeId++;
Chal storage c = challenges[challengeId];
lastChallengeId += 1;
//
the challenger arrives
//
A NEW CHALLENGER APPEARS
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;
}
...
...
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