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
3e6e6c39
Commit
3e6e6c39
authored
Mar 09, 2022
by
Nicolas "Norswap" Laurent
Committed by
norswap
Mar 17, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
expand on use of callWithTrieNodes
parent
312aad6d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
6 deletions
+12
-6
Challenge.sol
contracts/Challenge.sol
+12
-6
No files found.
contracts/Challenge.sol
View file @
3e6e6c39
...
@@ -84,7 +84,8 @@ contract Challenge {
...
@@ -84,7 +84,8 @@ contract Challenge {
/// Before calling this, it is necessary to have loaded all the trie node necessary to
/// Before calling this, it is necessary to have loaded all the trie node necessary to
/// write the input hash in the Merkleized initial MIPS state, and to read the output hash
/// write the input hash in the Merkleized initial MIPS state, and to read the output hash
/// and machine state from the Merkleized final MIPS state (i.e. `finalSystemState`). Use
/// and machine state from the Merkleized final MIPS state (i.e. `finalSystemState`). Use
/// `MIPSMemory.AddTrieNode` for this purpose.
/// `MIPSMemory.AddTrieNode` for this purpose. Use `callWithTrieNodes` to figure out
/// which nodes you need.
/// @param blockNumberN The number N of the parent of the block being challenged
/// @param blockNumberN The number N of the parent of the block being challenged
/// @param blockHeaderNp1 The RLP-encoded header of the block being challenged (N+1)
/// @param blockHeaderNp1 The RLP-encoded header of the block being challenged (N+1)
/// @param assertionRoot The state root that the challenger claims is the correct one for the
/// @param assertionRoot The state root that the challenger claims is the correct one for the
...
@@ -162,16 +163,15 @@ contract Challenge {
...
@@ -162,16 +163,15 @@ contract Challenge {
return challengeId;
return challengeId;
}
}
/// @notice Calling `initiateChallenge` requires some trie nodes to have been supplied beforehand,
/// @notice Calling `initiateChallenge`, `confirmStateTransition` or `denyStateTransition requires
/// in order to be able to write the input hash in the Merkleized initial MIPS state, and
/// some trie nodes to have been supplied beforehand (see these functions for details).
/// to read the output hash and machine state from the Merkleized final MIPS state.
/// This function can be used to figure out which nodes are needed, as memory-accessing
/// This function can be used to figure out which nodes are needed, as memory-reading
/// functions in MIPSMemory.sol will revert with the missing node ID when a node is
/// functions in MIPSMemory.sol will revert with the missing node ID when a node is
/// missing. Therefore, you can call this function repeatedly via `eth_call`, and
/// missing. Therefore, you can call this function repeatedly via `eth_call`, and
/// iteratively build the list of required node until the call succeeds.
/// iteratively build the list of required node until the call succeeds.
/// @param target The contract to call to (usually this contract)
/// @param target The contract to call to (usually this contract)
/// @param dat The data to include in the call (usually the calldata for a call to
/// @param dat The data to include in the call (usually the calldata for a call to
///
`initiateChallenge`
///
one of the aforementionned functions)
/// @param nodes The nodes to add the MIPS state trie before making the call
/// @param nodes The nodes to add the MIPS state trie before making the call
function callWithTrieNodes(address target, bytes calldata dat, bytes[] calldata nodes) public {
function callWithTrieNodes(address target, bytes calldata dat, bytes[] calldata nodes) public {
for (uint i = 0; i < nodes.length; i++) {
for (uint i = 0; i < nodes.length; i++) {
...
@@ -266,6 +266,9 @@ contract Challenge {
...
@@ -266,6 +266,9 @@ contract Challenge {
/// @notice Anybody can call this function to confirm that the single execution step that the
/// @notice Anybody can call this function to confirm that the single execution step that the
/// challenger and defender disagree on does indeed yield the result asserted by the
/// challenger and defender disagree on does indeed yield the result asserted by the
/// challenger, leading to him winning the challenge.
/// challenger, leading to him winning the challenge.
/// Before calling this function, you need to add trie nodes so that the MIPS state can be
/// read/written by the single step execution. Use `MIPSMemory.AddTrieNode` for this
/// purpose. Use `callWithTrieNodes` to figure out which nodes you need.
function confirmStateTransition(uint256 challengeId) external {
function confirmStateTransition(uint256 challengeId) external {
ChallengeData storage c = challenges[challengeId];
ChallengeData storage c = challenges[challengeId];
require(c.challenger != address(0), "invalid challenge");
require(c.challenger != address(0), "invalid challenge");
...
@@ -284,6 +287,9 @@ contract Challenge {
...
@@ -284,6 +287,9 @@ contract Challenge {
/// @notice Anybody can call this function to confirm that the single execution step that the
/// @notice Anybody can call this function to confirm that the single execution step that the
/// challenger and defender disagree on does indeed yield the result asserted by the
/// challenger and defender disagree on does indeed yield the result asserted by the
/// defender, leading to the challenger losing the challenge.
/// defender, leading to the challenger losing the challenge.
/// Before calling this function, you need to add trie nodes so that the MIPS state can be
/// read/written by the single step execution. Use `MIPSMemory.AddTrieNode` for this
/// purpose. Use `callWithTrieNodes` to figure out which nodes you need.
function denyStateTransition(uint256 challengeId) external {
function denyStateTransition(uint256 challengeId) external {
ChallengeData storage c = challenges[challengeId];
ChallengeData storage c = challenges[challengeId];
require(c.challenger != address(0), "invalid challenge");
require(c.challenger != address(0), "invalid challenge");
...
...
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