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
f80eb8dd
Unverified
Commit
f80eb8dd
authored
Nov 04, 2024
by
mbaxter
Committed by
GitHub
Nov 04, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cannon: Add post-state checks (#12809)
* cannon: Add post-state assertions * cannon: Bump MIPS64 contract version
parent
0eb090e1
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
55 additions
and
6 deletions
+55
-6
mips.go
cannon/mipsevm/multithreaded/mips.go
+17
-0
semver-lock.json
packages/contracts-bedrock/semver-lock.json
+2
-2
MIPS64.json
packages/contracts-bedrock/snapshots/abi/MIPS64.json
+1
-1
MIPS64.sol
packages/contracts-bedrock/src/cannon/MIPS64.sol
+35
-3
No files found.
cannon/mipsevm/multithreaded/mips.go
View file @
f80eb8dd
...
@@ -224,6 +224,23 @@ func (m *InstrumentedState) handleSyscall() error {
...
@@ -224,6 +224,23 @@ func (m *InstrumentedState) handleSyscall() error {
}
}
func
(
m
*
InstrumentedState
)
mipsStep
()
error
{
func
(
m
*
InstrumentedState
)
mipsStep
()
error
{
err
:=
m
.
doMipsStep
()
if
err
!=
nil
{
return
err
}
m
.
assertPostStateChecks
()
return
err
}
func
(
m
*
InstrumentedState
)
assertPostStateChecks
()
{
activeStack
:=
m
.
state
.
getActiveThreadStack
()
if
len
(
activeStack
)
==
0
{
panic
(
"post-state active thread stack is empty"
)
}
}
func
(
m
*
InstrumentedState
)
doMipsStep
()
error
{
if
m
.
state
.
Exited
{
if
m
.
state
.
Exited
{
return
nil
return
nil
}
}
...
...
packages/contracts-bedrock/semver-lock.json
View file @
f80eb8dd
...
@@ -148,8 +148,8 @@
...
@@ -148,8 +148,8 @@
"sourceCodeHash"
:
"0x9fa2d1297ad1e93b4d3c5c0fed08bedcd8f746807589f0fd3369e79347c6a027"
"sourceCodeHash"
:
"0x9fa2d1297ad1e93b4d3c5c0fed08bedcd8f746807589f0fd3369e79347c6a027"
},
},
"src/cannon/MIPS64.sol"
:
{
"src/cannon/MIPS64.sol"
:
{
"initCodeHash"
:
"0x
c615a8f321f3bfb29c9459705f3012e512c463ba9ba2e1bcb6f9349f2d911d10
"
,
"initCodeHash"
:
"0x
93aa8d7f9fd3c22276c0d303a3fefdf8f73cc55807b35e483bba64c92d02aaef
"
,
"sourceCodeHash"
:
"0x
8fd0f4167d80f48010ad1241a9f6fb93576887dcc1f97be6b05adaf0086a537b
"
"sourceCodeHash"
:
"0x
171d66c651fdad2ac9c287da92689815a5b09589945ada092179508ad2326306
"
},
},
"src/cannon/PreimageOracle.sol"
:
{
"src/cannon/PreimageOracle.sol"
:
{
"initCodeHash"
:
"0x5d7e8ae64f802bd9d760e3d52c0a620bd02405dc2c8795818db9183792ffe81c"
,
"initCodeHash"
:
"0x5d7e8ae64f802bd9d760e3d52c0a620bd02405dc2c8795818db9183792ffe81c"
,
...
...
packages/contracts-bedrock/snapshots/abi/MIPS64.json
View file @
f80eb8dd
...
@@ -45,7 +45,7 @@
...
@@ -45,7 +45,7 @@
"outputs"
:
[
"outputs"
:
[
{
{
"internalType"
:
"bytes32"
,
"internalType"
:
"bytes32"
,
"name"
:
""
,
"name"
:
"
postState_
"
,
"type"
:
"bytes32"
"type"
:
"bytes32"
}
}
],
],
...
...
packages/contracts-bedrock/src/cannon/MIPS64.sol
View file @
f80eb8dd
...
@@ -64,8 +64,8 @@ contract MIPS64 is ISemver {
...
@@ -64,8 +64,8 @@ contract MIPS64 is ISemver {
}
}
/// @notice The semantic version of the MIPS64 contract.
/// @notice The semantic version of the MIPS64 contract.
/// @custom:semver 1.0.0-beta.
3
/// @custom:semver 1.0.0-beta.
4
string public constant version = "1.0.0-beta.
3
";
string public constant version = "1.0.0-beta.
4
";
/// @notice The preimage oracle contract.
/// @notice The preimage oracle contract.
IPreimageOracle internal immutable ORACLE;
IPreimageOracle internal immutable ORACLE;
...
@@ -106,7 +106,39 @@ contract MIPS64 is ISemver {
...
@@ -106,7 +106,39 @@ contract MIPS64 is ISemver {
/// the current thread stack.
/// the current thread stack.
/// @param _localContext The local key context for the preimage oracle. Optional, can be set as a constant
/// @param _localContext The local key context for the preimage oracle. Optional, can be set as a constant
/// if the caller only requires one set of local keys.
/// if the caller only requires one set of local keys.
function step(bytes calldata _stateData, bytes calldata _proof, bytes32 _localContext) public returns (bytes32) {
/// @return postState_ The hash of the post state witness after the state transition.
function step(
bytes calldata _stateData,
bytes calldata _proof,
bytes32 _localContext
)
public
returns (bytes32 postState_)
{
postState_ = doStep(_stateData, _proof, _localContext);
assertPostStateChecks();
}
function assertPostStateChecks() internal pure {
State memory state;
assembly {
state := STATE_MEM_OFFSET
}
bytes32 activeStack = state.traverseRight ? state.rightThreadStack : state.leftThreadStack;
if (activeStack == EMPTY_THREAD_ROOT) {
revert("MIPS64: post-state active thread stack is empty");
}
}
function doStep(
bytes calldata _stateData,
bytes calldata _proof,
bytes32 _localContext
)
internal
returns (bytes32)
{
unchecked {
unchecked {
State memory state;
State memory state;
ThreadState memory thread;
ThreadState memory thread;
...
...
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