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
619e57db
Commit
619e57db
authored
Jun 10, 2023
by
clabby
Committed by
Mark Tyneway
Jun 13, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change `GameType` from an `enum` -> `uint8`
lint
parent
124799db
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
52 additions
and
38 deletions
+52
-38
disputegamefactory.go
op-bindings/bindings/disputegamefactory.go
+2
-2
.gas-snapshot
packages/contracts-bedrock/.gas-snapshot
+3
-3
.storage-layout
packages/contracts-bedrock/.storage-layout
+6
-6
BondManager.sol
packages/contracts-bedrock/contracts/dispute/BondManager.sol
+2
-2
DisputeTypes.sol
...es/contracts-bedrock/contracts/libraries/DisputeTypes.sol
+22
-8
BondManager.t.sol
packages/contracts-bedrock/contracts/test/BondManager.t.sol
+3
-3
DisputeGameFactory.t.sol
...contracts-bedrock/contracts/test/DisputeGameFactory.t.sol
+14
-14
No files found.
op-bindings/bindings/disputegamefactory.go
View file @
619e57db
This diff is collapsed.
Click to expand it.
packages/contracts-bedrock/.gas-snapshot
View file @
619e57db
...
@@ -28,8 +28,8 @@ CrossDomainOwnable_Test:test_onlyOwner_succeeds() (gas: 34883)
...
@@ -28,8 +28,8 @@ CrossDomainOwnable_Test:test_onlyOwner_succeeds() (gas: 34883)
DeployerWhitelist_Test:test_owner_succeeds() (gas: 7582)
DeployerWhitelist_Test:test_owner_succeeds() (gas: 7582)
DeployerWhitelist_Test:test_storageSlots_succeeds() (gas: 33395)
DeployerWhitelist_Test:test_storageSlots_succeeds() (gas: 33395)
DisputeGameFactory_Test:test_owner_succeeds() (gas: 7627)
DisputeGameFactory_Test:test_owner_succeeds() (gas: 7627)
DisputeGameFactory_Test:test_setImplementation_notOwner_reverts() (gas: 11
169
)
DisputeGameFactory_Test:test_setImplementation_notOwner_reverts() (gas: 11
077
)
DisputeGameFactory_Test:test_setImplementation_succeeds() (gas: 38
743
)
DisputeGameFactory_Test:test_setImplementation_succeeds() (gas: 38
320
)
DisputeGameFactory_Test:test_transferOwnership_notOwner_reverts() (gas: 10979)
DisputeGameFactory_Test:test_transferOwnership_notOwner_reverts() (gas: 10979)
DisputeGameFactory_Test:test_transferOwnership_succeeds() (gas: 13225)
DisputeGameFactory_Test:test_transferOwnership_succeeds() (gas: 13225)
FeeVault_Test:test_constructor_succeeds() (gas: 18185)
FeeVault_Test:test_constructor_succeeds() (gas: 18185)
...
@@ -435,4 +435,4 @@ SystemConfig_Setters_TestFail:test_setResourceConfig_notOwner_reverts() (gas: 11
...
@@ -435,4 +435,4 @@ SystemConfig_Setters_TestFail:test_setResourceConfig_notOwner_reverts() (gas: 11
SystemConfig_Setters_TestFail:test_setResourceConfig_zeroDenominator_reverts() (gas: 13039)
SystemConfig_Setters_TestFail:test_setResourceConfig_zeroDenominator_reverts() (gas: 13039)
SystemConfig_Setters_TestFail:test_setUnsafeBlockSigner_notOwner_reverts() (gas: 10616)
SystemConfig_Setters_TestFail:test_setUnsafeBlockSigner_notOwner_reverts() (gas: 10616)
TransferOnionTest:test_constructor_succeeds() (gas: 564855)
TransferOnionTest:test_constructor_succeeds() (gas: 564855)
TransferOnionTest:test_unwrap_succeeds() (gas: 724955)
TransferOnionTest:test_unwrap_succeeds() (gas: 724955)
\ No newline at end of file
packages/contracts-bedrock/.storage-layout
View file @
619e57db
...
@@ -253,12 +253,12 @@
...
@@ -253,12 +253,12 @@
➡ contracts/dispute/DisputeGameFactory.sol:DisputeGameFactory
➡ contracts/dispute/DisputeGameFactory.sol:DisputeGameFactory
=======================
=======================
| Name | Type
| Slot | Offset | Bytes | Contract |
| Name | Type | Slot | Offset | Bytes | Contract |
|-----------------|--------------------------------------------
-----
|------|--------|-------|-------------------------------------------------------------|
|-----------------|--------------------------------------------|------|--------|-------|-------------------------------------------------------------|
| _owner | address
| 0 | 0 | 20 | contracts/dispute/DisputeGameFactory.sol:DisputeGameFactory |
| _owner | address | 0 | 0 | 20 | contracts/dispute/DisputeGameFactory.sol:DisputeGameFactory |
| gameImpls | mapping(
enum
GameType => contract IDisputeGame) | 1 | 0 | 32 | contracts/dispute/DisputeGameFactory.sol:DisputeGameFactory |
| gameImpls | mapping(GameType => contract IDisputeGame) | 1 | 0 | 32 | contracts/dispute/DisputeGameFactory.sol:DisputeGameFactory |
| disputeGames | mapping(Hash => contract IDisputeGame)
| 2 | 0 | 32 | contracts/dispute/DisputeGameFactory.sol:DisputeGameFactory |
| disputeGames | mapping(Hash => contract IDisputeGame) | 2 | 0 | 32 | contracts/dispute/DisputeGameFactory.sol:DisputeGameFactory |
| disputeGameList | contract IDisputeGame[]
| 3 | 0 | 32 | contracts/dispute/DisputeGameFactory.sol:DisputeGameFactory |
| disputeGameList | contract IDisputeGame[] | 3 | 0 | 32 | contracts/dispute/DisputeGameFactory.sol:DisputeGameFactory |
=======================
=======================
➡ contracts/dispute/BondManager.sol:BondManager
➡ contracts/dispute/BondManager.sol:BondManager
...
...
packages/contracts-bedrock/contracts/dispute/BondManager.sol
View file @
619e57db
...
@@ -83,7 +83,7 @@ contract BondManager is IBondManager {
...
@@ -83,7 +83,7 @@ contract BondManager is IBondManager {
IDisputeGame caller = IDisputeGame(msg.sender);
IDisputeGame caller = IDisputeGame(msg.sender);
IDisputeGame game = DISPUTE_GAME_FACTORY.games(
IDisputeGame game = DISPUTE_GAME_FACTORY.games(
GameType.ATTESTATION,
GameType
s
.ATTESTATION,
caller.rootClaim(),
caller.rootClaim(),
caller.extraData()
caller.extraData()
);
);
...
@@ -108,7 +108,7 @@ contract BondManager is IBondManager {
...
@@ -108,7 +108,7 @@ contract BondManager is IBondManager {
IDisputeGame caller = IDisputeGame(msg.sender);
IDisputeGame caller = IDisputeGame(msg.sender);
IDisputeGame game = DISPUTE_GAME_FACTORY.games(
IDisputeGame game = DISPUTE_GAME_FACTORY.games(
GameType.ATTESTATION,
GameType
s
.ATTESTATION,
caller.rootClaim(),
caller.rootClaim(),
caller.extraData()
caller.extraData()
);
);
...
...
packages/contracts-bedrock/contracts/libraries/DisputeTypes.sol
View file @
619e57db
...
@@ -57,6 +57,11 @@ type Clock is uint256;
...
@@ -57,6 +57,11 @@ type Clock is uint256;
*/
*/
type Position is uint256;
type Position is uint256;
/**
* @notice A `GameType` represents the type of game being played.
*/
type GameType is uint8;
/**
/**
* @notice The current status of the dispute game.
* @notice The current status of the dispute game.
*/
*/
...
@@ -70,13 +75,22 @@ enum GameStatus {
...
@@ -70,13 +75,22 @@ enum GameStatus {
}
}
/**
/**
* @notice The type of proof system being used.
* @title GameTypes
* @notice A library that defines the IDs of games that can be played.
*/
*/
enum GameType {
library GameTypes {
// The game will use a `IDisputeGame` implementation that utilizes fault proofs.
/**
FAULT,
* @dev The game will use a `IDisputeGame` implementation that utilizes fault proofs.
// The game will use a `IDisputeGame` implementation that utilizes validity proofs.
*/
VALIDITY,
GameType internal constant FAULT = GameType.wrap(0);
// The game will use a `IDisputeGame` implementation that utilizes attestation proofs.
ATTESTATION
/**
* @dev The game will use a `IDisputeGame` implementation that utilizes validity proofs.
*/
GameType internal constant VALIDITY = GameType.wrap(1);
/**
* @dev The game will use a `IDisputeGame` implementation that utilizes attestation proofs.
*/
GameType internal constant ATTESTATION = GameType.wrap(2);
}
}
packages/contracts-bedrock/contracts/test/BondManager.t.sol
View file @
619e57db
...
@@ -208,7 +208,7 @@ contract BondManager_Test is Test {
...
@@ -208,7 +208,7 @@ contract BondManager_Test is Test {
{
{
rootClaim = Claim.wrap(bytes32(""));
rootClaim = Claim.wrap(bytes32(""));
MockAttestationDisputeGame implementation = new MockAttestationDisputeGame();
MockAttestationDisputeGame implementation = new MockAttestationDisputeGame();
GameType gt = GameType.ATTESTATION;
GameType gt = GameType
s
.ATTESTATION;
factory.setImplementation(gt, IDisputeGame(address(implementation)));
factory.setImplementation(gt, IDisputeGame(address(implementation)));
vm.expectEmit(false, true, true, false);
vm.expectEmit(false, true, true, false);
emit DisputeGameCreated(address(0), gt, rootClaim);
emit DisputeGameCreated(address(0), gt, rootClaim);
...
@@ -261,7 +261,7 @@ contract BondManager_Test is Test {
...
@@ -261,7 +261,7 @@ contract BondManager_Test is Test {
{
{
rootClaim = Claim.wrap(bytes32(""));
rootClaim = Claim.wrap(bytes32(""));
MockAttestationDisputeGame implementation = new MockAttestationDisputeGame();
MockAttestationDisputeGame implementation = new MockAttestationDisputeGame();
GameType gt = GameType.ATTESTATION;
GameType gt = GameType
s
.ATTESTATION;
factory.setImplementation(gt, IDisputeGame(address(implementation)));
factory.setImplementation(gt, IDisputeGame(address(implementation)));
vm.expectEmit(false, true, true, false);
vm.expectEmit(false, true, true, false);
emit DisputeGameCreated(address(0), gt, rootClaim);
emit DisputeGameCreated(address(0), gt, rootClaim);
...
@@ -418,7 +418,7 @@ contract MockAttestationDisputeGame {
...
@@ -418,7 +418,7 @@ contract MockAttestationDisputeGame {
}
}
function gameType() external pure returns (GameType _gameType) {
function gameType() external pure returns (GameType _gameType) {
return GameType.ATTESTATION;
return GameType
s
.ATTESTATION;
}
}
function rootClaim() external view returns (Claim _rootClaim) {
function rootClaim() external view returns (Claim _rootClaim) {
...
...
packages/contracts-bedrock/contracts/test/DisputeGameFactory.t.sol
View file @
619e57db
...
@@ -35,11 +35,11 @@ contract DisputeGameFactory_Test is Test {
...
@@ -35,11 +35,11 @@ contract DisputeGameFactory_Test is Test {
bytes calldata extraData
bytes calldata extraData
) public {
) 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.
GameType gt = GameType(uint8(bound(gameType, 0, 2)));
GameType gt = GameType
.wrap
(uint8(bound(gameType, 0, 2)));
// 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++) {
factory.setImplementation(GameType(i), IDisputeGame(address(fakeClone)));
factory.setImplementation(GameType
.wrap
(i), IDisputeGame(address(fakeClone)));
}
}
vm.expectEmit(false, true, true, false);
vm.expectEmit(false, true, true, false);
...
@@ -62,7 +62,7 @@ contract DisputeGameFactory_Test is Test {
...
@@ -62,7 +62,7 @@ contract DisputeGameFactory_Test is Test {
bytes calldata extraData
bytes calldata extraData
) public {
) 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.
GameType gt = GameType(uint8(bound(gameType, 0, 2)));
GameType gt = GameType
.wrap
(uint8(bound(gameType, 0, 2)));
vm.expectRevert(abi.encodeWithSelector(NoImplementation.selector, gt));
vm.expectRevert(abi.encodeWithSelector(NoImplementation.selector, gt));
factory.create(gt, rootClaim, extraData);
factory.create(gt, rootClaim, extraData);
...
@@ -77,11 +77,11 @@ contract DisputeGameFactory_Test is Test {
...
@@ -77,11 +77,11 @@ contract DisputeGameFactory_Test is Test {
bytes calldata extraData
bytes calldata extraData
) public {
) 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.
GameType gt = GameType(uint8(bound(gameType, 0, 2)));
GameType gt = GameType
.wrap
(uint8(bound(gameType, 0, 2)));
// 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++) {
factory.setImplementation(GameType(i), IDisputeGame(address(fakeClone)));
factory.setImplementation(GameType
.wrap
(i), IDisputeGame(address(fakeClone)));
}
}
// Create our first dispute game - this should succeed.
// Create our first dispute game - this should succeed.
...
@@ -106,17 +106,17 @@ contract DisputeGameFactory_Test is Test {
...
@@ -106,17 +106,17 @@ contract DisputeGameFactory_Test is Test {
* @dev Tests that the `setImplementation` function properly sets the implementation for a given `GameType`.
* @dev Tests that the `setImplementation` function properly sets the implementation for a given `GameType`.
*/
*/
function test_setImplementation_succeeds() public {
function test_setImplementation_succeeds() public {
// There should be no implementation for the `GameType.FAULT` enum value, it has not been set.
// There should be no implementation for the `GameType
s
.FAULT` enum value, it has not been set.
assertEq(address(factory.gameImpls(GameType.FAULT)), address(0));
assertEq(address(factory.gameImpls(GameType
s
.FAULT)), address(0));
vm.expectEmit(true, true, true, true, address(factory));
vm.expectEmit(true, true, true, true, address(factory));
emit ImplementationSet(address(1), GameType.FAULT);
emit ImplementationSet(address(1), GameType
s
.FAULT);
// Set the implementation for the `GameType.FAULT` enum value.
// Set the implementation for the `GameType
s
.FAULT` enum value.
factory.setImplementation(GameType.FAULT, IDisputeGame(address(1)));
factory.setImplementation(GameType
s
.FAULT, IDisputeGame(address(1)));
// Ensure that the implementation for the `GameType.FAULT` enum value is set.
// Ensure that the implementation for the `GameType
s
.FAULT` enum value is set.
assertEq(address(factory.gameImpls(GameType.FAULT)), address(1));
assertEq(address(factory.gameImpls(GameType
s
.FAULT)), address(1));
}
}
/**
/**
...
@@ -126,7 +126,7 @@ contract DisputeGameFactory_Test is Test {
...
@@ -126,7 +126,7 @@ contract DisputeGameFactory_Test is Test {
// Ensure that the `setImplementation` function reverts when called by a non-owner.
// Ensure that the `setImplementation` function reverts when called by a non-owner.
vm.prank(address(0));
vm.prank(address(0));
vm.expectRevert("Ownable: caller is not the owner");
vm.expectRevert("Ownable: caller is not the owner");
factory.setImplementation(GameType.FAULT, IDisputeGame(address(1)));
factory.setImplementation(GameType
s
.FAULT, IDisputeGame(address(1)));
}
}
/**
/**
...
@@ -139,7 +139,7 @@ contract DisputeGameFactory_Test is Test {
...
@@ -139,7 +139,7 @@ contract DisputeGameFactory_Test is Test {
bytes calldata extraData
bytes calldata extraData
) public {
) 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.
GameType gt = GameType(uint8(bound(gameType, 0, 2)));
GameType gt = GameType
.wrap
(uint8(bound(gameType, 0, 2)));
assertEq(
assertEq(
Hash.unwrap(factory.getGameUUID(gt, rootClaim, extraData)),
Hash.unwrap(factory.getGameUUID(gt, rootClaim, extraData)),
...
...
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