Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ctb): LibGameType downcast fix #10152

Merged
merged 2 commits into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion op-bindings/bindings/disputegamefactory.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion op-bindings/bindings/disputegamefactory_more.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion op-bindings/bindingspreview/optimismportal2.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion op-bindings/bindingspreview/optimismportal2_more.go

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions packages/contracts-bedrock/semver-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"sourceCodeHash": "0xd3450653cecc14bf8fbc21f2fa9b4a5fde348c2b6313d72e74e08666201295a2"
},
"src/L1/OptimismPortal2.sol": {
"initCodeHash": "0x428eb70b0212733b6271d885741da959ba95e310bf963ead9f7e93a6846eb9ea",
"initCodeHash": "0x12407ad2db89ab758460e1cbd93bdc61fc3c30b20acab6ab61c96c51767c16f6",
"sourceCodeHash": "0x1cd093d048b893846319bc242c8dd5744de1f675e87551de423e0ae4ab3216e1"
},
"src/L1/ProtocolVersions.sol": {
Expand Down Expand Up @@ -108,8 +108,8 @@
"sourceCodeHash": "0xba941ad1f941f5a4a066182d50634fa9b190085ed82779decef71c019ba963c5"
},
"src/dispute/DisputeGameFactory.sol": {
"initCodeHash": "0xcbf28ecd117cbcbb9cea34dd75d2d0afbdc42865311b6fa94f23958c26186ab3",
"sourceCodeHash": "0x08f34cec56d58ea6ee7a47b5adcbeca6a68a5dd1daa949330b4bde86c2e605f5"
"initCodeHash": "0x3d65d1afd2ba6cd7ebb194859390579fd5dd95c1e18ca9a74f00d95a3a4de4fa",
"sourceCodeHash": "0xc4dbd17217b63f8117f56f78c213e57dda304fee7577fe296e1d804ebe049542"
},
"src/dispute/FaultDisputeGame.sol": {
"initCodeHash": "0x42c04ec50860cf8f1f772bc77dcbd20e7e06554a0962d16eaad2ee5fd748cfe0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ contract DisputeGameFactory is OwnableUpgradeable, IDisputeGameFactory, ISemver
using LibClone for address;

/// @notice Semantic version.
/// @custom:semver 0.5.0
string public constant version = "0.5.0";
/// @custom:semver 0.6.0
string public constant version = "0.6.0";

/// @inheritdoc IDisputeGameFactory
mapping(GameType => IDisputeGame) public gameImpls;
Expand Down
6 changes: 3 additions & 3 deletions packages/contracts-bedrock/src/dispute/lib/LibUDT.sol
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,10 @@ library LibVMStatus {
/// @title LibGameType
/// @notice This library contains helper functions for working with the `GameType` type.
library LibGameType {
/// @notice Get the value of a `GameType` type in the form of the underlying uint8.
/// @notice Get the value of a `GameType` type in the form of the underlying uint32.
/// @param _gametype The `GameType` type to get the value of.
/// @return gametype_ The value of the `GameType` type as a uint8 type.
function raw(GameType _gametype) internal pure returns (uint8 gametype_) {
/// @return gametype_ The value of the `GameType` type as a uint32 type.
function raw(GameType _gametype) internal pure returns (uint32 gametype_) {
assembly {
gametype_ := _gametype
}
Expand Down
6 changes: 3 additions & 3 deletions packages/contracts-bedrock/src/libraries/DisputeTypes.sol
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ type Timestamp is uint64;
/// @dev Unit: seconds
type Duration is uint64;

/// @notice A `GameId` represents a packed 1 byte game ID, an 11 byte timestamp, and a 20 byte address.
/// @notice A `GameId` represents a packed 4 byte game ID, a 8 byte timestamp, and a 20 byte address.
/// @dev The packed layout of this type is as follows:
/// ┌───────────┬───────────┐
/// │ Bits │ Value │
/// ├───────────┼───────────┤
/// │ [0, 8) │ Game Type │
/// │ [8, 96) │ Timestamp │
/// │ [0, 32) │ Game Type │
/// │ [32, 96) │ Timestamp │
/// │ [96, 256) │ Address │
/// └───────────┴───────────┘
type GameId is bytes32;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ contract DisputeGameFactory_Create_Test is DisputeGameFactory_Init {
/// @dev Tests that the `create` function succeeds when creating a new dispute game
/// with a `GameType` that has an implementation set.
function testFuzz_create_succeeds(
uint8 gameType,
uint32 gameType,
Claim rootClaim,
bytes calldata extraData,
uint256 _value
Expand Down Expand Up @@ -74,7 +74,7 @@ contract DisputeGameFactory_Create_Test is DisputeGameFactory_Init {

/// @dev Tests that the `create` function reverts when creating a new dispute game with an incorrect bond amount.
function testFuzz_create_incorrectBondAmount_reverts(
uint8 gameType,
uint32 gameType,
Claim rootClaim,
bytes calldata extraData
)
Expand Down Expand Up @@ -110,7 +110,7 @@ contract DisputeGameFactory_Create_Test is DisputeGameFactory_Init {
}

/// @dev Tests that the `create` function reverts when there exists a dispute game with the same UUID.
function testFuzz_create_sameUUID_reverts(uint8 gameType, Claim rootClaim, bytes calldata extraData) public {
function testFuzz_create_sameUUID_reverts(uint32 gameType, Claim rootClaim, bytes calldata extraData) public {
// Ensure that the `gameType` is within the bounds of the `GameType` enum's possible values.
GameType gt = GameType.wrap(uint8(bound(gameType, 0, 2)));
// Ensure the rootClaim has a VMStatus that disagrees with the validity.
Expand Down Expand Up @@ -195,7 +195,7 @@ contract DisputeGameFactory_SetInitBond_Test is DisputeGameFactory_Init {
contract DisputeGameFactory_GetGameUUID_Test is DisputeGameFactory_Init {
/// @dev Tests that the `getGameUUID` function returns the correct hash when comparing
/// against the keccak256 hash of the abi-encoded parameters.
function testDiff_getGameUUID_succeeds(uint8 gameType, Claim rootClaim, bytes calldata extraData) public {
function testDiff_getGameUUID_succeeds(uint32 gameType, Claim rootClaim, bytes calldata extraData) public {
// Ensure that the `gameType` is within the bounds of the `GameType` enum's possible values.
GameType gt = GameType.wrap(uint8(bound(gameType, 0, 2)));

Expand Down Expand Up @@ -328,7 +328,7 @@ contract DisputeGameFactory_FindLatestGames_Test is DisputeGameFactory_Init {

// Create `_numGames` dispute games, with at least `_numSearchedGames` games.
for (uint256 i; i < _numGames; i++) {
uint8 gameType = i < _numSearchedGames ? 0 : 1;
uint32 gameType = i < _numSearchedGames ? 0 : 1;
disputeGameFactory.create(GameType.wrap(gameType), Claim.wrap(bytes32(i)), abi.encode(i));
}

Expand Down