Skip to content

Commit

Permalink
feat: add old dispute game address to event
Browse files Browse the repository at this point in the history
  • Loading branch information
maurelian committed Feb 11, 2025
1 parent 14772a1 commit 3c04934
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,9 @@ interface IOPContractsManager {
/// @notice Emitted when a new game type is added to a chain
/// @param l2ChainId Chain ID of the chain
/// @param gameType Type of the game being added
/// @param disputeGame Address of the deployed dispute game
/// @param delayedWETH Address of the WETH contract used by the game
event GameTypeAdded(uint256 indexed l2ChainId, GameType indexed gameType, IDisputeGame disputeGame, IDelayedWETH delayedWETH);
/// @param newDisputeGame Address of the deployed dispute game
/// @param oldDisputeGame Address of the old dispute game
event GameTypeAdded(uint256 indexed l2ChainId, GameType indexed gameType, IDisputeGame newDisputeGame, IDisputeGame oldDisputeGame);

// -------- Errors --------

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -768,13 +768,13 @@
{
"indexed": false,
"internalType": "contract IDisputeGame",
"name": "disputeGame",
"name": "newDisputeGame",
"type": "address"
},
{
"indexed": false,
"internalType": "contract IDelayedWETH",
"name": "delayedWETH",
"internalType": "contract IDisputeGame",
"name": "oldDisputeGame",
"type": "address"
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -768,13 +768,13 @@
{
"indexed": false,
"internalType": "contract IDisputeGame",
"name": "disputeGame",
"name": "newDisputeGame",
"type": "address"
},
{
"indexed": false,
"internalType": "contract IDelayedWETH",
"name": "delayedWETH",
"internalType": "contract IDisputeGame",
"name": "oldDisputeGame",
"type": "address"
}
],
Expand Down
8 changes: 4 additions & 4 deletions packages/contracts-bedrock/snapshots/semver-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
"sourceCodeHash": "0xf9ba98657dc235355146e381b654fe3ed766feb7cd87636ec0c9d4c6dd3e1973"
},
"src/L1/OPContractsManager.sol": {
"initCodeHash": "0x792cdc28c9fb20ea9afa840cc62f928195bb1e9e6aef8738e7a289a43b91ef80",
"sourceCodeHash": "0xe50c3d6ae2664000f942083d584fbbd28f1c622edfbdaaf2e7f31b344ca4207d"
"initCodeHash": "0x28f3b788bd68435a4f0b9629eb4127eb1a2024155f3d0cff3f06ce6ff5af6fd4",
"sourceCodeHash": "0x9a5cb646ac8e5b0521af74a156e66dba0db4e811c9f192612474bf4b7ce5e740"
},
"src/L1/OPContractsManagerInterop.sol": {
"initCodeHash": "0xf573925d3911492c6476076076a8903197c6ebc91bda490856e94f2fc89f819e",
"sourceCodeHash": "0x0ba9c63e3f00dab87be058fd0091f19c51faeafd24609bc13667214796bcc106"
"initCodeHash": "0x46142c289420f2f664423bd48731ab042d369855e317a1f6eb395bd309fd90b0",
"sourceCodeHash": "0x1bf5afe631f621078379773a0b0d6fda9d2b3bddd0acd7bd38fc461a2c8107bd"
},
"src/L1/OptimismPortal2.sol": {
"initCodeHash": "0x2cc5776c92d6cb154aa3d9897c476deaf49d98dc81493fabaea72987b9588853",
Expand Down
50 changes: 32 additions & 18 deletions packages/contracts-bedrock/src/L1/OPContractsManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,9 @@ contract OPContractsManager is ISemver {

// -------- Constants and Variables --------

/// @custom:semver 1.2.0
/// @custom:semver 1.3.0
function version() public pure virtual returns (string memory) {
return "1.2.0";
return "1.3.0";
}

/// @notice Address of the SuperchainConfig contract shared by all chains.
Expand Down Expand Up @@ -200,11 +200,11 @@ contract OPContractsManager is ISemver {

/// @notice Emitted when a new game type is added to a chain
/// @param l2ChainId Chain ID of the chain
/// @param gameType Type of the game being added
/// @param disputeGame Address of the deployed dispute game
/// @param delayedWETH Address of the WETH contract used by the game
/// @param gameType Type of the game being
/// @param newDisputeGame Address of the deployed dispute game
/// @param oldDisputeGame Address of the old dispute game
event GameTypeAdded(
uint256 indexed l2ChainId, GameType indexed gameType, IDisputeGame disputeGame, IDelayedWETH delayedWETH
uint256 indexed l2ChainId, GameType indexed gameType, IDisputeGame newDisputeGame, IDisputeGame oldDisputeGame
);

// -------- Errors --------
Expand Down Expand Up @@ -631,14 +631,15 @@ contract OPContractsManager is ISemver {
if (lastGameConfig >= gameTypeInt) revert InvalidGameConfigs();
lastGameConfig = gameTypeInt;

// Grab the FDG from the SystemConfig.
IFaultDisputeGame fdg = IFaultDisputeGame(
// Grab the permissioned and fault dispute games from the SystemConfig.
// We keep the FDG type as it reduces casting below.
IFaultDisputeGame pdg = IFaultDisputeGame(
address(
getGameImplementation(getDisputeGameFactory(gameConfig.systemConfig), GameTypes.PERMISSIONED_CANNON)
)
);
// Pull out the chain ID.
uint256 l2ChainId = getL2ChainId(fdg);
uint256 l2ChainId = getL2ChainId(pdg);

// Deploy a new DelayedWETH proxy for this game if one hasn't already been specified. Leaving
/// gameConfig.delayedWETH as the zero address will cause a new DelayedWETH to be deployed for this game.
Expand All @@ -658,10 +659,13 @@ contract OPContractsManager is ISemver {
outputs[i].delayedWETH = gameConfig.delayedWETH;
}

// The FDG is only used for the event below, and only if it is being replaced,
// so we declare it here, but only assign it below if needed.
IFaultDisputeGame fdg;

// The below sections are functionally the same. Both deploy a new dispute game. The dispute game type is
// either permissioned or permissionless depending on game config.
if (gameConfig.permissioned) {
IPermissionedDisputeGame pdg = IPermissionedDisputeGame(address(fdg));
outputs[i].faultDisputeGame = IFaultDisputeGame(
Blueprint.deployFrom(
bps.permissionedDisputeGame1,
Expand All @@ -677,15 +681,18 @@ contract OPContractsManager is ISemver {
gameConfig.disputeMaxClockDuration,
gameConfig.vm,
outputs[i].delayedWETH,
getAnchorStateRegistry(IFaultDisputeGame(address(pdg))),
getAnchorStateRegistry(pdg),
l2ChainId
),
getProposer(pdg),
getChallenger(pdg)
getProposer(IPermissionedDisputeGame(address(pdg))),
getChallenger(IPermissionedDisputeGame(address(pdg)))
)
)
);
} else {
fdg = IFaultDisputeGame(
address(getGameImplementation(getDisputeGameFactory(gameConfig.systemConfig), GameTypes.CANNON))
);
outputs[i].faultDisputeGame = IFaultDisputeGame(
Blueprint.deployFrom(
bps.permissionlessDisputeGame1,
Expand All @@ -701,7 +708,7 @@ contract OPContractsManager is ISemver {
gameConfig.disputeMaxClockDuration,
gameConfig.vm,
outputs[i].delayedWETH,
getAnchorStateRegistry(fdg),
getAnchorStateRegistry(pdg),
l2ChainId
)
)
Expand All @@ -715,10 +722,17 @@ contract OPContractsManager is ISemver {
setDGFImplementation(dgf, gameConfig.disputeGameType, IDisputeGame(address(outputs[i].faultDisputeGame)));
dgf.setInitBond(gameConfig.disputeGameType, gameConfig.initialBond);

// Emit event for the newly added game type
emit GameTypeAdded(
l2ChainId, gameConfig.disputeGameType, outputs[i].faultDisputeGame, outputs[i].delayedWETH
);
if (gameConfig.permissioned) {
// Emit event for the newly added game type with the old permissioned dispute game
emit GameTypeAdded(
l2ChainId, gameConfig.disputeGameType, outputs[i].faultDisputeGame, IDisputeGame(address(pdg))
);
} else {
// Emit event for the newly added game type with the old fault dispute game
emit GameTypeAdded(
l2ChainId, gameConfig.disputeGameType, outputs[i].faultDisputeGame, IDisputeGame(address(fdg))
);
}
}

return outputs;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import { ISystemConfigInterop } from "interfaces/L1/ISystemConfigInterop.sol";
import { IProxyAdmin } from "interfaces/universal/IProxyAdmin.sol";

contract OPContractsManagerInterop is OPContractsManager {
/// @custom:semver +interop.4
/// @custom:semver +interop.5
function version() public pure override returns (string memory) {
return string.concat(super.version(), "+interop.4");
return string.concat(super.version(), "+interop.5");
}

constructor(
Expand Down
4 changes: 2 additions & 2 deletions packages/contracts-bedrock/test/L1/OPContractsManager.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ contract OPContractsManager_AddGameType_Test is Test {
IOPContractsManager.DeployOutput internal chainDeployOutput;

event GameTypeAdded(
uint256 indexed l2ChainId, GameType indexed gameType, IDisputeGame disputeGame, IDelayedWETH delayedWETH
uint256 indexed l2ChainId, GameType indexed gameType, IDisputeGame newDisputeGame, IDisputeGame oldDisputeGame
);

function setUp() public {
Expand Down Expand Up @@ -710,7 +710,7 @@ contract OPContractsManager_AddGameType_Test is Test {
// Expect the GameTypeAdded event to be emitted.
vm.expectEmit(true, true, false, false, address(this));
emit GameTypeAdded(
l2ChainId, input.disputeGameType, IDisputeGame(payable(address(0))), IDelayedWETH(payable(address(0)))
l2ChainId, input.disputeGameType, IDisputeGame(payable(address(0))), IDisputeGame(payable(address(0)))
);
(bool success, bytes memory rawGameOut) =
address(opcm).delegatecall(abi.encodeCall(IOPContractsManager.addGameType, (inputs)));
Expand Down

0 comments on commit 3c04934

Please sign in to comment.