Commit 619e57db authored by clabby's avatar clabby Committed by Mark Tyneway

Change `GameType` from an `enum` -> `uint8`

lint
parent 124799db
This diff is collapsed.
...@@ -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: 11169) DisputeGameFactory_Test:test_setImplementation_notOwner_reverts() (gas: 11077)
DisputeGameFactory_Test:test_setImplementation_succeeds() (gas: 38743) DisputeGameFactory_Test:test_setImplementation_succeeds() (gas: 38320)
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
...@@ -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
......
...@@ -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, GameTypes.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, GameTypes.ATTESTATION,
caller.rootClaim(), caller.rootClaim(),
caller.extraData() caller.extraData()
); );
......
...@@ -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);
} }
...@@ -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 = GameTypes.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 = GameTypes.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 GameTypes.ATTESTATION;
} }
function rootClaim() external view returns (Claim _rootClaim) { function rootClaim() external view returns (Claim _rootClaim) {
......
...@@ -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 `GameTypes.FAULT` enum value, it has not been set.
assertEq(address(factory.gameImpls(GameType.FAULT)), address(0)); assertEq(address(factory.gameImpls(GameTypes.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), GameTypes.FAULT);
// Set the implementation for the `GameType.FAULT` enum value. // Set the implementation for the `GameTypes.FAULT` enum value.
factory.setImplementation(GameType.FAULT, IDisputeGame(address(1))); factory.setImplementation(GameTypes.FAULT, IDisputeGame(address(1)));
// Ensure that the implementation for the `GameType.FAULT` enum value is set. // Ensure that the implementation for the `GameTypes.FAULT` enum value is set.
assertEq(address(factory.gameImpls(GameType.FAULT)), address(1)); assertEq(address(factory.gameImpls(GameTypes.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(GameTypes.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)),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment