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
65dd880a
Commit
65dd880a
authored
Mar 07, 2022
by
Nicolas "Norswap" Laurent
Committed by
norswap
Mar 17, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
document contract interfaces
parent
7155f6dd
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
10 deletions
+24
-10
Challenge.sol
contracts/Challenge.sol
+24
-10
No files found.
contracts/Challenge.sol
View file @
65dd880a
...
...
@@ -5,28 +5,46 @@ pragma experimental ABIEncoderV2;
import "./lib/Lib_RLPReader.sol";
interface IMIPS {
// Given a MIPS state hash (includes code & registers), execute the next instruction and returns
// the update state hash.
function Step(bytes32 stateHash) external returns (bytes32);
// Returns the associated MIPS memory contract.
function m() external pure returns (IMIPSMemory);
}
interface IMIPSMemory {
// Adds a `(hash(anything) => anything)` entry to the mapping that underpins all the Merkle tries
// that this contract deals with (where "state hash" = Merkle root of such a trie).
// Here, `anything` is supposed to be node data in such a trie.
function AddTrieNode(bytes calldata anything) external;
function ReadMemory(bytes32 stateHash, uint32 addr) external view returns (uint32);
function ReadBytes32(bytes32 stateHash, uint32 addr) external view returns (bytes32);
// Write 32 bits at the given address and returns the updated state hash.
function WriteMemory(bytes32 stateHash, uint32 addr, uint32 val) external returns (bytes32);
// Write 32 bytes at the given address and returns the updated state hash.
function WriteBytes32(bytes32 stateHash, uint32 addr, bytes32 val) external returns (bytes32);
}
contract Challenge {
address payable immutable owner;
// the mips machine state transition function
IMIPS immutable mips;
IMIPSMemory immutable mem;
//
the program start state
//
State hash of the fault proof program's initial MIPS state.
bytes32 immutable GlobalStartState;
constructor(IMIPS imips, bytes32 globalStartState) {
owner = msg.sender;
mips = imips;
mem = imips.m();
GlobalStartState = globalStartState;
}
struct Chal {
uint256 L;
uint256 R;
...
...
@@ -35,17 +53,13 @@ contract Challenge {
address payable challenger;
uint256 blockNumberN;
}
mapping(uint256 => Chal) challenges;
constructor(IMIPS imips, bytes32 globalStartState) {
owner = msg.sender;
mips = imips;
mem = imips.m();
GlobalStartState = globalStartState;
}
mapping(uint256 => Chal) challenges;
//
allow getting money (and withdrawing the bounty, honor system)
//
Allow sending money to the contract (without calldata).
receive() external payable {}
// Allows the owner to withdraw funds from the contract.
function withdraw() external {
require(msg.sender == owner, "not owner");
(bool sent, ) = owner.call{value: address(this).balance}("");
...
...
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