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
0b3a5180
Commit
0b3a5180
authored
Oct 04, 2021
by
George Hotz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
don't keep calling m()
parent
cc62f79f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
3 deletions
+5
-3
Challenge.sol
contracts/Challenge.sol
+5
-3
No files found.
contracts/Challenge.sol
View file @
0b3a5180
...
...
@@ -19,6 +19,7 @@ contract Challenge {
// the mips machine state transition function
IMIPS immutable mips;
IMIPSMemory immutable mem;
// the program start state
bytes32 immutable GlobalStartState;
...
...
@@ -35,6 +36,7 @@ contract Challenge {
constructor(IMIPS imips, bytes32 globalStartState) {
owner = msg.sender;
mips = imips;
mem = imips.m();
GlobalStartState = globalStartState;
}
...
...
@@ -52,7 +54,7 @@ contract Challenge {
for (uint32 i = 0; i < 32; i += 4) {
uint256 tv = uint256(val>>(224-(i*8)));
stateHash = m
ips.m()
.WriteMemory(stateHash, addr+i, uint32(tv));
stateHash = m
em
.WriteMemory(stateHash, addr+i, uint32(tv));
}
return stateHash;
}
...
...
@@ -108,8 +110,8 @@ contract Challenge {
// confirm the finalSystemHash asserts the state you claim (in $t0-$t7) and the machine is stopped
// you must load these proofs into MIPS before calling this
// we disagree at the end
require(m
ips.m()
.ReadBytes32(finalSystemState, 0x30000800) == assertionRoot, "you are claiming a different state root in machine");
require(m
ips.m()
.ReadMemory(finalSystemState, 0xC0000080) == 0xDEAD0000, "machine is not stopped in final state (PC == 0xDEAD0000)");
require(m
em
.ReadBytes32(finalSystemState, 0x30000800) == assertionRoot, "you are claiming a different state root in machine");
require(m
em
.ReadMemory(finalSystemState, 0xC0000080) == 0xDEAD0000, "machine is not stopped in final state (PC == 0xDEAD0000)");
return newChallengeTrusted(startState, finalSystemState, stepCount);
}
...
...
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