Skip to content

Commit

Permalink
maint: fix dispute interfaces (#12010)
Browse files Browse the repository at this point in the history
Fixes the existing dispute interfaces and makes them match the
same style that we're using for all other interfaces.
  • Loading branch information
smartcontracts committed Sep 20, 2024
1 parent 43ec97d commit eaf4d3e
Show file tree
Hide file tree
Showing 38 changed files with 815 additions and 663 deletions.
18 changes: 8 additions & 10 deletions packages/contracts-bedrock/scripts/checks/check-interfaces.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,26 +48,24 @@ EXCLUDE_CONTRACTS=(
"KontrolCheatsBase"

# TODO: Interfaces that need to be fixed
"IPreimageOracle"
"IOptimismMintableERC721"
"IFaultDisputeGame"
"IOptimismSuperchainERC20"
"IInitializable"
"IOptimismMintableERC721"
"IOptimismMintableERC20"
"ILegacyMintableERC20"
"IInitializable"
"IPreimageOracle"
"ICrossL2Inbox"
"IL2ToL2CrossDomainMessenger"
"MintableAndBurnable"
"IDisputeGameFactory"
"IWETH"
"IDelayedWETH"
"IAnchorStateRegistry"
"ICrossL2Inbox"
"IL1CrossDomainMessenger"
"IL2ToL2CrossDomainMessenger"

# TODO: Kontrol interfaces that need to be removed
"IL1ERC721Bridge"
"IL1StandardBridge"
"IL1CrossDomainMessenger"
"ISuperchainConfig"
"IOptimismPortal"
"IL1BlockIsthmus"
)

# Find all JSON files in the forge-artifacts folder
Expand Down
10 changes: 5 additions & 5 deletions packages/contracts-bedrock/scripts/deploy/ChainAssertions.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ import { ISystemConfigV0 } from "scripts/interfaces/ISystemConfigV0.sol";

// Contracts
import { ProxyAdmin } from "src/universal/ProxyAdmin.sol";
import { DisputeGameFactory } from "src/dispute/DisputeGameFactory.sol";
import { DelayedWETH } from "src/dispute/DelayedWETH.sol";

// Libraries
import { Constants } from "src/libraries/Constants.sol";
Expand All @@ -31,6 +29,8 @@ import { IOptimismPortal2 } from "src/L1/interfaces/IOptimismPortal2.sol";
import { IL1ERC721Bridge } from "src/L1/interfaces/IL1ERC721Bridge.sol";
import { IL1StandardBridge } from "src/L1/interfaces/IL1StandardBridge.sol";
import { ProtocolVersion, IProtocolVersions } from "src/L1/interfaces/IProtocolVersions.sol";
import { IDisputeGameFactory } from "src/dispute/interfaces/IDisputeGameFactory.sol";
import { IDelayedWETH } from "src/dispute/interfaces/IDelayedWETH.sol";
import { IOptimismMintableERC20Factory } from "src/universal/interfaces/IOptimismMintableERC20Factory.sol";

library ChainAssertions {
Expand Down Expand Up @@ -183,7 +183,7 @@ library ChainAssertions {
/// @notice Asserts that the DisputeGameFactory is setup correctly
function checkDisputeGameFactory(Types.ContractSet memory _contracts, address _expectedOwner) internal view {
console.log("Running chain assertions on the DisputeGameFactory");
DisputeGameFactory factory = DisputeGameFactory(_contracts.DisputeGameFactory);
IDisputeGameFactory factory = IDisputeGameFactory(_contracts.DisputeGameFactory);

// Check that the contract is initialized
assertSlotValueIsOne({ _contractAddress: address(factory), _slot: 0, _offset: 0 });
Expand All @@ -202,7 +202,7 @@ library ChainAssertions {
view
{
console.log("Running chain assertions on the DelayedWETH");
DelayedWETH weth = DelayedWETH(payable(_contracts.DelayedWETH));
IDelayedWETH weth = IDelayedWETH(payable(_contracts.DelayedWETH));

// Check that the contract is initialized
assertSlotValueIsOne({ _contractAddress: address(weth), _slot: 0, _offset: 0 });
Expand All @@ -228,7 +228,7 @@ library ChainAssertions {
view
{
console.log("Running chain assertions on the permissioned DelayedWETH");
DelayedWETH weth = DelayedWETH(payable(_contracts.PermissionedDelayedWETH));
IDelayedWETH weth = IDelayedWETH(payable(_contracts.PermissionedDelayedWETH));

// Check that the contract is initialized
assertSlotValueIsOne({ _contractAddress: address(weth), _slot: 0, _offset: 0 });
Expand Down
176 changes: 96 additions & 80 deletions packages/contracts-bedrock/scripts/deploy/Deploy.s.sol

Large diffs are not rendered by default.

47 changes: 28 additions & 19 deletions packages/contracts-bedrock/scripts/fpac/FPACOPS.s.sol
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.15;

// Scripts
import { StdAssertions } from "forge-std/StdAssertions.sol";
import "scripts/deploy/Deploy.s.sol";

// Contracts
import { Proxy } from "src/universal/Proxy.sol";

// Libraries
import "src/dispute/lib/Types.sol";

// Interfaces
import { IDisputeGame } from "src/dispute/interfaces/IDisputeGame.sol";
import { AnchorStateRegistry, IAnchorStateRegistry } from "src/dispute/AnchorStateRegistry.sol";
import { IAnchorStateRegistry } from "src/dispute/interfaces/IAnchorStateRegistry.sol";
import { IDelayedWETH } from "src/dispute/interfaces/IDelayedWETH.sol";
import { StdAssertions } from "forge-std/StdAssertions.sol";
import "src/dispute/lib/Types.sol";
import "scripts/deploy/Deploy.s.sol";
import { IFaultDisputeGame } from "src/dispute/interfaces/IFaultDisputeGame.sol";
import { IPermissionedDisputeGame } from "src/dispute/interfaces/IPermissionedDisputeGame.sol";

/// @notice Deploys the Fault Proof Alpha Chad contracts.
contract FPACOPS is Deploy, StdAssertions {
Expand Down Expand Up @@ -70,11 +79,11 @@ contract FPACOPS is Deploy, StdAssertions {

address dgfProxy = mustGetAddress("DisputeGameFactoryProxy");
Proxy(payable(dgfProxy)).upgradeToAndCall(
mustGetAddress("DisputeGameFactory"), abi.encodeCall(DisputeGameFactory.initialize, msg.sender)
mustGetAddress("DisputeGameFactory"), abi.encodeCall(IDisputeGameFactory.initialize, msg.sender)
);

// Set the initialization bonds for the FaultDisputeGame and PermissionedDisputeGame.
DisputeGameFactory dgf = DisputeGameFactory(dgfProxy);
IDisputeGameFactory dgf = IDisputeGameFactory(dgfProxy);
dgf.setInitBond(GameTypes.CANNON, 0.08 ether);
dgf.setInitBond(GameTypes.PERMISSIONED_CANNON, 0.08 ether);
}
Expand All @@ -86,7 +95,7 @@ contract FPACOPS is Deploy, StdAssertions {
address superchainConfigProxy = mustGetAddress("SuperchainConfigProxy");
Proxy(payable(wethProxy)).upgradeToAndCall(
mustGetAddress("DelayedWETH"),
abi.encodeCall(DelayedWETH.initialize, (msg.sender, ISuperchainConfig(superchainConfigProxy)))
abi.encodeCall(IDelayedWETH.initialize, (msg.sender, ISuperchainConfig(superchainConfigProxy)))
);
}

Expand All @@ -95,15 +104,15 @@ contract FPACOPS is Deploy, StdAssertions {
address superchainConfigProxy = mustGetAddress("SuperchainConfigProxy");
ISuperchainConfig superchainConfig = ISuperchainConfig(superchainConfigProxy);

AnchorStateRegistry.StartingAnchorRoot[] memory roots = new AnchorStateRegistry.StartingAnchorRoot[](2);
roots[0] = AnchorStateRegistry.StartingAnchorRoot({
IAnchorStateRegistry.StartingAnchorRoot[] memory roots = new IAnchorStateRegistry.StartingAnchorRoot[](2);
roots[0] = IAnchorStateRegistry.StartingAnchorRoot({
gameType: GameTypes.CANNON,
outputRoot: OutputRoot({
root: Hash.wrap(cfg.faultGameGenesisOutputRoot()),
l2BlockNumber: cfg.faultGameGenesisBlock()
})
});
roots[1] = AnchorStateRegistry.StartingAnchorRoot({
roots[1] = IAnchorStateRegistry.StartingAnchorRoot({
gameType: GameTypes.PERMISSIONED_CANNON,
outputRoot: OutputRoot({
root: Hash.wrap(cfg.faultGameGenesisOutputRoot()),
Expand All @@ -114,14 +123,14 @@ contract FPACOPS is Deploy, StdAssertions {
address asrProxy = mustGetAddress("AnchorStateRegistryProxy");
Proxy(payable(asrProxy)).upgradeToAndCall(
mustGetAddress("AnchorStateRegistry"),
abi.encodeCall(AnchorStateRegistry.initialize, (roots, superchainConfig))
abi.encodeCall(IAnchorStateRegistry.initialize, (roots, superchainConfig))
);
}

/// @notice Transfers admin rights of the `DisputeGameFactoryProxy` to the `ProxyAdmin` and sets the
/// `DisputeGameFactory` owner to the `SystemOwnerSafe`.
function transferDGFOwnershipFinal(address _proxyAdmin, address _systemOwnerSafe) internal broadcast {
DisputeGameFactory dgf = DisputeGameFactory(mustGetAddress("DisputeGameFactoryProxy"));
IDisputeGameFactory dgf = IDisputeGameFactory(mustGetAddress("DisputeGameFactoryProxy"));

// Transfer the ownership of the DisputeGameFactory to the SystemOwnerSafe.
dgf.transferOwnership(_systemOwnerSafe);
Expand All @@ -134,7 +143,7 @@ contract FPACOPS is Deploy, StdAssertions {
/// @notice Transfers admin rights of the `DelayedWETHProxy` to the `ProxyAdmin` and sets the
/// `DelayedWETH` owner to the `SystemOwnerSafe`.
function transferWethOwnershipFinal(address _proxyAdmin, address _systemOwnerSafe) internal broadcast {
DelayedWETH weth = DelayedWETH(mustGetAddress("DelayedWETHProxy"));
IDelayedWETH weth = IDelayedWETH(mustGetAddress("DelayedWETHProxy"));

// Transfer the ownership of the DelayedWETH to the SystemOwnerSafe.
weth.transferOwnership(_systemOwnerSafe);
Expand All @@ -146,7 +155,7 @@ contract FPACOPS is Deploy, StdAssertions {

/// @notice Transfers admin rights of the `AnchorStateRegistryProxy` to the `ProxyAdmin`.
function transferAnchorStateOwnershipFinal(address _proxyAdmin) internal broadcast {
AnchorStateRegistry asr = AnchorStateRegistry(mustGetAddress("AnchorStateRegistryProxy"));
IAnchorStateRegistry asr = IAnchorStateRegistry(mustGetAddress("AnchorStateRegistryProxy"));

// Transfer the admin rights of the AnchorStateRegistryProxy to the ProxyAdmin.
Proxy prox = Proxy(payable(address(asr)));
Expand All @@ -163,7 +172,7 @@ contract FPACOPS is Deploy, StdAssertions {

// Ensure the contracts are owned by the correct entities.
address dgfProxyAddr = mustGetAddress("DisputeGameFactoryProxy");
DisputeGameFactory dgfProxy = DisputeGameFactory(dgfProxyAddr);
IDisputeGameFactory dgfProxy = IDisputeGameFactory(dgfProxyAddr);
assertEq(address(uint160(uint256(vm.load(dgfProxyAddr, Constants.PROXY_OWNER_ADDRESS)))), _proxyAdmin);
ChainAssertions.checkDisputeGameFactory(contracts, _systemOwnerSafe);
address wethProxyAddr = mustGetAddress("DelayedWETHProxy");
Expand All @@ -181,7 +190,7 @@ contract FPACOPS is Deploy, StdAssertions {
assertEq(address(mips.oracle()), address(oracle));

// Check the AnchorStateRegistry configuration.
AnchorStateRegistry asr = AnchorStateRegistry(mustGetAddress("AnchorStateRegistryProxy"));
IAnchorStateRegistry asr = IAnchorStateRegistry(mustGetAddress("AnchorStateRegistryProxy"));
(Hash root1, uint256 l2BlockNumber1) = asr.anchors(GameTypes.CANNON);
(Hash root2, uint256 l2BlockNumber2) = asr.anchors(GameTypes.PERMISSIONED_CANNON);
assertEq(root1.raw(), cfg.faultGameGenesisOutputRoot());
Expand All @@ -190,7 +199,7 @@ contract FPACOPS is Deploy, StdAssertions {
assertEq(l2BlockNumber2, cfg.faultGameGenesisBlock());

// Check the FaultDisputeGame configuration.
FaultDisputeGame gameImpl = FaultDisputeGame(payable(address(dgfProxy.gameImpls(GameTypes.CANNON))));
IFaultDisputeGame gameImpl = IFaultDisputeGame(payable(address(dgfProxy.gameImpls(GameTypes.CANNON))));
assertEq(gameImpl.maxGameDepth(), cfg.faultGameMaxDepth());
assertEq(gameImpl.splitDepth(), cfg.faultGameSplitDepth());
assertEq(gameImpl.clockExtension().raw(), cfg.faultGameClockExtension());
Expand All @@ -201,8 +210,8 @@ contract FPACOPS is Deploy, StdAssertions {
assertEq(address(gameImpl.vm()), address(mips));

// Check the security override yoke configuration.
PermissionedDisputeGame soyGameImpl =
PermissionedDisputeGame(payable(address(dgfProxy.gameImpls(GameTypes.PERMISSIONED_CANNON))));
IPermissionedDisputeGame soyGameImpl =
IPermissionedDisputeGame(payable(address(dgfProxy.gameImpls(GameTypes.PERMISSIONED_CANNON))));
assertEq(soyGameImpl.proposer(), cfg.l2OutputOracleProposer());
assertEq(soyGameImpl.challenger(), cfg.l2OutputOracleChallenger());
assertEq(soyGameImpl.maxGameDepth(), cfg.faultGameMaxDepth());
Expand Down
89 changes: 52 additions & 37 deletions packages/contracts-bedrock/scripts/fpac/FPACOPS2.s.sol
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.15;

// Scripts
import { StdAssertions } from "forge-std/StdAssertions.sol";
import "scripts/deploy/Deploy.s.sol";

// Contracts
import { Proxy } from "src/universal/Proxy.sol";

// Libraries
import "src/dispute/lib/Types.sol";

// Interfaces
import { IDisputeGame } from "src/dispute/interfaces/IDisputeGame.sol";
import { AnchorStateRegistry, IAnchorStateRegistry } from "src/dispute/AnchorStateRegistry.sol";
import { IAnchorStateRegistry } from "src/dispute/interfaces/IAnchorStateRegistry.sol";
import { IDelayedWETH } from "src/dispute/interfaces/IDelayedWETH.sol";
import { StdAssertions } from "forge-std/StdAssertions.sol";
import "src/dispute/lib/Types.sol";
import "scripts/deploy/Deploy.s.sol";
import { IFaultDisputeGame } from "src/dispute/interfaces/IFaultDisputeGame.sol";
import { IPermissionedDisputeGame } from "src/dispute/interfaces/IPermissionedDisputeGame.sol";

/// @notice Deploys new implementations of the FaultDisputeGame contract and its dependencies
/// assuming that the DisputeGameFactory contract does not need to be modified. Assumes
Expand Down Expand Up @@ -85,18 +94,21 @@ contract FPACOPS2 is Deploy, StdAssertions {
save(
"CannonFaultDisputeGame",
address(
new FaultDisputeGame({
_gameType: GameTypes.CANNON,
_absolutePrestate: loadMipsAbsolutePrestate(),
_maxGameDepth: cfg.faultGameMaxDepth(),
_splitDepth: cfg.faultGameSplitDepth(),
_clockExtension: Duration.wrap(uint64(cfg.faultGameClockExtension())),
_maxClockDuration: Duration.wrap(uint64(cfg.faultGameMaxClockDuration())),
_vm: IBigStepper(mustGetAddress("Mips")),
_weth: DelayedWETH(mustGetAddress("DelayedWETHProxy")),
_anchorStateRegistry: AnchorStateRegistry(mustGetAddress("AnchorStateRegistryProxy")),
_l2ChainId: cfg.l2ChainID()
})
_deploy(
"FaultDisputeGame",
abi.encode(
GameTypes.CANNON,
loadMipsAbsolutePrestate(),
cfg.faultGameMaxDepth(),
cfg.faultGameSplitDepth(),
Duration.wrap(uint64(cfg.faultGameClockExtension())),
Duration.wrap(uint64(cfg.faultGameMaxClockDuration())),
IBigStepper(mustGetAddress("Mips")),
IDelayedWETH(mustGetAddress("DelayedWETHProxy")),
IAnchorStateRegistry(mustGetAddress("AnchorStateRegistryProxy")),
cfg.l2ChainID()
)
)
)
);
}
Expand All @@ -108,20 +120,23 @@ contract FPACOPS2 is Deploy, StdAssertions {
save(
"PermissionedDisputeGame",
address(
new PermissionedDisputeGame({
_gameType: GameTypes.PERMISSIONED_CANNON,
_absolutePrestate: loadMipsAbsolutePrestate(),
_maxGameDepth: cfg.faultGameMaxDepth(),
_splitDepth: cfg.faultGameSplitDepth(),
_clockExtension: Duration.wrap(uint64(cfg.faultGameClockExtension())),
_maxClockDuration: Duration.wrap(uint64(cfg.faultGameMaxClockDuration())),
_vm: IBigStepper(mustGetAddress("Mips")),
_weth: DelayedWETH(mustGetAddress("PermissionedDelayedWETHProxy")),
_anchorStateRegistry: AnchorStateRegistry(mustGetAddress("AnchorStateRegistryProxy")),
_l2ChainId: cfg.l2ChainID(),
_proposer: cfg.l2OutputOracleProposer(),
_challenger: cfg.l2OutputOracleChallenger()
})
_deploy(
"PermissionedDisputeGame",
abi.encode(
GameTypes.PERMISSIONED_CANNON,
loadMipsAbsolutePrestate(),
cfg.faultGameMaxDepth(),
cfg.faultGameSplitDepth(),
Duration.wrap(uint64(cfg.faultGameClockExtension())),
Duration.wrap(uint64(cfg.faultGameMaxClockDuration())),
IBigStepper(mustGetAddress("Mips")),
IDelayedWETH(mustGetAddress("PermissionedDelayedWETHProxy")),
IAnchorStateRegistry(mustGetAddress("AnchorStateRegistryProxy")),
cfg.l2ChainID(),
cfg.l2OutputOracleProposer(),
cfg.l2OutputOracleChallenger()
)
)
)
);
}
Expand All @@ -134,7 +149,7 @@ contract FPACOPS2 is Deploy, StdAssertions {
address superchainConfigProxy = mustGetAddress("SuperchainConfigProxy");
Proxy(payable(wethProxy)).upgradeToAndCall(
mustGetAddress("DelayedWETH"),
abi.encodeCall(DelayedWETH.initialize, (msg.sender, ISuperchainConfig(superchainConfigProxy)))
abi.encodeCall(IDelayedWETH.initialize, (msg.sender, ISuperchainConfig(superchainConfigProxy)))
);
}

Expand All @@ -146,7 +161,7 @@ contract FPACOPS2 is Deploy, StdAssertions {
address superchainConfigProxy = mustGetAddress("SuperchainConfigProxy");
Proxy(payable(wethProxy)).upgradeToAndCall(
mustGetAddress("DelayedWETH"),
abi.encodeCall(DelayedWETH.initialize, (msg.sender, ISuperchainConfig(superchainConfigProxy)))
abi.encodeCall(IDelayedWETH.initialize, (msg.sender, ISuperchainConfig(superchainConfigProxy)))
);
}

Expand All @@ -155,7 +170,7 @@ contract FPACOPS2 is Deploy, StdAssertions {
function transferWethOwnershipFinal(address _proxyAdmin, address _systemOwnerSafe) internal broadcast {
console.log("Transferring ownership of DelayedWETHProxy");

DelayedWETH weth = DelayedWETH(mustGetAddress("DelayedWETHProxy"));
IDelayedWETH weth = IDelayedWETH(mustGetAddress("DelayedWETHProxy"));

// Transfer the ownership of the DelayedWETH to the SystemOwnerSafe.
weth.transferOwnership(_systemOwnerSafe);
Expand All @@ -170,7 +185,7 @@ contract FPACOPS2 is Deploy, StdAssertions {
function transferPermissionedWETHOwnershipFinal(address _proxyAdmin, address _systemOwnerSafe) internal broadcast {
console.log("Transferring ownership of permissioned DelayedWETHProxy");

DelayedWETH weth = DelayedWETH(mustGetAddress("PermissionedDelayedWETHProxy"));
IDelayedWETH weth = IDelayedWETH(mustGetAddress("PermissionedDelayedWETHProxy"));

// Transfer the ownership of the DelayedWETH to the SystemOwnerSafe.
weth.transferOwnership(_systemOwnerSafe);
Expand Down Expand Up @@ -214,11 +229,11 @@ contract FPACOPS2 is Deploy, StdAssertions {
assertEq(address(mips.oracle()), address(oracle));

// Grab ASR
AnchorStateRegistry asr = AnchorStateRegistry(mustGetAddress("AnchorStateRegistryProxy"));
IAnchorStateRegistry asr = IAnchorStateRegistry(mustGetAddress("AnchorStateRegistryProxy"));

// Verify FaultDisputeGame configuration.
address gameAddr = mustGetAddress("CannonFaultDisputeGame");
FaultDisputeGame gameImpl = FaultDisputeGame(payable(gameAddr));
IFaultDisputeGame gameImpl = IFaultDisputeGame(payable(gameAddr));
assertEq(gameImpl.maxGameDepth(), cfg.faultGameMaxDepth());
assertEq(gameImpl.splitDepth(), cfg.faultGameSplitDepth());
assertEq(gameImpl.clockExtension().raw(), cfg.faultGameClockExtension());
Expand All @@ -230,7 +245,7 @@ contract FPACOPS2 is Deploy, StdAssertions {

// Verify security override yoke configuration.
address soyGameAddr = mustGetAddress("PermissionedDisputeGame");
PermissionedDisputeGame soyGameImpl = PermissionedDisputeGame(payable(soyGameAddr));
IPermissionedDisputeGame soyGameImpl = IPermissionedDisputeGame(payable(soyGameAddr));
assertEq(soyGameImpl.proposer(), cfg.l2OutputOracleProposer());
assertEq(soyGameImpl.challenger(), cfg.l2OutputOracleChallenger());
assertEq(soyGameImpl.maxGameDepth(), cfg.faultGameMaxDepth());
Expand Down
Loading

0 comments on commit eaf4d3e

Please sign in to comment.