diff --git a/packages/contracts-bedrock/scripts/Deploy.s.sol b/packages/contracts-bedrock/scripts/Deploy.s.sol index dd8b2f243dac5..58871ca1b4174 100644 --- a/packages/contracts-bedrock/scripts/Deploy.s.sol +++ b/packages/contracts-bedrock/scripts/Deploy.s.sol @@ -47,7 +47,7 @@ import { Config } from "scripts/Config.sol"; import { IBigStepper } from "src/dispute/interfaces/IBigStepper.sol"; import { IPreimageOracle } from "src/cannon/interfaces/IPreimageOracle.sol"; import { AlphabetVM } from "test/mocks/AlphabetVM.sol"; -import "src/libraries/DisputeTypes.sol"; +import "src/dispute/lib/Types.sol"; import { ChainAssertions } from "scripts/ChainAssertions.sol"; import { Types } from "scripts/Types.sol"; import { LibStateDiff } from "scripts/libraries/LibStateDiff.sol"; diff --git a/packages/contracts-bedrock/scripts/FaultDisputeGameViz.s.sol b/packages/contracts-bedrock/scripts/FaultDisputeGameViz.s.sol index 1d9ba743a56ba..ae370934f1e34 100644 --- a/packages/contracts-bedrock/scripts/FaultDisputeGameViz.s.sol +++ b/packages/contracts-bedrock/scripts/FaultDisputeGameViz.s.sol @@ -9,9 +9,8 @@ import { DisputeGameFactory } from "src/dispute/DisputeGameFactory.sol"; import { FaultDisputeGame } from "src/dispute/FaultDisputeGame.sol"; import { IFaultDisputeGame } from "src/dispute/interfaces/IFaultDisputeGame.sol"; -import "src/libraries/DisputeTypes.sol"; -import "src/libraries/DisputeErrors.sol"; -import { LibPosition } from "src/dispute/lib/LibPosition.sol"; +import "src/dispute/lib/Types.sol"; +import "src/dispute/lib/Errors.sol"; /** * @title FaultDisputeGameViz diff --git a/packages/contracts-bedrock/scripts/fpac/FPACOPS.s.sol b/packages/contracts-bedrock/scripts/fpac/FPACOPS.s.sol index fec27c83153d7..434b5274d9290 100644 --- a/packages/contracts-bedrock/scripts/fpac/FPACOPS.s.sol +++ b/packages/contracts-bedrock/scripts/fpac/FPACOPS.s.sol @@ -6,7 +6,7 @@ import { IDisputeGame } from "src/dispute/interfaces/IDisputeGame.sol"; import { AnchorStateRegistry, IAnchorStateRegistry } from "src/dispute/AnchorStateRegistry.sol"; import { IDelayedWETH } from "src/dispute/interfaces/IDelayedWETH.sol"; import { StdAssertions } from "forge-std/StdAssertions.sol"; -import "src/libraries/DisputeTypes.sol"; +import "src/dispute/lib/Types.sol"; import "scripts/Deploy.s.sol"; /// @notice Deploys the Fault Proof Alpha Chad contracts. diff --git a/packages/contracts-bedrock/semver-lock.json b/packages/contracts-bedrock/semver-lock.json index 17d50471fe268..75076be435a4e 100644 --- a/packages/contracts-bedrock/semver-lock.json +++ b/packages/contracts-bedrock/semver-lock.json @@ -37,7 +37,7 @@ }, "src/L1/OptimismPortal2.sol": { "initCodeHash": "0xea32d79e8297956d4f9a4c7985bb53ff8bb3735e5b307d4e118fea71f503a38e", - "sourceCodeHash": "0x2b662e100d1e282588eaaf3704aca0d0a6900ec3b8f8134e2d5d577ee372e42f" + "sourceCodeHash": "0x209d7e9ffa97a54c060f5d30e5d88684a50a7b4610336cf03880bfbc80ca669e" }, "src/L1/ProtocolVersions.sol": { "initCodeHash": "0x72cd467e8bcf019c02675d72ab762e088bcc9cc0f1a4e9f587fa4589f7fdd1b8", @@ -96,8 +96,8 @@ "sourceCodeHash": "0xa304b4b556162323d69662b4dd9a1d073d55ec661494465489bb67f1e465e7b3" }, "src/Safe/DeputyGuardianModule.sol": { - "initCodeHash": "0x8f6adc162587ac7150045c0cf4671f23e0453417a4b7006e39eb8cb58052dc58", - "sourceCodeHash": "0x8ebf09555561d475ec51c681033b8c567281f40f310ad47312b00710f6394d34" + "initCodeHash": "0x533a9dfab7fa1f7f5e8796f0ad78b4a16f93cd8ff3cddcce946691944f6416c0", + "sourceCodeHash": "0x82c7ea737cefeb2fda38a75c7165cbad9c902a0f22a13dd46f56050223e308ce" }, "src/Safe/LivenessGuard.sol": { "initCodeHash": "0x16ec47f0888391638814047a1735dbac849b48e256b2e20182bbb3186d950a3c", @@ -116,16 +116,16 @@ "sourceCodeHash": "0x292a950cfe01923558ead684f2e014b00bc17bc07362dbd58f45b1cc121942a9" }, "src/dispute/AnchorStateRegistry.sol": { - "initCodeHash": "0x2f8c56069e43e306b0e40fba43109188b29328e83569560021a68aa5d9f2486b", - "sourceCodeHash": "0xba941ad1f941f5a4a066182d50634fa9b190085ed82779decef71c019ba963c5" + "initCodeHash": "0x1d01bc6ff31eec22200919d7c78e1e17c13482d290386e950a3767002816164e", + "sourceCodeHash": "0x99fece0b7b5952bca60a998a8c47bfd3696e5268271d321011feea1bfb9df24d" }, "src/dispute/DisputeGameFactory.sol": { - "initCodeHash": "0x3d65d1afd2ba6cd7ebb194859390579fd5dd95c1e18ca9a74f00d95a3a4de4fa", - "sourceCodeHash": "0xc4dbd17217b63f8117f56f78c213e57dda304fee7577fe296e1d804ebe049542" + "initCodeHash": "0xfcb7178f7ed9e9ecb095d7e5252e4353d8f964d908de6914eb61a67ce69f2a63", + "sourceCodeHash": "0x3865908f3101bbb866cb103a4f23a35e54da863b0ff11b0aa56fe5ab72786601" }, "src/dispute/FaultDisputeGame.sol": { - "initCodeHash": "0x44407585a3dcf50d7e0d0f6c3d752fe5b18bb6837a9db138a2e0961757eb91c7", - "sourceCodeHash": "0x4f930a9e4577404887c03fd91ddfcbf9915bddcfb52e4ff8d7a00099c6ad0f29" + "initCodeHash": "0x1a645e296fa5a9a707726d9b79f5b87a9337198351c9c966e785389c1ddc745b", + "sourceCodeHash": "0xfc9256651556ac2a59b82e48b22e89c46e9a67327a84c308c9745d96ef410d1d" }, "src/dispute/weth/DelayedWETH.sol": { "initCodeHash": "0x7b6ec89eaec09e369426e73161a9c6932223bb1f974377190c3f6f552995da35", diff --git a/packages/contracts-bedrock/snapshots/abi/FaultDisputeGame.json b/packages/contracts-bedrock/snapshots/abi/FaultDisputeGame.json index da75eff9a1b00..e8c4133bb3170 100644 --- a/packages/contracts-bedrock/snapshots/abi/FaultDisputeGame.json +++ b/packages/contracts-bedrock/snapshots/abi/FaultDisputeGame.json @@ -200,7 +200,7 @@ { "inputs": [ { - "internalType": "ClaimHash", + "internalType": "Hash", "name": "", "type": "bytes32" } diff --git a/packages/contracts-bedrock/snapshots/abi/PermissionedDisputeGame.json b/packages/contracts-bedrock/snapshots/abi/PermissionedDisputeGame.json index 00942950a6dfc..272d4f3057abb 100644 --- a/packages/contracts-bedrock/snapshots/abi/PermissionedDisputeGame.json +++ b/packages/contracts-bedrock/snapshots/abi/PermissionedDisputeGame.json @@ -223,7 +223,7 @@ { "inputs": [ { - "internalType": "ClaimHash", + "internalType": "Hash", "name": "", "type": "bytes32" } diff --git a/packages/contracts-bedrock/snapshots/storageLayout/FaultDisputeGame.json b/packages/contracts-bedrock/snapshots/storageLayout/FaultDisputeGame.json index e32a31bc487c2..fdecec4967523 100644 --- a/packages/contracts-bedrock/snapshots/storageLayout/FaultDisputeGame.json +++ b/packages/contracts-bedrock/snapshots/storageLayout/FaultDisputeGame.json @@ -46,7 +46,7 @@ "label": "claims", "offset": 0, "slot": "3", - "type": "mapping(ClaimHash => bool)" + "type": "mapping(Hash => bool)" }, { "bytes": "32", diff --git a/packages/contracts-bedrock/snapshots/storageLayout/PermissionedDisputeGame.json b/packages/contracts-bedrock/snapshots/storageLayout/PermissionedDisputeGame.json index e32a31bc487c2..fdecec4967523 100644 --- a/packages/contracts-bedrock/snapshots/storageLayout/PermissionedDisputeGame.json +++ b/packages/contracts-bedrock/snapshots/storageLayout/PermissionedDisputeGame.json @@ -46,7 +46,7 @@ "label": "claims", "offset": 0, "slot": "3", - "type": "mapping(ClaimHash => bool)" + "type": "mapping(Hash => bool)" }, { "bytes": "32", diff --git a/packages/contracts-bedrock/src/L1/OptimismPortal2.sol b/packages/contracts-bedrock/src/L1/OptimismPortal2.sol index 838eaa2df9f21..cc7496a9c9943 100644 --- a/packages/contracts-bedrock/src/L1/OptimismPortal2.sol +++ b/packages/contracts-bedrock/src/L1/OptimismPortal2.sol @@ -16,7 +16,7 @@ import { ISemver } from "src/universal/ISemver.sol"; import { Constants } from "src/libraries/Constants.sol"; import "src/libraries/PortalErrors.sol"; -import "src/libraries/DisputeTypes.sol"; +import "src/dispute/lib/Types.sol"; /// @custom:proxied /// @title OptimismPortal2 diff --git a/packages/contracts-bedrock/src/Safe/DeputyGuardianModule.sol b/packages/contracts-bedrock/src/Safe/DeputyGuardianModule.sol index c0cf49c1daa7d..27a78ac3bbfcb 100644 --- a/packages/contracts-bedrock/src/Safe/DeputyGuardianModule.sol +++ b/packages/contracts-bedrock/src/Safe/DeputyGuardianModule.sol @@ -10,7 +10,7 @@ import { IDisputeGame } from "src/dispute/interfaces/IDisputeGame.sol"; import { ISemver } from "src/universal/ISemver.sol"; import { Unauthorized } from "src/libraries/PortalErrors.sol"; -import "src/libraries/DisputeTypes.sol"; +import "src/dispute/lib/Types.sol"; /// @title DeputyGuardianModule /// @notice This module is intended to be enabled on the Security Council Safe, which will own the Guardian role in the @@ -43,8 +43,8 @@ contract DeputyGuardianModule is ISemver { address internal immutable DEPUTY_GUARDIAN; /// @notice Semantic version. - /// @custom:semver 1.0.0 - string public constant version = "1.0.0"; + /// @custom:semver 1.0.1 + string public constant version = "1.0.1"; // Constructor to initialize the Safe and baseModule instances constructor(Safe _safe, SuperchainConfig _superchainConfig, address _deputyGuardian) { diff --git a/packages/contracts-bedrock/src/dispute/AnchorStateRegistry.sol b/packages/contracts-bedrock/src/dispute/AnchorStateRegistry.sol index f9fc42162f33d..8813c01b67e68 100644 --- a/packages/contracts-bedrock/src/dispute/AnchorStateRegistry.sol +++ b/packages/contracts-bedrock/src/dispute/AnchorStateRegistry.sol @@ -9,7 +9,7 @@ import { IFaultDisputeGame } from "src/dispute/interfaces/IFaultDisputeGame.sol" import { IDisputeGame } from "src/dispute/interfaces/IDisputeGame.sol"; import { IDisputeGameFactory } from "src/dispute/interfaces/IDisputeGameFactory.sol"; -import "src/libraries/DisputeTypes.sol"; +import "src/dispute/lib/Types.sol"; /// @title AnchorStateRegistry /// @notice The AnchorStateRegistry is a contract that stores the latest "anchor" state for each available @@ -24,8 +24,8 @@ contract AnchorStateRegistry is Initializable, IAnchorStateRegistry, ISemver { } /// @notice Semantic version. - /// @custom:semver 0.1.0 - string public constant version = "0.1.0"; + /// @custom:semver 0.1.1 + string public constant version = "0.1.1"; /// @notice DisputeGameFactory address. IDisputeGameFactory internal immutable DISPUTE_GAME_FACTORY; diff --git a/packages/contracts-bedrock/src/dispute/DisputeGameFactory.sol b/packages/contracts-bedrock/src/dispute/DisputeGameFactory.sol index a5921748427ef..4609fc690bb83 100644 --- a/packages/contracts-bedrock/src/dispute/DisputeGameFactory.sol +++ b/packages/contracts-bedrock/src/dispute/DisputeGameFactory.sol @@ -8,10 +8,8 @@ import { ISemver } from "src/universal/ISemver.sol"; import { IDisputeGame } from "src/dispute/interfaces/IDisputeGame.sol"; import { IDisputeGameFactory } from "src/dispute/interfaces/IDisputeGameFactory.sol"; -import { LibGameId } from "src/dispute/lib/LibGameId.sol"; - -import "src/libraries/DisputeTypes.sol"; -import "src/libraries/DisputeErrors.sol"; +import "src/dispute/lib/Types.sol"; +import "src/dispute/lib/Errors.sol"; /// @title DisputeGameFactory /// @notice A factory contract for creating `IDisputeGame` contracts. All created dispute games are stored in both a @@ -23,8 +21,8 @@ contract DisputeGameFactory is OwnableUpgradeable, IDisputeGameFactory, ISemver using LibClone for address; /// @notice Semantic version. - /// @custom:semver 0.6.0 - string public constant version = "0.6.0"; + /// @custom:semver 0.7.0 + string public constant version = "0.7.0"; /// @inheritdoc IDisputeGameFactory mapping(GameType => IDisputeGame) public gameImpls; @@ -68,7 +66,8 @@ contract DisputeGameFactory is OwnableUpgradeable, IDisputeGameFactory, ISemver returns (IDisputeGame proxy_, Timestamp timestamp_) { Hash uuid = getGameUUID(_gameType, _rootClaim, _extraData); - (, timestamp_, proxy_) = _disputeGames[uuid].unpack(); + (, Timestamp timestamp, address proxy) = _disputeGames[uuid].unpack(); + (proxy_, timestamp_) = (IDisputeGame(proxy), timestamp); } /// @inheritdoc IDisputeGameFactory @@ -77,7 +76,8 @@ contract DisputeGameFactory is OwnableUpgradeable, IDisputeGameFactory, ISemver view returns (GameType gameType_, Timestamp timestamp_, IDisputeGame proxy_) { - (gameType_, timestamp_, proxy_) = _disputeGameList[_index].unpack(); + (GameType gameType, Timestamp timestamp, address proxy) = _disputeGameList[_index].unpack(); + (gameType_, timestamp_, proxy_) = (gameType, timestamp, IDisputeGame(proxy)); } /// @inheritdoc IDisputeGameFactory @@ -123,7 +123,7 @@ contract DisputeGameFactory is OwnableUpgradeable, IDisputeGameFactory, ISemver if (GameId.unwrap(_disputeGames[uuid]) != bytes32(0)) revert GameAlreadyExists(uuid); // Pack the game ID. - GameId id = LibGameId.pack(_gameType, Timestamp.wrap(uint64(block.timestamp)), proxy_); + GameId id = LibGameId.pack(_gameType, Timestamp.wrap(uint64(block.timestamp)), address(proxy_)); // Store the dispute game id in the mapping & emit the `DisputeGameCreated` event. _disputeGames[uuid] = id; @@ -167,7 +167,7 @@ contract DisputeGameFactory is OwnableUpgradeable, IDisputeGameFactory, ISemver // Perform a reverse linear search for the `_n` most recent games of type `_gameType`. for (uint256 i = _start; i >= 0 && i <= _start;) { GameId id = _disputeGameList[i]; - (GameType gameType, Timestamp timestamp, IDisputeGame proxy) = id.unpack(); + (GameType gameType, Timestamp timestamp, address proxy) = id.unpack(); if (gameType.raw() == _gameType.raw()) { // Increase the size of the `games_` array by 1. @@ -177,8 +177,8 @@ contract DisputeGameFactory is OwnableUpgradeable, IDisputeGameFactory, ISemver mstore(games_, add(mload(games_), 0x01)) } - bytes memory extraData = proxy.extraData(); - Claim rootClaim = proxy.rootClaim(); + bytes memory extraData = IDisputeGame(proxy).extraData(); + Claim rootClaim = IDisputeGame(proxy).rootClaim(); games_[games_.length - 1] = GameSearchResult({ index: i, metadata: id, diff --git a/packages/contracts-bedrock/src/dispute/FaultDisputeGame.sol b/packages/contracts-bedrock/src/dispute/FaultDisputeGame.sol index 726462e4fb204..24f46ed1d9fbb 100644 --- a/packages/contracts-bedrock/src/dispute/FaultDisputeGame.sol +++ b/packages/contracts-bedrock/src/dispute/FaultDisputeGame.sol @@ -13,10 +13,9 @@ import { IAnchorStateRegistry } from "src/dispute/interfaces/IAnchorStateRegistr import { Clone } from "@solady/utils/Clone.sol"; import { Types } from "src/libraries/Types.sol"; import { ISemver } from "src/universal/ISemver.sol"; -import { LibClock } from "src/dispute/lib/LibUDT.sol"; -import "src/libraries/DisputeTypes.sol"; -import "src/libraries/DisputeErrors.sol"; +import "src/dispute/lib/Types.sol"; +import "src/dispute/lib/Errors.sol"; /// @title FaultDisputeGame /// @notice An implementation of the `IFaultDisputeGame` interface. @@ -62,8 +61,8 @@ contract FaultDisputeGame is IFaultDisputeGame, Clone, ISemver { Position internal constant ROOT_POSITION = Position.wrap(1); /// @notice Semantic version. - /// @custom:semver 0.18.0 - string public constant version = "0.18.0"; + /// @custom:semver 0.18.1 + string public constant version = "0.18.1"; /// @notice The starting timestamp of the game Timestamp public createdAt; @@ -84,7 +83,7 @@ contract FaultDisputeGame is IFaultDisputeGame, Clone, ISemver { mapping(address => uint256) public credit; /// @notice A mapping to allow for constant-time lookups of existing claims. - mapping(ClaimHash => bool) public claims; + mapping(Hash => bool) public claims; /// @notice A mapping of subgames rooted at a claim index to other claim indices in the subgame. mapping(uint256 => uint256[]) public subgames; @@ -365,7 +364,7 @@ contract FaultDisputeGame is IFaultDisputeGame, Clone, ISemver { // INVARIANT: There cannot be multiple identical claims with identical moves on the same challengeIndex. Multiple // claims at the same position may dispute the same challengeIndex. However, they must have different // values. - ClaimHash claimHash = _claim.hashClaimPos(nextPosition, _challengeIndex); + Hash claimHash = _claim.hashClaimPos(nextPosition, _challengeIndex); if (claims[claimHash]) revert ClaimAlreadyExists(); claims[claimHash] = true; diff --git a/packages/contracts-bedrock/src/dispute/PermissionedDisputeGame.sol b/packages/contracts-bedrock/src/dispute/PermissionedDisputeGame.sol index e2a9975b45426..ba7c23ac6c02f 100644 --- a/packages/contracts-bedrock/src/dispute/PermissionedDisputeGame.sol +++ b/packages/contracts-bedrock/src/dispute/PermissionedDisputeGame.sol @@ -4,8 +4,8 @@ pragma solidity 0.8.15; import { IDelayedWETH } from "src/dispute/interfaces/IDelayedWETH.sol"; import { IAnchorStateRegistry } from "src/dispute/interfaces/IAnchorStateRegistry.sol"; import { FaultDisputeGame, IFaultDisputeGame, IBigStepper, IInitializable } from "src/dispute/FaultDisputeGame.sol"; -import "src/libraries/DisputeTypes.sol"; -import "src/libraries/DisputeErrors.sol"; +import "src/dispute/lib/Types.sol"; +import "src/dispute/lib/Errors.sol"; /// @title PermissionedDisputeGame /// @notice PermissionedDisputeGame is a contract that inherits from `FaultDisputeGame`, and contains two roles: diff --git a/packages/contracts-bedrock/src/dispute/interfaces/IAnchorStateRegistry.sol b/packages/contracts-bedrock/src/dispute/interfaces/IAnchorStateRegistry.sol index b10a9dc7712e4..2294a76ef3036 100644 --- a/packages/contracts-bedrock/src/dispute/interfaces/IAnchorStateRegistry.sol +++ b/packages/contracts-bedrock/src/dispute/interfaces/IAnchorStateRegistry.sol @@ -3,7 +3,7 @@ pragma solidity ^0.8.0; import { IDisputeGameFactory } from "src/dispute/interfaces/IDisputeGameFactory.sol"; -import "src/libraries/DisputeTypes.sol"; +import "src/dispute/lib/Types.sol"; /// @title IAnchorStateRegistry /// @notice Describes a contract that stores the anchor state for each game type. diff --git a/packages/contracts-bedrock/src/dispute/interfaces/IDisputeGame.sol b/packages/contracts-bedrock/src/dispute/interfaces/IDisputeGame.sol index 4d2785687ec37..7e9389b4ddafb 100644 --- a/packages/contracts-bedrock/src/dispute/interfaces/IDisputeGame.sol +++ b/packages/contracts-bedrock/src/dispute/interfaces/IDisputeGame.sol @@ -3,7 +3,7 @@ pragma solidity ^0.8.0; import { IInitializable } from "src/dispute/interfaces/IInitializable.sol"; -import "src/libraries/DisputeTypes.sol"; +import "src/dispute/lib/Types.sol"; /// @title IDisputeGame /// @notice The generic interface for a DisputeGame contract. diff --git a/packages/contracts-bedrock/src/dispute/interfaces/IDisputeGameFactory.sol b/packages/contracts-bedrock/src/dispute/interfaces/IDisputeGameFactory.sol index e528057e8addf..5021de04d62a8 100644 --- a/packages/contracts-bedrock/src/dispute/interfaces/IDisputeGameFactory.sol +++ b/packages/contracts-bedrock/src/dispute/interfaces/IDisputeGameFactory.sol @@ -3,7 +3,7 @@ pragma solidity ^0.8.0; import { IDisputeGame } from "./IDisputeGame.sol"; -import "src/libraries/DisputeTypes.sol"; +import "src/dispute/lib/Types.sol"; /// @title IDisputeGameFactory /// @notice The interface for a DisputeGameFactory contract. diff --git a/packages/contracts-bedrock/src/dispute/interfaces/IFaultDisputeGame.sol b/packages/contracts-bedrock/src/dispute/interfaces/IFaultDisputeGame.sol index d4a784b4ed060..5d062faa80cf8 100644 --- a/packages/contracts-bedrock/src/dispute/interfaces/IFaultDisputeGame.sol +++ b/packages/contracts-bedrock/src/dispute/interfaces/IFaultDisputeGame.sol @@ -3,7 +3,7 @@ pragma solidity ^0.8.0; import { IDisputeGame } from "./IDisputeGame.sol"; -import "src/libraries/DisputeTypes.sol"; +import "src/dispute/lib/Types.sol"; /// @title IFaultDisputeGame /// @notice The interface for a fault proof backed dispute game. diff --git a/packages/contracts-bedrock/src/libraries/DisputeErrors.sol b/packages/contracts-bedrock/src/dispute/lib/Errors.sol similarity index 99% rename from packages/contracts-bedrock/src/libraries/DisputeErrors.sol rename to packages/contracts-bedrock/src/dispute/lib/Errors.sol index b179279bf19b6..c56051a4602ed 100644 --- a/packages/contracts-bedrock/src/libraries/DisputeErrors.sol +++ b/packages/contracts-bedrock/src/dispute/lib/Errors.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.15; -import "src/libraries/DisputeTypes.sol"; +import "src/dispute/lib/LibUDT.sol"; //////////////////////////////////////////////////////////////// // `DisputeGameFactory` Errors // diff --git a/packages/contracts-bedrock/src/dispute/lib/LibGameId.sol b/packages/contracts-bedrock/src/dispute/lib/LibGameId.sol deleted file mode 100644 index 2a4657b3246ed..0000000000000 --- a/packages/contracts-bedrock/src/dispute/lib/LibGameId.sol +++ /dev/null @@ -1,45 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.15; - -import "src/libraries/DisputeTypes.sol"; -import "src/dispute/interfaces/IDisputeGame.sol"; - -/// @title LibGameId -/// @notice Utility functions for packing and unpacking GameIds. -library LibGameId { - /// @notice Packs values into a 32 byte GameId type. - /// @param _gameType The game type. - /// @param _timestamp The timestamp of the game's creation. - /// @param _gameProxy The game proxy address. - /// @return gameId_ The packed GameId. - function pack( - GameType _gameType, - Timestamp _timestamp, - IDisputeGame _gameProxy - ) - internal - pure - returns (GameId gameId_) - { - assembly { - gameId_ := or(or(shl(224, _gameType), shl(160, _timestamp)), _gameProxy) - } - } - - /// @notice Unpacks values from a 32 byte GameId type. - /// @param _gameId The packed GameId. - /// @return gameType_ The game type. - /// @return timestamp_ The timestamp of the game's creation. - /// @return gameProxy_ The game proxy address. - function unpack(GameId _gameId) - internal - pure - returns (GameType gameType_, Timestamp timestamp_, IDisputeGame gameProxy_) - { - assembly { - gameType_ := shr(224, _gameId) - timestamp_ := and(shr(160, _gameId), 0xFFFFFFFFFFFFFFFF) - gameProxy_ := and(_gameId, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF) - } - } -} diff --git a/packages/contracts-bedrock/src/dispute/lib/LibHashing.sol b/packages/contracts-bedrock/src/dispute/lib/LibHashing.sol deleted file mode 100644 index 800eeb1bde67f..0000000000000 --- a/packages/contracts-bedrock/src/dispute/lib/LibHashing.sol +++ /dev/null @@ -1,29 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.15; - -import "src/libraries/DisputeTypes.sol"; - -/// @title Hashing -/// @notice This library contains all of the hashing utilities used in the Cannon contracts. -library LibHashing { - /// @notice Hashes a claim and a position together. - /// @param _claim A Claim type. - /// @param _position The position of `claim`. - /// @param _challengeIndex The index of the claim being moved against. - /// @return claimHash_ A hash of abi.encodePacked(claim, position|challengeIndex); - function hashClaimPos( - Claim _claim, - Position _position, - uint256 _challengeIndex - ) - internal - pure - returns (ClaimHash claimHash_) - { - assembly { - mstore(0x00, _claim) - mstore(0x20, or(shl(128, _position), and(0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF, _challengeIndex))) - claimHash_ := keccak256(0x00, 0x40) - } - } -} diff --git a/packages/contracts-bedrock/src/dispute/lib/LibPosition.sol b/packages/contracts-bedrock/src/dispute/lib/LibPosition.sol index c9a1ec0edc5a5..9cff271920b4a 100644 --- a/packages/contracts-bedrock/src/dispute/lib/LibPosition.sol +++ b/packages/contracts-bedrock/src/dispute/lib/LibPosition.sol @@ -1,8 +1,14 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.15; -import "src/libraries/DisputeTypes.sol"; -import "src/libraries/DisputeErrors.sol"; +using LibPosition for Position global; + +/// @notice A `Position` represents a position of a claim within the game tree. +/// @dev This is represented as a "generalized index" where the high-order bit +/// is the level in the tree and the remaining bits is a unique bit pattern, allowing +/// a unique identifier for each node in the tree. Mathematically, it is calculated +/// as 2^{depth} + indexAtDepth. +type Position is uint128; /// @title LibPosition /// @notice This library contains helper functions for working with the `Position` type. @@ -156,7 +162,13 @@ library LibPosition { returns (Position ancestor_) { // This function only works for positions that are below the upper bound. - if (_position.depth() <= _upperBoundExclusive) revert ClaimAboveSplit(); + if (_position.depth() <= _upperBoundExclusive) { + assembly { + // Revert with `ClaimAboveSplit()` + mstore(0x00, 0xb34b5c22) + revert(0x1C, 0x04) + } + } // Grab the global trace ancestor. ancestor_ = traceAncestor(_position); diff --git a/packages/contracts-bedrock/src/dispute/lib/LibUDT.sol b/packages/contracts-bedrock/src/dispute/lib/LibUDT.sol index 3f011f772f989..b0b8edfab8f49 100644 --- a/packages/contracts-bedrock/src/dispute/lib/LibUDT.sol +++ b/packages/contracts-bedrock/src/dispute/lib/LibUDT.sol @@ -1,7 +1,26 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.15; -import "src/libraries/DisputeTypes.sol"; +import "src/dispute/lib/LibPosition.sol"; + +using LibClaim for Claim global; +using LibHash for Hash global; +using LibDuration for Duration global; +using LibClock for Clock global; +using LibGameId for GameId global; +using LibTimestamp for Timestamp global; +using LibVMStatus for VMStatus global; +using LibGameType for GameType global; + +/// @notice A `Clock` represents a packed `Duration` and `Timestamp` +/// @dev The packed layout of this type is as follows: +/// ┌────────────┬────────────────┐ +/// │ Bits │ Value │ +/// ├────────────┼────────────────┤ +/// │ [0, 64) │ Duration │ +/// │ [64, 128) │ Timestamp │ +/// └────────────┴────────────────┘ +type Clock is uint128; /// @title LibClock /// @notice This library contains helper functions for working with the `Clock` type. @@ -47,6 +66,60 @@ library LibClock { } } +/// @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, 32) │ Game Type │ +/// │ [32, 96) │ Timestamp │ +/// │ [96, 256) │ Address │ +/// └───────────┴───────────┘ +type GameId is bytes32; + +/// @title LibGameId +/// @notice Utility functions for packing and unpacking GameIds. +library LibGameId { + /// @notice Packs values into a 32 byte GameId type. + /// @param _gameType The game type. + /// @param _timestamp The timestamp of the game's creation. + /// @param _gameProxy The game proxy address. + /// @return gameId_ The packed GameId. + function pack( + GameType _gameType, + Timestamp _timestamp, + address _gameProxy + ) + internal + pure + returns (GameId gameId_) + { + assembly { + gameId_ := or(or(shl(224, _gameType), shl(160, _timestamp)), _gameProxy) + } + } + + /// @notice Unpacks values from a 32 byte GameId type. + /// @param _gameId The packed GameId. + /// @return gameType_ The game type. + /// @return timestamp_ The timestamp of the game's creation. + /// @return gameProxy_ The game proxy address. + function unpack(GameId _gameId) + internal + pure + returns (GameType gameType_, Timestamp timestamp_, address gameProxy_) + { + assembly { + gameType_ := shr(224, _gameId) + timestamp_ := and(shr(160, _gameId), 0xFFFFFFFFFFFFFFFF) + gameProxy_ := and(_gameId, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF) + } + } +} + +/// @notice A claim represents an MPT root representing the state of the fault proof program. +type Claim is bytes32; + /// @title LibClaim /// @notice This library contains helper functions for working with the `Claim` type. library LibClaim { @@ -58,8 +131,33 @@ library LibClaim { claim_ := _claim } } + + /// @notice Hashes a claim and a position together. + /// @param _claim A Claim type. + /// @param _position The position of `claim`. + /// @param _challengeIndex The index of the claim being moved against. + /// @return claimHash_ A hash of abi.encodePacked(claim, position|challengeIndex); + function hashClaimPos( + Claim _claim, + Position _position, + uint256 _challengeIndex + ) + internal + pure + returns (Hash claimHash_) + { + assembly { + mstore(0x00, _claim) + mstore(0x20, or(shl(128, _position), and(0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF, _challengeIndex))) + claimHash_ := keccak256(0x00, 0x40) + } + } } +/// @notice A dedicated duration type. +/// @dev Unit: seconds +type Duration is uint64; + /// @title LibDuration /// @notice This library contains helper functions for working with the `Duration` type. library LibDuration { @@ -73,6 +171,9 @@ library LibDuration { } } +/// @notice A custom type for a generic hash. +type Hash is bytes32; + /// @title LibHash /// @notice This library contains helper functions for working with the `Hash` type. library LibHash { @@ -86,6 +187,9 @@ library LibHash { } } +/// @notice A dedicated timestamp type. +type Timestamp is uint64; + /// @title LibTimestamp /// @notice This library contains helper functions for working with the `Timestamp` type. library LibTimestamp { @@ -99,6 +203,9 @@ library LibTimestamp { } } +/// @notice A `VMStatus` represents the status of a VM execution. +type VMStatus is uint8; + /// @title LibVMStatus /// @notice This library contains helper functions for working with the `VMStatus` type. library LibVMStatus { @@ -112,6 +219,9 @@ library LibVMStatus { } } +/// @notice A `GameType` represents the type of game being played. +type GameType is uint32; + /// @title LibGameType /// @notice This library contains helper functions for working with the `GameType` type. library LibGameType { diff --git a/packages/contracts-bedrock/src/dispute/lib/Types.sol b/packages/contracts-bedrock/src/dispute/lib/Types.sol new file mode 100644 index 0000000000000..a5866699d0669 --- /dev/null +++ b/packages/contracts-bedrock/src/dispute/lib/Types.sol @@ -0,0 +1,74 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.15; + +import "src/dispute/lib/LibUDT.sol"; + +/// @notice The current status of the dispute game. +enum GameStatus { + // The game is currently in progress, and has not been resolved. + IN_PROGRESS, + // The game has concluded, and the `rootClaim` was challenged successfully. + CHALLENGER_WINS, + // The game has concluded, and the `rootClaim` could not be contested. + DEFENDER_WINS +} + +/// @notice Represents an L2 output root and the L2 block number at which it was generated. +/// @custom:field root The output root. +/// @custom:field l2BlockNumber The L2 block number at which the output root was generated. +struct OutputRoot { + Hash root; + uint256 l2BlockNumber; +} + +/// @title GameTypes +/// @notice A library that defines the IDs of games that can be played. +library GameTypes { + /// @dev A dispute game type the uses the cannon vm. + GameType internal constant CANNON = GameType.wrap(0); + + /// @dev A permissioned dispute game type the uses the cannon vm. + GameType internal constant PERMISSIONED_CANNON = GameType.wrap(1); + + /// @notice A dispute game type the uses the asterisc VM + GameType internal constant ASTERISC = GameType.wrap(2); + + /// @notice A dispute game type that uses an alphabet vm. + /// Not intended for production use. + GameType internal constant ALPHABET = GameType.wrap(255); +} + +/// @title VMStatuses +/// @notice Named type aliases for the various valid VM status bytes. +library VMStatuses { + /// @notice The VM has executed successfully and the outcome is valid. + VMStatus internal constant VALID = VMStatus.wrap(0); + + /// @notice The VM has executed successfully and the outcome is invalid. + VMStatus internal constant INVALID = VMStatus.wrap(1); + + /// @notice The VM has paniced. + VMStatus internal constant PANIC = VMStatus.wrap(2); + + /// @notice The VM execution is still in progress. + VMStatus internal constant UNFINISHED = VMStatus.wrap(3); +} + +/// @title LocalPreimageKey +/// @notice Named type aliases for local `PreimageOracle` key identifiers. +library LocalPreimageKey { + /// @notice The identifier for the L1 head hash. + uint256 internal constant L1_HEAD_HASH = 0x01; + + /// @notice The identifier for the starting output root. + uint256 internal constant STARTING_OUTPUT_ROOT = 0x02; + + /// @notice The identifier for the disputed output root. + uint256 internal constant DISPUTED_OUTPUT_ROOT = 0x03; + + /// @notice The identifier for the disputed L2 block number. + uint256 internal constant DISPUTED_L2_BLOCK_NUMBER = 0x04; + + /// @notice The identifier for the chain ID. + uint256 internal constant CHAIN_ID = 0x05; +} diff --git a/packages/contracts-bedrock/src/libraries/DisputeTypes.sol b/packages/contracts-bedrock/src/libraries/DisputeTypes.sol deleted file mode 100644 index 4f87d6e670e16..0000000000000 --- a/packages/contracts-bedrock/src/libraries/DisputeTypes.sol +++ /dev/null @@ -1,150 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.15; - -import { LibHashing } from "src/dispute/lib/LibHashing.sol"; -import { - LibClaim, - LibHash, - LibDuration, - LibClock, - LibTimestamp, - LibVMStatus, - LibGameType -} from "src/dispute/lib/LibUDT.sol"; -import { LibPosition } from "src/dispute/lib/LibPosition.sol"; -import { LibGameId } from "src/dispute/lib/LibGameId.sol"; - -using LibClaim for Claim global; -using LibHashing for Claim global; -using LibHash for Hash global; -using LibPosition for Position global; -using LibDuration for Duration global; -using LibClock for Clock global; -using LibGameId for GameId global; -using LibTimestamp for Timestamp global; -using LibVMStatus for VMStatus global; -using LibGameType for GameType global; - -/// @notice A custom type for a generic hash. -type Hash is bytes32; - -/// @notice A claim represents an MPT root representing the state of the fault proof program. -type Claim is bytes32; - -/// @notice A claim hash represents a hash of a claim and a position within the game tree. -/// @dev Keccak hash of abi.encodePacked(Claim, Position); -type ClaimHash is bytes32; - -/// @notice A bondamount represents the amount of collateral that a user has locked up in a claim. -type BondAmount is uint256; - -/// @notice A dedicated timestamp type. -type Timestamp is uint64; - -/// @notice A dedicated duration type. -/// @dev Unit: seconds -type Duration is uint64; - -/// @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, 32) │ Game Type │ -/// │ [32, 96) │ Timestamp │ -/// │ [96, 256) │ Address │ -/// └───────────┴───────────┘ -type GameId is bytes32; - -/// @notice A `Clock` represents a packed `Duration` and `Timestamp` -/// @dev The packed layout of this type is as follows: -/// ┌────────────┬────────────────┐ -/// │ Bits │ Value │ -/// ├────────────┼────────────────┤ -/// │ [0, 64) │ Duration │ -/// │ [64, 128) │ Timestamp │ -/// └────────────┴────────────────┘ -type Clock is uint128; - -/// @notice A `Position` represents a position of a claim within the game tree. -/// @dev This is represented as a "generalized index" where the high-order bit -/// is the level in the tree and the remaining bits is a unique bit pattern, allowing -/// a unique identifier for each node in the tree. Mathematically, it is calculated -/// as 2^{depth} + indexAtDepth. -type Position is uint128; - -/// @notice A `GameType` represents the type of game being played. -type GameType is uint32; - -/// @notice A `VMStatus` represents the status of a VM execution. -type VMStatus is uint8; - -/// @notice The current status of the dispute game. -enum GameStatus { - // The game is currently in progress, and has not been resolved. - IN_PROGRESS, - // The game has concluded, and the `rootClaim` was challenged successfully. - CHALLENGER_WINS, - // The game has concluded, and the `rootClaim` could not be contested. - DEFENDER_WINS -} - -/// @notice Represents an L2 output root and the L2 block number at which it was generated. -/// @custom:field root The output root. -/// @custom:field l2BlockNumber The L2 block number at which the output root was generated. -struct OutputRoot { - Hash root; - uint256 l2BlockNumber; -} - -/// @title GameTypes -/// @notice A library that defines the IDs of games that can be played. -library GameTypes { - /// @dev A dispute game type the uses the cannon vm. - GameType internal constant CANNON = GameType.wrap(0); - - /// @dev A permissioned dispute game type the uses the cannon vm. - GameType internal constant PERMISSIONED_CANNON = GameType.wrap(1); - - /// @notice A dispute game type the uses the asterisc VM - GameType internal constant ASTERISC = GameType.wrap(2); - - /// @notice A dispute game type that uses an alphabet vm. - /// Not intended for production use. - GameType internal constant ALPHABET = GameType.wrap(255); -} - -/// @title VMStatuses -/// @notice Named type aliases for the various valid VM status bytes. -library VMStatuses { - /// @notice The VM has executed successfully and the outcome is valid. - VMStatus internal constant VALID = VMStatus.wrap(0); - - /// @notice The VM has executed successfully and the outcome is invalid. - VMStatus internal constant INVALID = VMStatus.wrap(1); - - /// @notice The VM has paniced. - VMStatus internal constant PANIC = VMStatus.wrap(2); - - /// @notice The VM execution is still in progress. - VMStatus internal constant UNFINISHED = VMStatus.wrap(3); -} - -/// @title LocalPreimageKey -/// @notice Named type aliases for local `PreimageOracle` key identifiers. -library LocalPreimageKey { - /// @notice The identifier for the L1 head hash. - uint256 internal constant L1_HEAD_HASH = 0x01; - - /// @notice The identifier for the starting output root. - uint256 internal constant STARTING_OUTPUT_ROOT = 0x02; - - /// @notice The identifier for the disputed output root. - uint256 internal constant DISPUTED_OUTPUT_ROOT = 0x03; - - /// @notice The identifier for the disputed L2 block number. - uint256 internal constant DISPUTED_L2_BLOCK_NUMBER = 0x04; - - /// @notice The identifier for the chain ID. - uint256 internal constant CHAIN_ID = 0x05; -} diff --git a/packages/contracts-bedrock/test/L1/OptimismPortal2.t.sol b/packages/contracts-bedrock/test/L1/OptimismPortal2.t.sol index 6836ec2053a64..9d98ed30d3766 100644 --- a/packages/contracts-bedrock/test/L1/OptimismPortal2.t.sol +++ b/packages/contracts-bedrock/test/L1/OptimismPortal2.t.sol @@ -22,7 +22,7 @@ import { SuperchainConfig } from "src/L1/SuperchainConfig.sol"; import { OptimismPortal2 } from "src/L1/OptimismPortal2.sol"; import { FaultDisputeGame, IDisputeGame } from "src/dispute/FaultDisputeGame.sol"; -import "src/libraries/DisputeTypes.sol"; +import "src/dispute/lib/Types.sol"; import "src/libraries/PortalErrors.sol"; contract OptimismPortal2_Test is CommonTest { diff --git a/packages/contracts-bedrock/test/Safe/DeputyGuardianModule.t.sol b/packages/contracts-bedrock/test/Safe/DeputyGuardianModule.t.sol index 30d245c565573..af9fa505d21fb 100644 --- a/packages/contracts-bedrock/test/Safe/DeputyGuardianModule.t.sol +++ b/packages/contracts-bedrock/test/Safe/DeputyGuardianModule.t.sol @@ -9,7 +9,7 @@ import "test/safe-tools/SafeTestTools.sol"; import { IDisputeGame } from "src/dispute/interfaces/IDisputeGame.sol"; import { DeputyGuardianModule } from "src/Safe/DeputyGuardianModule.sol"; -import { GameType } from "src/libraries/DisputeTypes.sol"; +import { GameType } from "src/dispute/lib/Types.sol"; contract DeputyGuardianModule_TestInit is CommonTest, SafeTestTools { using SafeTestLib for SafeInstance; @@ -241,8 +241,9 @@ contract DeputyGuardianModule_NoPortalCollisions_Test is DeputyGuardianModule_Te /// @dev tests that no function selectors in the L1 contracts collide with the OptimismPortal2 functions called by /// the DeputyGuardianModule. function test_noPortalCollisions_succeeds() external { - string[] memory excludes = new string[](1); + string[] memory excludes = new string[](2); excludes[0] = "src/L1/OptimismPortal2.sol"; + excludes[1] = "src/dispute/lib/*"; Abi[] memory abis = ForgeArtifacts.getContractFunctionAbis("src/{L1,dispute,universal}/", excludes); for (uint256 i; i < abis.length; i++) { for (uint256 j; j < abis[i].entries.length; j++) { diff --git a/packages/contracts-bedrock/test/actors/FaultDisputeActors.sol b/packages/contracts-bedrock/test/actors/FaultDisputeActors.sol index d1bf6456e2c80..9516d2fb4b03d 100644 --- a/packages/contracts-bedrock/test/actors/FaultDisputeActors.sol +++ b/packages/contracts-bedrock/test/actors/FaultDisputeActors.sol @@ -6,7 +6,7 @@ import { CommonBase } from "forge-std/Base.sol"; import { FaultDisputeGame } from "src/dispute/FaultDisputeGame.sol"; import { IFaultDisputeGame } from "src/dispute/interfaces/IFaultDisputeGame.sol"; -import "src/libraries/DisputeTypes.sol"; +import "src/dispute/lib/Types.sol"; /// @title GameSolver /// @notice The `GameSolver` contract is a contract that can produce an array of available diff --git a/packages/contracts-bedrock/test/cannon/MIPS.t.sol b/packages/contracts-bedrock/test/cannon/MIPS.t.sol index eb7843fd7cc98..823cb81daee6e 100644 --- a/packages/contracts-bedrock/test/cannon/MIPS.t.sol +++ b/packages/contracts-bedrock/test/cannon/MIPS.t.sol @@ -4,7 +4,7 @@ pragma solidity 0.8.15; import { CommonTest } from "test/setup/CommonTest.sol"; import { MIPS } from "src/cannon/MIPS.sol"; import { PreimageOracle } from "src/cannon/PreimageOracle.sol"; -import "src/libraries/DisputeTypes.sol"; +import "src/dispute/lib/Types.sol"; contract MIPS_Test is CommonTest { MIPS internal mips; diff --git a/packages/contracts-bedrock/test/dispute/AnchorStateRegistry.t.sol b/packages/contracts-bedrock/test/dispute/AnchorStateRegistry.t.sol index ec40d2ec2652f..4f9cb3c8115e2 100644 --- a/packages/contracts-bedrock/test/dispute/AnchorStateRegistry.t.sol +++ b/packages/contracts-bedrock/test/dispute/AnchorStateRegistry.t.sol @@ -1,8 +1,8 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.15; -import "src/libraries/DisputeTypes.sol"; -import "src/libraries/DisputeErrors.sol"; +import "src/dispute/lib/Types.sol"; +import "src/dispute/lib/Errors.sol"; import { Test } from "forge-std/Test.sol"; import { FaultDisputeGame_Init, _changeClaimStatus } from "test/dispute/FaultDisputeGame.t.sol"; diff --git a/packages/contracts-bedrock/test/dispute/DelayedWETH.t.sol b/packages/contracts-bedrock/test/dispute/DelayedWETH.t.sol index 3ed85813de0f8..0e0922f825c46 100644 --- a/packages/contracts-bedrock/test/dispute/DelayedWETH.t.sol +++ b/packages/contracts-bedrock/test/dispute/DelayedWETH.t.sol @@ -1,8 +1,8 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.15; -import "src/libraries/DisputeTypes.sol"; -import "src/libraries/DisputeErrors.sol"; +import "src/dispute/lib/Types.sol"; +import "src/dispute/lib/Errors.sol"; import { Test } from "forge-std/Test.sol"; import { DisputeGameFactory, IDisputeGameFactory } from "src/dispute/DisputeGameFactory.sol"; diff --git a/packages/contracts-bedrock/test/dispute/DisputeGameFactory.t.sol b/packages/contracts-bedrock/test/dispute/DisputeGameFactory.t.sol index 3f6abcbbaaaca..09a087fb5d776 100644 --- a/packages/contracts-bedrock/test/dispute/DisputeGameFactory.t.sol +++ b/packages/contracts-bedrock/test/dispute/DisputeGameFactory.t.sol @@ -1,8 +1,8 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.15; -import "src/libraries/DisputeTypes.sol"; -import "src/libraries/DisputeErrors.sol"; +import "src/dispute/lib/Types.sol"; +import "src/dispute/lib/Errors.sol"; import { Test } from "forge-std/Test.sol"; import { DisputeGameFactory, IDisputeGameFactory } from "src/dispute/DisputeGameFactory.sol"; @@ -272,7 +272,7 @@ contract DisputeGameFactory_FindLatestGames_Test is DisputeGameFactory_Init { games = disputeGameFactory.findLatestGames(GameType.wrap(0), gameCount - 1, 1); assertEq(games.length, 1); assertEq(games[0].index, 30); - (GameType gameType, Timestamp createdAt, IDisputeGame game) = games[0].metadata.unpack(); + (GameType gameType, Timestamp createdAt, address game) = games[0].metadata.unpack(); assertEq(gameType.raw(), 0); assertEq(createdAt.raw(), block.timestamp); diff --git a/packages/contracts-bedrock/test/dispute/FaultDisputeGame.t.sol b/packages/contracts-bedrock/test/dispute/FaultDisputeGame.t.sol index f55a74d0b5f1b..b62bcf583f70d 100644 --- a/packages/contracts-bedrock/test/dispute/FaultDisputeGame.t.sol +++ b/packages/contracts-bedrock/test/dispute/FaultDisputeGame.t.sol @@ -9,8 +9,8 @@ import { FaultDisputeGame } from "src/dispute/FaultDisputeGame.sol"; import { DelayedWETH } from "src/dispute/weth/DelayedWETH.sol"; import { PreimageOracle } from "src/cannon/PreimageOracle.sol"; -import "src/libraries/DisputeTypes.sol"; -import "src/libraries/DisputeErrors.sol"; +import "src/dispute/lib/Types.sol"; +import "src/dispute/lib/Errors.sol"; import { LibClock } from "src/dispute/lib/LibUDT.sol"; import { LibPosition } from "src/dispute/lib/LibPosition.sol"; import { IPreimageOracle } from "src/dispute/interfaces/IBigStepper.sol"; diff --git a/packages/contracts-bedrock/test/dispute/PermissionedDisputeGame.t.sol b/packages/contracts-bedrock/test/dispute/PermissionedDisputeGame.t.sol index 4add739667cd0..1247ec5bd8376 100644 --- a/packages/contracts-bedrock/test/dispute/PermissionedDisputeGame.t.sol +++ b/packages/contracts-bedrock/test/dispute/PermissionedDisputeGame.t.sol @@ -11,8 +11,8 @@ import { L2OutputOracle } from "src/L1/L2OutputOracle.sol"; import { PreimageOracle } from "src/cannon/PreimageOracle.sol"; import { PreimageKeyLib } from "src/cannon/PreimageKeyLib.sol"; -import "src/libraries/DisputeTypes.sol"; -import "src/libraries/DisputeErrors.sol"; +import "src/dispute/lib/Types.sol"; +import "src/dispute/lib/Errors.sol"; import { Types } from "src/libraries/Types.sol"; import { LibClock } from "src/dispute/lib/LibUDT.sol"; import { LibPosition } from "src/dispute/lib/LibPosition.sol"; diff --git a/packages/contracts-bedrock/test/dispute/lib/LibClock.t.sol b/packages/contracts-bedrock/test/dispute/lib/LibClock.t.sol index fee39fae3b90a..3e4579b006273 100644 --- a/packages/contracts-bedrock/test/dispute/lib/LibClock.t.sol +++ b/packages/contracts-bedrock/test/dispute/lib/LibClock.t.sol @@ -3,7 +3,7 @@ pragma solidity ^0.8.15; import { Test } from "forge-std/Test.sol"; import { LibClock } from "src/dispute/lib/LibUDT.sol"; -import "src/libraries/DisputeTypes.sol"; +import "src/dispute/lib/Types.sol"; /// @notice Tests for `LibClock` contract LibClock_Test is Test { diff --git a/packages/contracts-bedrock/test/dispute/lib/LibGameId.t.sol b/packages/contracts-bedrock/test/dispute/lib/LibGameId.t.sol index 4f0e23d1decb7..70ca0dab6a8a8 100644 --- a/packages/contracts-bedrock/test/dispute/lib/LibGameId.t.sol +++ b/packages/contracts-bedrock/test/dispute/lib/LibGameId.t.sol @@ -3,25 +3,24 @@ pragma solidity ^0.8.15; import { Test } from "forge-std/Test.sol"; -import { LibGameId } from "src/dispute/lib/LibGameId.sol"; import { IDisputeGame } from "src/dispute/interfaces/IDisputeGame.sol"; -import "src/libraries/DisputeTypes.sol"; +import "src/dispute/lib/Types.sol"; contract LibGameId_Test is Test { /// @dev Tests that a round trip of packing and unpacking a GameId maintains the same values. function testFuzz_gameId_roundTrip_succeeds( GameType _gameType, Timestamp _timestamp, - IDisputeGame _gameProxy + address _gameProxy ) public pure { GameId gameId = LibGameId.pack(_gameType, _timestamp, _gameProxy); - (GameType gameType_, Timestamp timestamp_, IDisputeGame gameProxy_) = LibGameId.unpack(gameId); + (GameType gameType_, Timestamp timestamp_, address gameProxy_) = LibGameId.unpack(gameId); assertEq(GameType.unwrap(gameType_), GameType.unwrap(_gameType)); assertEq(Timestamp.unwrap(timestamp_), Timestamp.unwrap(_timestamp)); - assertEq(address(gameProxy_), address(_gameProxy)); + assertEq(gameProxy_, _gameProxy); } } diff --git a/packages/contracts-bedrock/test/dispute/lib/LibPosition.t.sol b/packages/contracts-bedrock/test/dispute/lib/LibPosition.t.sol index d4864a919b28c..26d79c1a82d85 100644 --- a/packages/contracts-bedrock/test/dispute/lib/LibPosition.t.sol +++ b/packages/contracts-bedrock/test/dispute/lib/LibPosition.t.sol @@ -3,7 +3,7 @@ pragma solidity ^0.8.15; import { Test } from "forge-std/Test.sol"; import { LibPosition } from "src/dispute/lib/LibPosition.sol"; -import "src/libraries/DisputeTypes.sol"; +import "src/dispute/lib/Types.sol"; /// @notice Tests for `LibPosition` contract LibPosition_Test is Test { diff --git a/packages/contracts-bedrock/test/invariants/FaultDisputeGame.t.sol b/packages/contracts-bedrock/test/invariants/FaultDisputeGame.t.sol index bde9b7f0f2909..2eb8727595714 100644 --- a/packages/contracts-bedrock/test/invariants/FaultDisputeGame.t.sol +++ b/packages/contracts-bedrock/test/invariants/FaultDisputeGame.t.sol @@ -6,8 +6,8 @@ import { StdUtils } from "forge-std/StdUtils.sol"; import { FaultDisputeGame } from "src/dispute/FaultDisputeGame.sol"; import { FaultDisputeGame_Init } from "test/dispute/FaultDisputeGame.t.sol"; -import "src/libraries/DisputeTypes.sol"; -import "src/libraries/DisputeErrors.sol"; +import "src/dispute/lib/Types.sol"; +import "src/dispute/lib/Errors.sol"; contract FaultDisputeGame_Solvency_Invariant is FaultDisputeGame_Init { Claim internal constant ROOT_CLAIM = Claim.wrap(bytes32(uint256(10))); diff --git a/packages/contracts-bedrock/test/invariants/OptimismPortal2.t.sol b/packages/contracts-bedrock/test/invariants/OptimismPortal2.t.sol index 5c20132dba6d2..bffc3a3b4259e 100644 --- a/packages/contracts-bedrock/test/invariants/OptimismPortal2.t.sol +++ b/packages/contracts-bedrock/test/invariants/OptimismPortal2.t.sol @@ -15,7 +15,7 @@ import { EIP1967Helper } from "test/mocks/EIP1967Helper.sol"; import { Types } from "src/libraries/Types.sol"; import { FaultDisputeGame } from "src/dispute/FaultDisputeGame.sol"; -import "src/libraries/DisputeTypes.sol"; +import "src/dispute/lib/Types.sol"; contract OptimismPortal2_Depositor is StdUtils, ResourceMetering { Vm internal vm; diff --git a/packages/contracts-bedrock/test/mocks/AlphabetVM.sol b/packages/contracts-bedrock/test/mocks/AlphabetVM.sol index e7488f5384ecc..b5d940c1cf6ed 100644 --- a/packages/contracts-bedrock/test/mocks/AlphabetVM.sol +++ b/packages/contracts-bedrock/test/mocks/AlphabetVM.sol @@ -3,7 +3,7 @@ pragma solidity ^0.8.15; import { IBigStepper, IPreimageOracle } from "src/dispute/interfaces/IBigStepper.sol"; import { PreimageOracle, PreimageKeyLib } from "src/cannon/PreimageOracle.sol"; -import "src/libraries/DisputeTypes.sol"; +import "src/dispute/lib/Types.sol"; /// @title AlphabetVM /// @dev A mock VM for the purpose of testing the dispute game infrastructure. Note that this only works diff --git a/packages/contracts-bedrock/test/vendor/Initializable.t.sol b/packages/contracts-bedrock/test/vendor/Initializable.t.sol index 3593d080a2fc0..6409d0c3d9a91 100644 --- a/packages/contracts-bedrock/test/vendor/Initializable.t.sol +++ b/packages/contracts-bedrock/test/vendor/Initializable.t.sol @@ -11,7 +11,7 @@ import { ResourceMetering } from "src/L1/ResourceMetering.sol"; import { OptimismPortal } from "src/L1/OptimismPortal.sol"; import { ForgeArtifacts } from "scripts/ForgeArtifacts.sol"; import "src/L1/ProtocolVersions.sol"; -import "src/libraries/DisputeTypes.sol"; +import "src/dispute/lib/Types.sol"; import "scripts/Deployer.sol"; /// @title Initializer_Test