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
1d230d23
Commit
1d230d23
authored
Sep 05, 2023
by
clabby
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add `VMStatus` type
dedup
parent
e5014d71
Changes
8
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
47 additions
and
29 deletions
+47
-29
faultdisputegame.go
op-bindings/bindings/faultdisputegame.go
+1
-1
faultdisputegame_more.go
op-bindings/bindings/faultdisputegame_more.go
+1
-1
semver-lock.json
packages/contracts-bedrock/semver-lock.json
+1
-1
FaultDisputeGame.sol
packages/contracts-bedrock/src/dispute/FaultDisputeGame.sol
+3
-1
DisputeTypes.sol
packages/contracts-bedrock/src/libraries/DisputeTypes.sol
+18
-0
DisputeGameFactory.t.sol
packages/contracts-bedrock/test/DisputeGameFactory.t.sol
+7
-7
FaultDisputeGame.t.sol
packages/contracts-bedrock/test/FaultDisputeGame.t.sol
+9
-12
MIPS.t.sol
packages/contracts-bedrock/test/MIPS.t.sol
+7
-6
No files found.
op-bindings/bindings/faultdisputegame.go
View file @
1d230d23
This diff is collapsed.
Click to expand it.
op-bindings/bindings/faultdisputegame_more.go
View file @
1d230d23
This diff is collapsed.
Click to expand it.
packages/contracts-bedrock/semver-lock.json
View file @
1d230d23
...
@@ -16,7 +16,7 @@
...
@@ -16,7 +16,7 @@
"src/L2/L2StandardBridge.sol"
:
"0xe025dcccbf21d48828ecf588941c9ba04c91b87bdd177a653d3f1b265b0b02a8"
,
"src/L2/L2StandardBridge.sol"
:
"0xe025dcccbf21d48828ecf588941c9ba04c91b87bdd177a653d3f1b265b0b02a8"
,
"src/L2/L2ToL1MessagePasser.sol"
:
"0xda56ba2e5b2c28fa8ca2df24077d49e96155a00ecc99cd0778d681be6ed166fe"
,
"src/L2/L2ToL1MessagePasser.sol"
:
"0xda56ba2e5b2c28fa8ca2df24077d49e96155a00ecc99cd0778d681be6ed166fe"
,
"src/L2/SequencerFeeVault.sol"
:
"0x37816035c992d38cf7e3d5a1846b02d017dd7bdca46abe6e5c5171b9ee6225ab"
,
"src/L2/SequencerFeeVault.sol"
:
"0x37816035c992d38cf7e3d5a1846b02d017dd7bdca46abe6e5c5171b9ee6225ab"
,
"src/dispute/FaultDisputeGame.sol"
:
"0x
b965888c2ea9e8dda89d6b5041c05b445568c8819b6616bba15ecf61fa112045
"
,
"src/dispute/FaultDisputeGame.sol"
:
"0x
80a0571e79b452c086e5432606c26ff548d2ae4443d0836833302c2989b0a1ea
"
,
"src/legacy/DeployerWhitelist.sol"
:
"0xf2129ec3da75307ba8e21bc943c332bb04704642e6e263149b5c8ee92dbcb7a8"
,
"src/legacy/DeployerWhitelist.sol"
:
"0xf2129ec3da75307ba8e21bc943c332bb04704642e6e263149b5c8ee92dbcb7a8"
,
"src/legacy/L1BlockNumber.sol"
:
"0x30aae1fc85103476af0226b6e98c71c01feebbdc35d93401390b1ad438a37be6"
,
"src/legacy/L1BlockNumber.sol"
:
"0x30aae1fc85103476af0226b6e98c71c01feebbdc35d93401390b1ad438a37be6"
,
"src/legacy/LegacyMessagePasser.sol"
:
"0x5c08b0a663cc49d30e4e38540f6aefab19ef287c3ecd31c8d8c3decd5f5bd497"
,
"src/legacy/LegacyMessagePasser.sol"
:
"0x5c08b0a663cc49d30e4e38540f6aefab19ef287c3ecd31c8d8c3decd5f5bd497"
,
...
...
packages/contracts-bedrock/src/dispute/FaultDisputeGame.sol
View file @
1d230d23
...
@@ -449,7 +449,9 @@ contract FaultDisputeGame is IFaultDisputeGame, Clone, Semver {
...
@@ -449,7 +449,9 @@ contract FaultDisputeGame is IFaultDisputeGame, Clone, Semver {
// The VMStatus must indicate (1) 'invalid', to argue that disputed thing is invalid.
// The VMStatus must indicate (1) 'invalid', to argue that disputed thing is invalid.
// Games that agree with the existing outcome are not allowed.
// Games that agree with the existing outcome are not allowed.
// NOTE(clabby): This assumption will change in Alpha Chad.
// NOTE(clabby): This assumption will change in Alpha Chad.
if (uint8(Claim.unwrap(rootClaim())[0]) != 1) revert UnexpectedRootClaim(rootClaim());
if (uint8(Claim.unwrap(rootClaim())[0]) != VMStatus.unwrap(VMStatuses.INVALID)) {
revert UnexpectedRootClaim(rootClaim());
}
// Set the game's starting timestamp
// Set the game's starting timestamp
createdAt = Timestamp.wrap(uint64(block.timestamp));
createdAt = Timestamp.wrap(uint64(block.timestamp));
...
...
packages/contracts-bedrock/src/libraries/DisputeTypes.sol
View file @
1d230d23
...
@@ -62,6 +62,9 @@ type Position is uint128;
...
@@ -62,6 +62,9 @@ type Position is uint128;
/// @notice A `GameType` represents the type of game being played.
/// @notice A `GameType` represents the type of game being played.
type GameType is uint8;
type GameType is uint8;
/// @notice A `VMStatus` represents the status of a VM execution.
type VMStatus is uint8;
/// @notice The current status of the dispute game.
/// @notice The current status of the dispute game.
enum GameStatus
enum GameStatus
// The game is currently in progress, and has not been resolved.
// The game is currently in progress, and has not been resolved.
...
@@ -85,3 +88,18 @@ library GameTypes {
...
@@ -85,3 +88,18 @@ library GameTypes {
/// @dev The game will use a `IDisputeGame` implementation that utilizes attestation proofs.
/// @dev The game will use a `IDisputeGame` implementation that utilizes attestation proofs.
GameType internal constant ATTESTATION = GameType.wrap(2);
GameType internal constant ATTESTATION = GameType.wrap(2);
}
}
/// @title VMStatuses
library VMStatuses {
/// @dev The VM has executed successfully and the outcome is valid.
VMStatus internal constant VALID = VMStatus.wrap(0);
/// @dev The VM has executed successfully and the outcome is invalid.
VMStatus internal constant INVALID = VMStatus.wrap(1);
/// @dev The VM has paniced.
VMStatus internal constant PANIC = VMStatus.wrap(2);
/// @dev The VM execution is still in progress.
VMStatus internal constant UNFINISHED = VMStatus.wrap(3);
}
packages/contracts-bedrock/test/DisputeGameFactory.t.sol
View file @
1d230d23
...
@@ -42,7 +42,7 @@ contract DisputeGameFactory_Create_Test is DisputeGameFactory_Init {
...
@@ -42,7 +42,7 @@ contract DisputeGameFactory_Create_Test is DisputeGameFactory_Init {
// Ensure that the `gameType` is within the bounds of the `GameType` enum's possible values.
// Ensure that the `gameType` is within the bounds of the `GameType` enum's possible values.
GameType gt = GameType.wrap(uint8(bound(gameType, 0, 2)));
GameType gt = GameType.wrap(uint8(bound(gameType, 0, 2)));
// Ensure the rootClaim has a VMStatus that disagrees with the validity.
// Ensure the rootClaim has a VMStatus that disagrees with the validity.
rootClaim = changeClaimStatus(rootClaim,
1
);
rootClaim = changeClaimStatus(rootClaim,
VMStatuses.INVALID
);
// Set all three implementations to the same `FakeClone` contract.
// Set all three implementations to the same `FakeClone` contract.
for (uint8 i; i < 3; i++) {
for (uint8 i; i < 3; i++) {
...
@@ -71,7 +71,7 @@ contract DisputeGameFactory_Create_Test is DisputeGameFactory_Init {
...
@@ -71,7 +71,7 @@ contract DisputeGameFactory_Create_Test is DisputeGameFactory_Init {
// Ensure that the `gameType` is within the bounds of the `GameType` enum's possible values.
// Ensure that the `gameType` is within the bounds of the `GameType` enum's possible values.
GameType gt = GameType.wrap(uint8(bound(gameType, 0, 2)));
GameType gt = GameType.wrap(uint8(bound(gameType, 0, 2)));
// Ensure the rootClaim has a VMStatus that disagrees with the validity.
// Ensure the rootClaim has a VMStatus that disagrees with the validity.
rootClaim = changeClaimStatus(rootClaim,
1
);
rootClaim = changeClaimStatus(rootClaim,
VMStatuses.INVALID
);
vm.expectRevert(abi.encodeWithSelector(NoImplementation.selector, gt));
vm.expectRevert(abi.encodeWithSelector(NoImplementation.selector, gt));
factory.create(gt, rootClaim, extraData);
factory.create(gt, rootClaim, extraData);
...
@@ -82,7 +82,7 @@ contract DisputeGameFactory_Create_Test is DisputeGameFactory_Init {
...
@@ -82,7 +82,7 @@ contract DisputeGameFactory_Create_Test is DisputeGameFactory_Init {
// Ensure that the `gameType` is within the bounds of the `GameType` enum's possible values.
// Ensure that the `gameType` is within the bounds of the `GameType` enum's possible values.
GameType gt = GameType.wrap(uint8(bound(gameType, 0, 2)));
GameType gt = GameType.wrap(uint8(bound(gameType, 0, 2)));
// Ensure the rootClaim has a VMStatus that disagrees with the validity.
// Ensure the rootClaim has a VMStatus that disagrees with the validity.
rootClaim = changeClaimStatus(rootClaim,
1
);
rootClaim = changeClaimStatus(rootClaim,
VMStatuses.INVALID
);
// Set all three implementations to the same `FakeClone` contract.
// Set all three implementations to the same `FakeClone` contract.
for (uint8 i; i < 3; i++) {
for (uint8 i; i < 3; i++) {
...
@@ -106,10 +106,10 @@ contract DisputeGameFactory_Create_Test is DisputeGameFactory_Init {
...
@@ -106,10 +106,10 @@ contract DisputeGameFactory_Create_Test is DisputeGameFactory_Init {
factory.create(gt, rootClaim, extraData);
factory.create(gt, rootClaim, extraData);
}
}
function changeClaimStatus(Claim
claim, uint8 status) public pure returns (Claim _out
) {
function changeClaimStatus(Claim
_claim, VMStatus _status) public pure returns (Claim out_
) {
bytes32 hash = Claim.unwrap(claim);
assembly {
hash = bytes32((uint256(hash) & (~(uint256(0xff) << 248))) | (uint256(status) << 248));
out_ := or(and(not(shl(248, 0xFF)), _claim), shl(248, _status))
return Claim.wrap(hash);
}
}
}
}
}
...
...
packages/contracts-bedrock/test/FaultDisputeGame.t.sol
View file @
1d230d23
...
@@ -147,7 +147,7 @@ contract FaultDisputeGame_Test is FaultDisputeGame_Init {
...
@@ -147,7 +147,7 @@ contract FaultDisputeGame_Test is FaultDisputeGame_Init {
function testFuzz_initialize_badRootStatus_reverts(Claim rootClaim, bytes calldata extraData) public {
function testFuzz_initialize_badRootStatus_reverts(Claim rootClaim, bytes calldata extraData) public {
// Ensure that the `gameType` is within the bounds of the `GameType` enum's possible values.
// Ensure that the `gameType` is within the bounds of the `GameType` enum's possible values.
// Ensure the root claim does not have the correct VM status
// Ensure the root claim does not have the correct VM status
if (uint8(Claim.unwrap(rootClaim)[0]) == 1) rootClaim = changeClaimStatus(rootClaim,
0
);
if (uint8(Claim.unwrap(rootClaim)[0]) == 1) rootClaim = changeClaimStatus(rootClaim,
VMStatuses.VALID
);
vm.expectRevert(abi.encodeWithSelector(UnexpectedRootClaim.selector, rootClaim));
vm.expectRevert(abi.encodeWithSelector(UnexpectedRootClaim.selector, rootClaim));
factory.create(GameTypes.FAULT, rootClaim, extraData);
factory.create(GameTypes.FAULT, rootClaim, extraData);
...
@@ -460,10 +460,10 @@ contract FaultDisputeGame_Test is FaultDisputeGame_Init {
...
@@ -460,10 +460,10 @@ contract FaultDisputeGame_Test is FaultDisputeGame_Init {
return bytes32((uint256(h) & ~uint256(0xFF << 248)) | (1 << 248));
return bytes32((uint256(h) & ~uint256(0xFF << 248)) | (1 << 248));
}
}
function changeClaimStatus(Claim
claim, uint8 status) public pure returns (Claim _out
) {
function changeClaimStatus(Claim
_claim, VMStatus _status) public pure returns (Claim out_
) {
bytes32 hash = Claim.unwrap(claim);
assembly {
hash = bytes32((uint256(hash) & (~(uint256(0xff) << 248))) | (uint256(status) << 248));
out_ := or(and(not(shl(248, 0xFF)), _claim), shl(248, _status))
return Claim.wrap(hash);
}
}
}
}
}
...
@@ -1024,16 +1024,13 @@ contract AlphabetVM is IBigStepper {
...
@@ -1024,16 +1024,13 @@ contract AlphabetVM is IBigStepper {
}
}
// STF: n -> n + 1
// STF: n -> n + 1
postState_ = keccak256(abi.encode(traceIndex, claim + 1));
postState_ = keccak256(abi.encode(traceIndex, claim + 1));
uint256
status;
VMStatus
status;
if (traceIndex == traceLength - 1) {
if (traceIndex == traceLength - 1) {
// VmStatusInvalid
status = VMStatuses.INVALID;
status = 1;
} else if (traceIndex < traceLength - 1) {
} else if (traceIndex < traceLength - 1) {
// VmStatusUnfinished
status = VMStatuses.UNFINISHED;
status = 3;
} else {
} else {
// VmStatusPanic
status = VMStatuses.PANIC;
status = 2;
}
}
assembly {
assembly {
postState_ := or(and(postState_, not(shl(248, 0xFF))), shl(248, status))
postState_ := or(and(postState_, not(shl(248, 0xFF))), shl(248, status))
...
...
packages/contracts-bedrock/test/MIPS.t.sol
View file @
1d230d23
...
@@ -4,6 +4,7 @@ pragma solidity 0.8.15;
...
@@ -4,6 +4,7 @@ pragma solidity 0.8.15;
import { CommonTest } from "./CommonTest.t.sol";
import { CommonTest } from "./CommonTest.t.sol";
import { MIPS } from "src/cannon/MIPS.sol";
import { MIPS } from "src/cannon/MIPS.sol";
import { PreimageOracle } from "src/cannon/PreimageOracle.sol";
import { PreimageOracle } from "src/cannon/PreimageOracle.sol";
import "src/libraries/DisputeTypes.sol";
contract MIPS_Test is CommonTest {
contract MIPS_Test is CommonTest {
MIPS internal mips;
MIPS internal mips;
...
@@ -1558,23 +1559,23 @@ contract MIPS_Test is CommonTest {
...
@@ -1558,23 +1559,23 @@ contract MIPS_Test is CommonTest {
/// 1. Exited with success (Invalid)
/// 1. Exited with success (Invalid)
/// 2. Exited with failure (Panic)
/// 2. Exited with failure (Panic)
/// 3. Unfinished
/// 3. Unfinished
function vmStatus(MIPS.State memory state) internal pure returns (
uint256
out_) {
function vmStatus(MIPS.State memory state) internal pure returns (
VMStatus
out_) {
if (state.exited) {
if (state.exited) {
if (state.exitCode == 0) {
if (state.exitCode == 0) {
return
0
;
return
VMStatuses.VALID
;
} else if (state.exitCode == 1) {
} else if (state.exitCode == 1) {
return
1
;
return
VMStatuses.INVALID
;
} else {
} else {
return
2
;
return
VMStatuses.PANIC
;
}
}
} else {
} else {
return
3
;
return
VMStatuses.UNFINISHED
;
}
}
}
}
function outputState(MIPS.State memory state) internal pure returns (bytes32 out_) {
function outputState(MIPS.State memory state) internal pure returns (bytes32 out_) {
bytes memory enc = encodeState(state);
bytes memory enc = encodeState(state);
uint256
status = vmStatus(state);
VMStatus
status = vmStatus(state);
assembly {
assembly {
out_ := keccak256(add(enc, 0x20), 226)
out_ := keccak256(add(enc, 0x20), 226)
out_ := or(and(not(shl(248, 0xFF)), out_), shl(248, status))
out_ := or(and(not(shl(248, 0xFF)), out_), shl(248, status))
...
...
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