Skip to content

Commit

Permalink
Merge pull request #6122 from ethereum-optimism/clabby/dispute/semver
Browse files Browse the repository at this point in the history
feat(ctb): Introduce `Semver` on `FaultDisputeGame` + `DisputeGameFactory`
  • Loading branch information
mergify[bot] committed Jun 23, 2023
2 parents ec33fd9 + 897d9b8 commit e1571d7
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 39 deletions.
10 changes: 5 additions & 5 deletions op-bindings/bindings/disputegamefactory.go

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions packages/contracts-bedrock/.gas-snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ FaultDisputeGame_ResolvesCorrectly_IncorrectRoot2:test_resolvesCorrectly_succeed
FaultDisputeGame_ResolvesCorrectly_IncorrectRoot3:test_resolvesCorrectly_succeeds() (gas: 503574)
FaultDisputeGame_ResolvesCorrectly_IncorrectRoot:test_resolvesCorrectly_succeeds() (gas: 491581)
FaultDisputeGame_Test:test_defendRoot_invalidMove_reverts() (gas: 13250)
FaultDisputeGame_Test:test_extraData_succeeds() (gas: 17409)
FaultDisputeGame_Test:test_gameData_succeeds() (gas: 17834)
FaultDisputeGame_Test:test_extraData_succeeds() (gas: 17448)
FaultDisputeGame_Test:test_gameData_succeeds() (gas: 17873)
FaultDisputeGame_Test:test_gameStart_succeeds() (gas: 10337)
FaultDisputeGame_Test:test_gameType_succeeds() (gas: 8216)
FaultDisputeGame_Test:test_initialRootClaimData_succeeds() (gas: 17691)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@ import { ClonesWithImmutableArgs } from "@cwia/ClonesWithImmutableArgs.sol";
import {
OwnableUpgradeable
} from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import { Semver } from "../universal/Semver.sol";

import { IDisputeGame } from "./interfaces/IDisputeGame.sol";
import { IDisputeGameFactory } from "./interfaces/IDisputeGameFactory.sol";
import { IVersioned } from "./interfaces/IVersioned.sol";

/// @title DisputeGameFactory
/// @notice A factory contract for creating `IDisputeGame` contracts. All created dispute games
/// are stored in both a mapping and an append only array. The timestamp of the creation
/// time of the dispute game is packed tightly into the storage slot with the address of
/// the dispute game. This is to make offchain discoverability of playable dispute games
/// easier.
contract DisputeGameFactory is OwnableUpgradeable, IDisputeGameFactory, IVersioned {
contract DisputeGameFactory is OwnableUpgradeable, IDisputeGameFactory, Semver {
/// @dev Allows for the creation of clone proxies with immutable arguments.
using ClonesWithImmutableArgs for address;

Expand All @@ -37,7 +37,7 @@ contract DisputeGameFactory is OwnableUpgradeable, IDisputeGameFactory, IVersion
GameId[] internal _disputeGameList;

/// @notice constructs a new DisputeGameFactory contract.
constructor() OwnableUpgradeable() {
constructor() OwnableUpgradeable() Semver(0, 0, 2) {
initialize(address(0));
}

Expand All @@ -48,12 +48,6 @@ contract DisputeGameFactory is OwnableUpgradeable, IDisputeGameFactory, IVersion
_transferOwnership(_owner);
}

/// @inheritdoc IVersioned
/// @custom:semver 0.0.2
function version() external pure returns (string memory) {
return "0.0.2";
}

/// @inheritdoc IDisputeGameFactory
function gameCount() external view returns (uint256 gameCount_) {
gameCount_ = _disputeGameList.length;
Expand Down
14 changes: 3 additions & 11 deletions packages/contracts-bedrock/contracts/dispute/FaultDisputeGame.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
pragma solidity ^0.8.15;

import { IDisputeGame } from "./interfaces/IDisputeGame.sol";
import { IVersioned } from "./interfaces/IVersioned.sol";
import { IFaultDisputeGame } from "./interfaces/IFaultDisputeGame.sol";
import { IInitializable } from "./interfaces/IInitializable.sol";
import { IBondManager } from "./interfaces/IBondManager.sol";
import { IBigStepper } from "./interfaces/IBigStepper.sol";

import { Clone } from "../libraries/Clone.sol";
import { Semver } from "../universal/Semver.sol";
import { LibHashing } from "./lib/LibHashing.sol";
import { LibPosition } from "./lib/LibPosition.sol";
import { LibClock } from "./lib/LibClock.sol";
Expand All @@ -18,7 +18,7 @@ import "../libraries/DisputeErrors.sol";

/// @title FaultDisputeGame
/// @notice An implementation of the `IFaultDisputeGame` interface.
contract FaultDisputeGame is IFaultDisputeGame, Clone {
contract FaultDisputeGame is IFaultDisputeGame, Clone, Semver {
////////////////////////////////////////////////////////////////
// State Vars //
////////////////////////////////////////////////////////////////
Expand All @@ -40,9 +40,6 @@ contract FaultDisputeGame is IFaultDisputeGame, Clone {
/// @notice The root claim's position is always at gindex 1.
Position internal constant ROOT_POSITION = Position.wrap(1);

/// @notice The current Semver of the FaultDisputeGame implementation.
string internal constant VERSION = "0.0.2";

/// @notice The starting timestamp of the game
Timestamp public gameStart;

Expand All @@ -63,7 +60,7 @@ contract FaultDisputeGame is IFaultDisputeGame, Clone {
Claim _absolutePrestate,
uint256 _maxGameDepth,
IBigStepper _vm
) {
) Semver(0, 0, 2) {
ABSOLUTE_PRESTATE = _absolutePrestate;
MAX_GAME_DEPTH = _maxGameDepth;
VM = _vm;
Expand Down Expand Up @@ -376,9 +373,4 @@ contract FaultDisputeGame is IFaultDisputeGame, Clone {
})
);
}

/// @inheritdoc IVersioned
function version() external pure override returns (string memory version_) {
version_ = VERSION;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@ pragma solidity ^0.8.15;

import "../../libraries/DisputeTypes.sol";

import { IVersioned } from "./IVersioned.sol";
import { IBondManager } from "./IBondManager.sol";
import { IInitializable } from "./IInitializable.sol";

/// @title IDisputeGame
/// @notice The generic interface for a DisputeGame contract.
interface IDisputeGame is IInitializable, IVersioned {
interface IDisputeGame is IInitializable {
/// @notice Emitted when the game is resolved.
/// @param status The status of the game after resolution.
event Resolved(GameStatus indexed status);
Expand Down

This file was deleted.

0 comments on commit e1571d7

Please sign in to comment.