Commit eaf4d3ed authored by smartcontracts's avatar smartcontracts Committed by GitHub

maint: fix dispute interfaces (#12010)

Fixes the existing dispute interfaces and makes them match the
same style that we're using for all other interfaces.
parent 43ec97dd
......@@ -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
......
......@@ -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";
......@@ -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 {
......@@ -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 });
......@@ -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 });
......@@ -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 });
......
// 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 {
......@@ -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);
}
......@@ -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)))
);
}
......@@ -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()),
......@@ -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);
......@@ -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);
......@@ -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)));
......@@ -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");
......@@ -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());
......@@ -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());
......@@ -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());
......
// 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
......@@ -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()
)
)
)
);
}
......@@ -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()
)
)
)
);
}
......@@ -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)))
);
}
......@@ -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)))
);
}
......@@ -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);
......@@ -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);
......@@ -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());
......@@ -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());
......
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.15;
// Testing
import { FaultDisputeGame_Init } from "test/dispute/FaultDisputeGame.t.sol";
// Scripts
import { Script } from "forge-std/Script.sol";
import { console2 as console } from "forge-std/console2.sol";
import { FaultDisputeGame_Init } from "test/dispute/FaultDisputeGame.t.sol";
import { DisputeGameFactory } from "src/dispute/DisputeGameFactory.sol";
import { FaultDisputeGame } from "src/dispute/FaultDisputeGame.sol";
import { IFaultDisputeGame } from "src/dispute/interfaces/IFaultDisputeGame.sol";
import { Process } from "scripts/libraries/Process.sol";
// Libraries
import "src/dispute/lib/Types.sol";
import "src/dispute/lib/Errors.sol";
// Interfaces
import { IFaultDisputeGame } from "src/dispute/interfaces/IFaultDisputeGame.sol";
/**
* @title FaultDisputeGameViz
* @dev To run this script, make sure to install the `dagviz` & `eth_abi` python packages.
......@@ -43,7 +46,7 @@ contract FaultDisputeGameViz is Script, FaultDisputeGame_Init {
* @dev Entry point
*/
function remote(address _addr) public {
gameProxy = FaultDisputeGame(payable(_addr));
gameProxy = IFaultDisputeGame(payable(_addr));
buildGraph();
console.log("Saved graph to `./dispute_game.svg");
}
......
......@@ -152,20 +152,20 @@
"sourceCodeHash": "0xdb9421a552e6d7581b3db9e4c2a02d8210ad6ca66ba0f8703d77f7cd4b8e132b"
},
"src/dispute/AnchorStateRegistry.sol": {
"initCodeHash": "0x73a094f7d00422c8a765a63f4645f9e2fb508655181f227fd9b338c62c26e106",
"sourceCodeHash": "0x7ed9631efb6f5cdec9fb09bc22f0e6248314db6331ed65f0baa462b230733b88"
"initCodeHash": "0x13d00eef8c3f769863fc766180acc8586f5da309ca0a098e67d4d90bd3243341",
"sourceCodeHash": "0x39a23c91d4c5380d285f49660b858d39f3fa27bdbfbc72e0e14587e7c57dfae9"
},
"src/dispute/DelayedWETH.sol": {
"initCodeHash": "0xbda8166b77517df1df1dcef7c307c11a5520188f83555aec9439f6887c419dd0",
"sourceCodeHash": "0x70192d1eae4e16f791d826edf75a825246136fe5f8645b066a401b1dfee3e38c"
"initCodeHash": "0x835b322de7d5c84b415e99f2cb1000411df18995b5476f2116ac6f897f2d0910",
"sourceCodeHash": "0xdbd64724b73f8f9d6f1cc72bb662a99b9955ab72950a8f6ffeb1d2454997f60b"
},
"src/dispute/DisputeGameFactory.sol": {
"initCodeHash": "0xc1a10f65287c414076b68a7de6c238b91bc6252213187bdef35657d0f00f9382",
"sourceCodeHash": "0x3d391c58420abe60d8486136a57d7f9c7137f722c80a8d884305617eb31566ef"
"initCodeHash": "0xb91623cca41e63e6e5a75c681b0d9ef7cb8bf68e7ff5e202a217629899fae099",
"sourceCodeHash": "0xc8f21c777b2c5a37c2d2f92e8eeceba3b231b500a7d9cb0b607b774478f8be6b"
},
"src/dispute/FaultDisputeGame.sol": {
"initCodeHash": "0x0084ca38e6ceb3c70ce77ef9769a724e8be5b92457222ef2b09c63bb4b449bf2",
"sourceCodeHash": "0xf199eace79690c010d0f252819e62ef7ad165d9af19c1ee47a6aa451cda259b2"
"initCodeHash": "0xdb724dfd12dcea804d1adbc5a7e919625615c62b940035cf4b9115ea3a63e0ae",
"sourceCodeHash": "0x223428ee91532af397cef72356430ff59221e0ac0cbf697a881d36bb1d672392"
},
"src/legacy/DeployerWhitelist.sol": {
"initCodeHash": "0x0b8177ed75b69eddbb9ce6537683f69a9935efed86a1d6faa8feaafbd151c1bd",
......@@ -196,8 +196,8 @@
"sourceCodeHash": "0x3a0a294932d6deba043f6a2b46b4e8477ee96e7fb054d7e7229a43ce4352c68d"
},
"src/safe/DeputyGuardianModule.sol": {
"initCodeHash": "0x785cb529957f4d42d1659f2c37967dce7c621f3c6e06550600897205c2551a88",
"sourceCodeHash": "0xc8df2c0ae90cff18ddd4d2b8e2d44689e3c4c98e96c746c4ee9baaebf6a80ec4"
"initCodeHash": "0x308212d163aad169a5e42ce703a1ce36f5425ad96037850c0747177041f6596e",
"sourceCodeHash": "0xde1a289c1cb0bf92138daf8f3db7457be2f84bedaa111b536f646dd6e121718c"
},
"src/safe/LivenessGuard.sol": {
"initCodeHash": "0xfd74ff89e7b689b38ab97515d64429ffaf6c0cd1ea6488c6a4743a0665419c85",
......
......@@ -74,7 +74,7 @@
{
"inputs": [
{
"internalType": "contract AnchorStateRegistry",
"internalType": "contract IAnchorStateRegistry",
"name": "_registry",
"type": "address"
},
......
......@@ -81,7 +81,7 @@
"type": "bytes"
}
],
"internalType": "struct IDisputeGameFactory.GameSearchResult[]",
"internalType": "struct DisputeGameFactory.GameSearchResult[]",
"name": "games_",
"type": "tuple[]"
}
......
......@@ -53,7 +53,7 @@
"label": "withdrawals",
"offset": 0,
"slot": "103",
"type": "mapping(address => mapping(address => struct IDelayedWETH.WithdrawalRequest))"
"type": "mapping(address => mapping(address => struct DelayedWETH.WithdrawalRequest))"
},
{
"bytes": "20",
......
......@@ -46,7 +46,7 @@
"label": "claimData",
"offset": 0,
"slot": "2",
"type": "struct IFaultDisputeGame.ClaimData[]"
"type": "struct FaultDisputeGame.ClaimData[]"
},
{
"bytes": "32",
......@@ -81,7 +81,7 @@
"label": "resolutionCheckpoints",
"offset": 0,
"slot": "7",
"type": "mapping(uint256 => struct IFaultDisputeGame.ResolutionCheckpoint)"
"type": "mapping(uint256 => struct FaultDisputeGame.ResolutionCheckpoint)"
},
{
"bytes": "64",
......
......@@ -46,7 +46,7 @@
"label": "claimData",
"offset": 0,
"slot": "2",
"type": "struct IFaultDisputeGame.ClaimData[]"
"type": "struct FaultDisputeGame.ClaimData[]"
},
{
"bytes": "32",
......@@ -81,7 +81,7 @@
"label": "resolutionCheckpoints",
"offset": 0,
"slot": "7",
"type": "mapping(uint256 => struct IFaultDisputeGame.ResolutionCheckpoint)"
"type": "mapping(uint256 => struct FaultDisputeGame.ResolutionCheckpoint)"
},
{
"bytes": "64",
......
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
interface IL1BlockIsthmus {
type ConfigType is uint8;
enum ConfigType {
SET_GAS_PAYING_TOKEN,
ADD_DEPENDENCY,
REMOVE_DEPENDENCY
}
interface IL1BlockIsthmus {
error AlreadyDependency();
error CantRemovedDependency();
error DependencySetSizeTooLarge();
......
// SPDX-License-Identifier: MIT
pragma solidity 0.8.15;
// Contracts
import { Initializable } from "@openzeppelin/contracts/proxy/utils/Initializable.sol";
import { ISemver } from "src/universal/interfaces/ISemver.sol";
import { IAnchorStateRegistry } from "src/dispute/interfaces/IAnchorStateRegistry.sol";
// Libraries
import "src/dispute/lib/Types.sol";
import { Unauthorized } from "src/libraries/errors/CommonErrors.sol";
import { UnregisteredGame, InvalidGameStatus } from "src/dispute/lib/Errors.sol";
// Interfaces
import { ISemver } from "src/universal/interfaces/ISemver.sol";
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 { ISuperchainConfig } from "src/L1/interfaces/ISuperchainConfig.sol";
import "src/dispute/lib/Types.sol";
import { Unauthorized } from "src/libraries/errors/CommonErrors.sol";
import { UnregisteredGame, InvalidGameStatus } from "src/dispute/lib/Errors.sol";
/// @custom:proxied true
/// @title AnchorStateRegistry
/// @notice The AnchorStateRegistry is a contract that stores the latest "anchor" state for each available
/// FaultDisputeGame type. The anchor state is the latest state that has been proposed on L1 and was not
/// challenged within the challenge period. By using stored anchor states, new FaultDisputeGame instances can
/// be initialized with a more recent starting state which reduces the amount of required offchain computation.
contract AnchorStateRegistry is Initializable, IAnchorStateRegistry, ISemver {
contract AnchorStateRegistry is Initializable, ISemver {
/// @notice Describes an initial anchor state for a game type.
struct StartingAnchorRoot {
GameType gameType;
......@@ -28,13 +30,13 @@ contract AnchorStateRegistry is Initializable, IAnchorStateRegistry, ISemver {
}
/// @notice Semantic version.
/// @custom:semver 2.0.1-beta.2
string public constant version = "2.0.1-beta.2";
/// @custom:semver 2.0.1-beta.3
string public constant version = "2.0.1-beta.3";
/// @notice DisputeGameFactory address.
IDisputeGameFactory internal immutable DISPUTE_GAME_FACTORY;
/// @inheritdoc IAnchorStateRegistry
/// @notice Returns the anchor state for the given game type.
mapping(GameType => OutputRoot) public anchors;
/// @notice Address of the SuperchainConfig contract.
......@@ -63,12 +65,15 @@ contract AnchorStateRegistry is Initializable, IAnchorStateRegistry, ISemver {
superchainConfig = _superchainConfig;
}
/// @inheritdoc IAnchorStateRegistry
/// @notice Returns the DisputeGameFactory address.
/// @return DisputeGameFactory address.
function disputeGameFactory() external view returns (IDisputeGameFactory) {
return DISPUTE_GAME_FACTORY;
}
/// @inheritdoc IAnchorStateRegistry
/// @notice Callable by FaultDisputeGame contracts to update the anchor state. Pulls the anchor state directly from
/// the FaultDisputeGame contract and stores it in the registry if the new anchor state is valid and the
/// state is newer than the current anchor state.
function tryUpdateAnchorState() external {
// Grab the game and game data.
IFaultDisputeGame game = IFaultDisputeGame(msg.sender);
......@@ -96,7 +101,8 @@ contract AnchorStateRegistry is Initializable, IAnchorStateRegistry, ISemver {
anchors[gameType] = OutputRoot({ l2BlockNumber: game.l2BlockNumber(), root: Hash.wrap(game.rootClaim().raw()) });
}
/// @inheritdoc IAnchorStateRegistry
/// @notice Sets the anchor state given the game.
/// @param _game The game to set the anchor state for.
function setAnchorState(IFaultDisputeGame _game) external {
if (msg.sender != superchainConfig.guardian()) revert Unauthorized();
......
......@@ -7,8 +7,6 @@ import { WETH98 } from "src/universal/WETH98.sol";
// Interfaces
import { ISemver } from "src/universal/interfaces/ISemver.sol";
import { IWETH } from "src/universal/interfaces/IWETH.sol";
import { IDelayedWETH } from "src/dispute/interfaces/IDelayedWETH.sol";
import { ISuperchainConfig } from "src/L1/interfaces/ISuperchainConfig.sol";
/// @custom:proxied true
......@@ -21,12 +19,23 @@ import { ISuperchainConfig } from "src/L1/interfaces/ISuperchainConfig.sol";
/// is meant to sit behind a proxy contract and has an owner address that can pull WETH from any account and
/// can recover ETH from the contract itself. Variable and function naming vaguely follows the vibe of WETH9.
/// Not the prettiest contract in the world, but it gets the job done.
contract DelayedWETH is OwnableUpgradeable, WETH98, IDelayedWETH, ISemver {
contract DelayedWETH is OwnableUpgradeable, WETH98, ISemver {
/// @notice Represents a withdrawal request.
struct WithdrawalRequest {
uint256 amount;
uint256 timestamp;
}
/// @notice Emitted when an unwrap is started.
/// @param src The address that started the unwrap.
/// @param wad The amount of WETH that was unwrapped.
event Unwrap(address indexed src, uint256 wad);
/// @notice Semantic version.
/// @custom:semver 1.2.0-beta.1
string public constant version = "1.2.0-beta.1";
/// @custom:semver 1.2.0-beta.2
string public constant version = "1.2.0-beta.2";
/// @inheritdoc IDelayedWETH
/// @notice Returns a withdrawal request for the given address.
mapping(address => mapping(address => WithdrawalRequest)) public withdrawals;
/// @notice Withdrawal delay in seconds.
......@@ -50,12 +59,15 @@ contract DelayedWETH is OwnableUpgradeable, WETH98, IDelayedWETH, ISemver {
config = _config;
}
/// @inheritdoc IDelayedWETH
/// @notice Returns the withdrawal delay in seconds.
/// @return The withdrawal delay in seconds.
function delay() external view returns (uint256) {
return DELAY_SECONDS;
}
/// @inheritdoc IDelayedWETH
/// @notice Unlocks withdrawals for the sender's account, after a time delay.
/// @param _guy Sub-account to unlock.
/// @param _wad The amount of WETH to unlock.
function unlock(address _guy, uint256 _wad) external {
// Note that the unlock function can be called by any address, but the actual unlocking capability still only
// gives the msg.sender the ability to withdraw from the account. As long as the unlock and withdraw functions
......@@ -67,12 +79,15 @@ contract DelayedWETH is OwnableUpgradeable, WETH98, IDelayedWETH, ISemver {
wd.amount += _wad;
}
/// @inheritdoc IWETH
function withdraw(uint256 _wad) public override(WETH98, IWETH) {
/// @notice Withdraws an amount of ETH.
/// @param _wad The amount of ETH to withdraw.
function withdraw(uint256 _wad) public override {
withdraw(msg.sender, _wad);
}
/// @inheritdoc IDelayedWETH
/// @notice Extension to withdrawal, must provide a sub-account to withdraw from.
/// @param _guy Sub-account to withdraw from.
/// @param _wad The amount of WETH to withdraw.
function withdraw(address _guy, uint256 _wad) public {
require(!config.paused(), "DelayedWETH: contract is paused");
WithdrawalRequest storage wd = withdrawals[msg.sender][_guy];
......@@ -83,7 +98,8 @@ contract DelayedWETH is OwnableUpgradeable, WETH98, IDelayedWETH, ISemver {
super.withdraw(_wad);
}
/// @inheritdoc IDelayedWETH
/// @notice Allows the owner to recover from error cases by pulling ETH out of the contract.
/// @param _wad The amount of WETH to recover.
function recover(uint256 _wad) external {
require(msg.sender == owner(), "DelayedWETH: not owner");
uint256 amount = _wad < address(this).balance ? _wad : address(this).balance;
......@@ -91,7 +107,9 @@ contract DelayedWETH is OwnableUpgradeable, WETH98, IDelayedWETH, ISemver {
require(success, "DelayedWETH: recover failed");
}
/// @inheritdoc IDelayedWETH
/// @notice Allows the owner to recover from error cases by pulling ETH from a specific owner.
/// @param _guy The address to recover the WETH from.
/// @param _wad The amount of WETH to recover.
function hold(address _guy, uint256 _wad) external {
require(msg.sender == owner(), "DelayedWETH: not owner");
allowance[_guy][msg.sender] = _wad;
......
// SPDX-License-Identifier: MIT
pragma solidity 0.8.15;
import { LibClone } from "@solady/utils/LibClone.sol";
// Contracts
import { OwnableUpgradeable } from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import { ISemver } from "src/universal/interfaces/ISemver.sol";
import { IDisputeGame } from "src/dispute/interfaces/IDisputeGame.sol";
import { IDisputeGameFactory } from "src/dispute/interfaces/IDisputeGameFactory.sol";
// Libraries
import { LibClone } from "@solady/utils/LibClone.sol";
import "src/dispute/lib/Types.sol";
import "src/dispute/lib/Errors.sol";
// Interfaces
import { ISemver } from "src/universal/interfaces/ISemver.sol";
import { IDisputeGame } from "src/dispute/interfaces/IDisputeGame.sol";
/// @custom:proxied true
/// @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 to make offchain discoverability of playable
/// dispute games easier.
contract DisputeGameFactory is OwnableUpgradeable, IDisputeGameFactory, ISemver {
contract DisputeGameFactory is OwnableUpgradeable, ISemver {
/// @dev Allows for the creation of clone proxies with immutable arguments.
using LibClone for address;
/// @notice Emitted when a new dispute game is created
/// @param disputeProxy The address of the dispute game proxy
/// @param gameType The type of the dispute game proxy's implementation
/// @param rootClaim The root claim of the dispute game
event DisputeGameCreated(address indexed disputeProxy, GameType indexed gameType, Claim indexed rootClaim);
/// @notice Emitted when a new game implementation added to the factory
/// @param impl The implementation contract for the given `GameType`.
/// @param gameType The type of the DisputeGame.
event ImplementationSet(address indexed impl, GameType indexed gameType);
/// @notice Emitted when a game type's initialization bond is updated
/// @param gameType The type of the DisputeGame.
/// @param newBond The new bond (in wei) for initializing the game type.
event InitBondUpdated(GameType indexed gameType, uint256 indexed newBond);
/// @notice Information about a dispute game found in a `findLatestGames` search.
struct GameSearchResult {
uint256 index;
GameId metadata;
Timestamp timestamp;
Claim rootClaim;
bytes extraData;
}
/// @notice Semantic version.
/// @custom:semver 1.0.1-beta.1
string public constant version = "1.0.1-beta.1";
/// @custom:semver 1.0.1-beta.2
string public constant version = "1.0.1-beta.2";
/// @inheritdoc IDisputeGameFactory
/// @notice `gameImpls` is a mapping that maps `GameType`s to their respective
/// `IDisputeGame` implementations.
mapping(GameType => IDisputeGame) public gameImpls;
/// @inheritdoc IDisputeGameFactory
/// @notice Returns the required bonds for initializing a dispute game of the given type.
mapping(GameType => uint256) public initBonds;
/// @notice Mapping of a hash of `gameType || rootClaim || extraData` to the deployed `IDisputeGame` clone (where
......@@ -51,12 +79,21 @@ contract DisputeGameFactory is OwnableUpgradeable, IDisputeGameFactory, ISemver
_transferOwnership(_owner);
}
/// @inheritdoc IDisputeGameFactory
/// @notice The total number of dispute games created by this factory.
/// @return gameCount_ The total number of dispute games created by this factory.
function gameCount() external view returns (uint256 gameCount_) {
gameCount_ = _disputeGameList.length;
}
/// @inheritdoc IDisputeGameFactory
/// @notice `games` queries an internal mapping that maps the hash of
/// `gameType ++ rootClaim ++ extraData` to the deployed `DisputeGame` clone.
/// @dev `++` equates to concatenation.
/// @param _gameType The type of the DisputeGame - used to decide the proxy implementation
/// @param _rootClaim The root claim of the DisputeGame.
/// @param _extraData Any extra data that should be provided to the created dispute game.
/// @return proxy_ The clone of the `DisputeGame` created with the given parameters.
/// Returns `address(0)` if nonexistent.
/// @return timestamp_ The timestamp of the creation of the dispute game.
function games(
GameType _gameType,
Claim _rootClaim,
......@@ -71,7 +108,13 @@ contract DisputeGameFactory is OwnableUpgradeable, IDisputeGameFactory, ISemver
(proxy_, timestamp_) = (IDisputeGame(proxy), timestamp);
}
/// @inheritdoc IDisputeGameFactory
/// @notice `gameAtIndex` returns the dispute game contract address and its creation timestamp
/// at the given index. Each created dispute game increments the underlying index.
/// @param _index The index of the dispute game.
/// @return gameType_ The type of the DisputeGame - used to decide the proxy implementation.
/// @return timestamp_ The timestamp of the creation of the dispute game.
/// @return proxy_ The clone of the `DisputeGame` created with the given parameters.
/// Returns `address(0)` if nonexistent.
function gameAtIndex(uint256 _index)
external
view
......@@ -81,7 +124,11 @@ contract DisputeGameFactory is OwnableUpgradeable, IDisputeGameFactory, ISemver
(gameType_, timestamp_, proxy_) = (gameType, timestamp, IDisputeGame(proxy));
}
/// @inheritdoc IDisputeGameFactory
/// @notice Creates a new DisputeGame proxy contract.
/// @param _gameType The type of the DisputeGame - used to decide the proxy implementation.
/// @param _rootClaim The root claim of the DisputeGame.
/// @param _extraData Any extra data that should be provided to the created dispute game.
/// @return proxy_ The address of the created DisputeGame proxy.
function create(
GameType _gameType,
Claim _rootClaim,
......@@ -132,7 +179,13 @@ contract DisputeGameFactory is OwnableUpgradeable, IDisputeGameFactory, ISemver
emit DisputeGameCreated(address(proxy_), _gameType, _rootClaim);
}
/// @inheritdoc IDisputeGameFactory
/// @notice Returns a unique identifier for the given dispute game parameters.
/// @dev Hashes the concatenation of `gameType . rootClaim . extraData`
/// without expanding memory.
/// @param _gameType The type of the DisputeGame.
/// @param _rootClaim The root claim of the DisputeGame.
/// @param _extraData Any extra data that should be provided to the created dispute game.
/// @return uuid_ The unique identifier for the given dispute game parameters.
function getGameUUID(
GameType _gameType,
Claim _rootClaim,
......@@ -145,7 +198,11 @@ contract DisputeGameFactory is OwnableUpgradeable, IDisputeGameFactory, ISemver
uuid_ = Hash.wrap(keccak256(abi.encode(_gameType, _rootClaim, _extraData)));
}
/// @inheritdoc IDisputeGameFactory
/// @notice Finds the `_n` most recent `GameId`'s of type `_gameType` starting at `_start`. If there are less than
/// `_n` games of type `_gameType` starting at `_start`, then the returned array will be shorter than `_n`.
/// @param _gameType The type of game to find.
/// @param _start The index to start the reverse search from.
/// @param _n The number of games to find.
function findLatestGames(
GameType _gameType,
uint256 _start,
......@@ -196,13 +253,19 @@ contract DisputeGameFactory is OwnableUpgradeable, IDisputeGameFactory, ISemver
}
}
/// @inheritdoc IDisputeGameFactory
/// @notice Sets the implementation contract for a specific `GameType`.
/// @dev May only be called by the `owner`.
/// @param _gameType The type of the DisputeGame.
/// @param _impl The implementation contract for the given `GameType`.
function setImplementation(GameType _gameType, IDisputeGame _impl) external onlyOwner {
gameImpls[_gameType] = _impl;
emit ImplementationSet(address(_impl), _gameType);
}
/// @inheritdoc IDisputeGameFactory
/// @notice Sets the bond (in wei) for initializing a game type.
/// @dev May only be called by the `owner`.
/// @param _gameType The type of the DisputeGame.
/// @param _initBond The bond (in wei) for initializing a game type.
function setInitBond(GameType _gameType, uint256 _initBond) external onlyOwner {
initBonds[_gameType] = _initBond;
emit InitBondUpdated(_gameType, _initBond);
......
// SPDX-License-Identifier: MIT
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";
// Contracts
import { FaultDisputeGame } from "src/dispute/FaultDisputeGame.sol";
// Libraries
import "src/dispute/lib/Types.sol";
import "src/dispute/lib/Errors.sol";
// Interfaces
import { IDelayedWETH } from "src/dispute/interfaces/IDelayedWETH.sol";
import { IAnchorStateRegistry } from "src/dispute/interfaces/IAnchorStateRegistry.sol";
import { IBigStepper } from "src/dispute/interfaces/IBigStepper.sol";
/// @title PermissionedDisputeGame
/// @notice PermissionedDisputeGame is a contract that inherits from `FaultDisputeGame`, and contains two roles:
/// - The `challenger` role, which is allowed to challenge a dispute.
......@@ -73,7 +79,7 @@ contract PermissionedDisputeGame is FaultDisputeGame {
CHALLENGER = _challenger;
}
/// @inheritdoc IFaultDisputeGame
/// @inheritdoc FaultDisputeGame
function step(
uint256 _claimIndex,
bool _isAttack,
......@@ -106,7 +112,7 @@ contract PermissionedDisputeGame is FaultDisputeGame {
super.move(_disputed, _challengeIndex, _claim, _isAttack);
}
/// @inheritdoc IInitializable
/// @notice Initializes the contract.
function initialize() public payable override {
// The creator of the dispute game must be the proposer EOA.
if (tx.origin != PROPOSER) revert BadAuth();
......
......@@ -3,27 +3,30 @@ pragma solidity ^0.8.0;
import { IFaultDisputeGame } from "src/dispute/interfaces/IFaultDisputeGame.sol";
import { IDisputeGameFactory } from "src/dispute/interfaces/IDisputeGameFactory.sol";
import { ISuperchainConfig } from "src/L1/interfaces/ISuperchainConfig.sol";
import "src/dispute/lib/Types.sol";
/// @title IAnchorStateRegistry
/// @notice Describes a contract that stores the anchor state for each game type.
interface IAnchorStateRegistry {
/// @notice Returns the anchor state for the given game type.
/// @param _gameType The game type to get the anchor state for.
/// @return The anchor state for the given game type.
function anchors(GameType _gameType) external view returns (Hash, uint256);
struct StartingAnchorRoot {
GameType gameType;
OutputRoot outputRoot;
}
/// @notice Returns the DisputeGameFactory address.
/// @return DisputeGameFactory address.
function disputeGameFactory() external view returns (IDisputeGameFactory);
error InvalidGameStatus();
error Unauthorized();
error UnregisteredGame();
/// @notice Callable by FaultDisputeGame contracts to update the anchor state. Pulls the anchor state directly from
/// the FaultDisputeGame contract and stores it in the registry if the new anchor state is valid and the
/// state is newer than the current anchor state.
function tryUpdateAnchorState() external;
event Initialized(uint8 version);
/// @notice Sets the anchor state given the game.
/// @param _game The game to set the anchor state for.
function anchors(GameType) external view returns (Hash root, uint256 l2BlockNumber);
function disputeGameFactory() external view returns (IDisputeGameFactory);
function initialize(
StartingAnchorRoot[] memory _startingAnchorRoots,
ISuperchainConfig _superchainConfig
)
external;
function setAnchorState(IFaultDisputeGame _game) external;
function superchainConfig() external view returns (ISuperchainConfig);
function tryUpdateAnchorState() external;
function version() external view returns (string memory);
}
......@@ -2,47 +2,29 @@
pragma solidity ^0.8.0;
import { IWETH } from "src/universal/interfaces/IWETH.sol";
import { ISuperchainConfig } from "src/L1/interfaces/ISuperchainConfig.sol";
/// @title IDelayedWETH
/// @notice Interface for the DelayedWETH contract.
interface IDelayedWETH is IWETH {
/// @notice Represents a withdrawal request.
struct WithdrawalRequest {
uint256 amount;
uint256 timestamp;
}
/// @notice Emitted when an unwrap is started.
/// @param src The address that started the unwrap.
/// @param wad The amount of WETH that was unwrapped.
event Unwrap(address indexed src, uint256 wad);
/// @notice Returns the withdrawal delay in seconds.
/// @return The withdrawal delay in seconds.
function delay() external view returns (uint256);
/// @notice Returns a withdrawal request for the given address.
/// @param _owner The address to query the withdrawal request of.
/// @param _guy Sub-account to query the withdrawal request of.
/// @return The withdrawal request for the given address-subaccount pair.
function withdrawals(address _owner, address _guy) external view returns (uint256, uint256);
fallback() external payable;
receive() external payable;
/// @notice Unlocks withdrawals for the sender's account, after a time delay.
/// @param _guy Sub-account to unlock.
/// @param _wad The amount of WETH to unlock.
function config() external view returns (ISuperchainConfig);
function delay() external view returns (uint256);
function hold(address _guy, uint256 _wad) external;
function initialize(address _owner, ISuperchainConfig _config) external;
function owner() external view returns (address);
function recover(uint256 _wad) external;
function transferOwnership(address newOwner) external;
function renounceOwnership() external;
function unlock(address _guy, uint256 _wad) external;
/// @notice Extension to withdrawal, must provide a sub-account to withdraw from.
/// @param _guy Sub-account to withdraw from.
/// @param _wad The amount of WETH to withdraw.
function withdraw(address _guy, uint256 _wad) external;
/// @notice Allows the owner to recover from error cases by pulling ETH out of the contract.
/// @param _wad The amount of WETH to recover.
function recover(uint256 _wad) external;
/// @notice Allows the owner to recover from error cases by pulling ETH from a specific owner.
/// @param _guy The address to recover the WETH from.
/// @param _wad The amount of WETH to recover.
function hold(address _guy, uint256 _wad) external;
function withdrawals(address _owner, address _guy) external view returns (uint256, uint256);
function version() external view returns (string memory);
}
......@@ -2,68 +2,19 @@
pragma solidity ^0.8.0;
import { IInitializable } from "src/dispute/interfaces/IInitializable.sol";
import "src/dispute/lib/Types.sol";
/// @title IDisputeGame
/// @notice The generic interface for a DisputeGame contract.
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);
/// @notice Returns the timestamp that the DisputeGame contract was created at.
/// @return createdAt_ The timestamp that the DisputeGame contract was created at.
function createdAt() external view returns (Timestamp createdAt_);
/// @notice Returns the timestamp that the DisputeGame contract was resolved at.
/// @return resolvedAt_ The timestamp that the DisputeGame contract was resolved at.
function resolvedAt() external view returns (Timestamp resolvedAt_);
/// @notice Returns the current status of the game.
/// @return status_ The current status of the game.
function status() external view returns (GameStatus status_);
/// @notice Getter for the game type.
/// @dev The reference impl should be entirely different depending on the type (fault, validity)
/// i.e. The game type should indicate the security model.
/// @return gameType_ The type of proof system being used.
function createdAt() external view returns (Timestamp);
function resolvedAt() external view returns (Timestamp);
function status() external view returns (GameStatus);
function gameType() external view returns (GameType gameType_);
/// @notice Getter for the creator of the dispute game.
/// @dev `clones-with-immutable-args` argument #1
/// @return creator_ The creator of the dispute game.
function gameCreator() external pure returns (address creator_);
/// @notice Getter for the root claim.
/// @dev `clones-with-immutable-args` argument #2
/// @return rootClaim_ The root claim of the DisputeGame.
function rootClaim() external pure returns (Claim rootClaim_);
/// @notice Getter for the parent hash of the L1 block when the dispute game was created.
/// @dev `clones-with-immutable-args` argument #3
/// @return l1Head_ The parent hash of the L1 block when the dispute game was created.
function l1Head() external pure returns (Hash l1Head_);
/// @notice Getter for the extra data.
/// @dev `clones-with-immutable-args` argument #4
/// @return extraData_ Any extra data supplied to the dispute game contract by the creator.
function extraData() external pure returns (bytes memory extraData_);
/// @notice If all necessary information has been gathered, this function should mark the game
/// status as either `CHALLENGER_WINS` or `DEFENDER_WINS` and return the status of
/// the resolved game. It is at this stage that the bonds should be awarded to the
/// necessary parties.
/// @dev May only be called if the `status` is `IN_PROGRESS`.
/// @return status_ The status of the game after resolution.
function resolve() external returns (GameStatus status_);
/// @notice A compliant implementation of this interface should return the components of the
/// game UUID's preimage provided in the cwia payload. The preimage of the UUID is
/// constructed as `keccak256(gameType . rootClaim . extraData)` where `.` denotes
/// concatenation.
/// @return gameType_ The type of proof system being used.
/// @return rootClaim_ The root claim of the DisputeGame.
/// @return extraData_ Any extra data supplied to the dispute game contract by the creator.
function gameData() external view returns (GameType gameType_, Claim rootClaim_, bytes memory extraData_);
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import { IDisputeGame } from "./IDisputeGame.sol";
import { IDisputeGame } from "src/dispute/interfaces/IDisputeGame.sol";
import "src/dispute/lib/Types.sol";
/// @title IDisputeGameFactory
/// @notice The interface for a DisputeGameFactory contract.
interface IDisputeGameFactory {
/// @notice Emitted when a new dispute game is created
/// @param disputeProxy The address of the dispute game proxy
/// @param gameType The type of the dispute game proxy's implementation
/// @param rootClaim The root claim of the dispute game
event DisputeGameCreated(address indexed disputeProxy, GameType indexed gameType, Claim indexed rootClaim);
/// @notice Emitted when a new game implementation added to the factory
/// @param impl The implementation contract for the given `GameType`.
/// @param gameType The type of the DisputeGame.
event ImplementationSet(address indexed impl, GameType indexed gameType);
/// @notice Emitted when a game type's initialization bond is updated
/// @param gameType The type of the DisputeGame.
/// @param newBond The new bond (in wei) for initializing the game type.
event InitBondUpdated(GameType indexed gameType, uint256 indexed newBond);
/// @notice Information about a dispute game found in a `findLatestGames` search.
struct GameSearchResult {
uint256 index;
GameId metadata;
......@@ -33,85 +13,46 @@ interface IDisputeGameFactory {
bytes extraData;
}
/// @notice The total number of dispute games created by this factory.
/// @return gameCount_ The total number of dispute games created by this factory.
function gameCount() external view returns (uint256 gameCount_);
error GameAlreadyExists(Hash uuid);
error IncorrectBondAmount();
error NoImplementation(GameType gameType);
/// @notice `games` queries an internal mapping that maps the hash of
/// `gameType ++ rootClaim ++ extraData` to the deployed `DisputeGame` clone.
/// @dev `++` equates to concatenation.
/// @param _gameType The type of the DisputeGame - used to decide the proxy implementation
/// @param _rootClaim The root claim of the DisputeGame.
/// @param _extraData Any extra data that should be provided to the created dispute game.
/// @return proxy_ The clone of the `DisputeGame` created with the given parameters.
/// Returns `address(0)` if nonexistent.
/// @return timestamp_ The timestamp of the creation of the dispute game.
function games(
event DisputeGameCreated(address indexed disputeProxy, GameType indexed gameType, Claim indexed rootClaim);
event ImplementationSet(address indexed impl, GameType indexed gameType);
event InitBondUpdated(GameType indexed gameType, uint256 indexed newBond);
event Initialized(uint8 version);
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
function create(
GameType _gameType,
Claim _rootClaim,
bytes calldata _extraData
bytes memory _extraData
)
external
payable
returns (IDisputeGame proxy_);
function findLatestGames(
GameType _gameType,
uint256 _start,
uint256 _n
)
external
view
returns (IDisputeGame proxy_, Timestamp timestamp_);
/// @notice `gameAtIndex` returns the dispute game contract address and its creation timestamp
/// at the given index. Each created dispute game increments the underlying index.
/// @param _index The index of the dispute game.
/// @return gameType_ The type of the DisputeGame - used to decide the proxy implementation.
/// @return timestamp_ The timestamp of the creation of the dispute game.
/// @return proxy_ The clone of the `DisputeGame` created with the given parameters.
/// Returns `address(0)` if nonexistent.
returns (GameSearchResult[] memory games_);
function gameAtIndex(uint256 _index)
external
view
returns (GameType gameType_, Timestamp timestamp_, IDisputeGame proxy_);
/// @notice `gameImpls` is a mapping that maps `GameType`s to their respective
/// `IDisputeGame` implementations.
/// @param _gameType The type of the dispute game.
/// @return impl_ The address of the implementation of the game type.
/// Will be cloned on creation of a new dispute game with the given `gameType`.
function gameImpls(GameType _gameType) external view returns (IDisputeGame impl_);
/// @notice Returns the required bonds for initializing a dispute game of the given type.
/// @param _gameType The type of the dispute game.
/// @return bond_ The required bond for initializing a dispute game of the given type.
function initBonds(GameType _gameType) external view returns (uint256 bond_);
/// @notice Creates a new DisputeGame proxy contract.
/// @param _gameType The type of the DisputeGame - used to decide the proxy implementation.
/// @param _rootClaim The root claim of the DisputeGame.
/// @param _extraData Any extra data that should be provided to the created dispute game.
/// @return proxy_ The address of the created DisputeGame proxy.
function create(
function gameCount() external view returns (uint256 gameCount_);
function gameImpls(GameType) external view returns (IDisputeGame);
function games(
GameType _gameType,
Claim _rootClaim,
bytes calldata _extraData
bytes memory _extraData
)
external
payable
returns (IDisputeGame proxy_);
/// @notice Sets the implementation contract for a specific `GameType`.
/// @dev May only be called by the `owner`.
/// @param _gameType The type of the DisputeGame.
/// @param _impl The implementation contract for the given `GameType`.
function setImplementation(GameType _gameType, IDisputeGame _impl) external;
/// @notice Sets the bond (in wei) for initializing a game type.
/// @dev May only be called by the `owner`.
/// @param _gameType The type of the DisputeGame.
/// @param _initBond The bond (in wei) for initializing a game type.
function setInitBond(GameType _gameType, uint256 _initBond) external;
/// @notice Returns a unique identifier for the given dispute game parameters.
/// @dev Hashes the concatenation of `gameType . rootClaim . extraData`
/// without expanding memory.
/// @param _gameType The type of the DisputeGame.
/// @param _rootClaim The root claim of the DisputeGame.
/// @param _extraData Any extra data that should be provided to the created dispute game.
/// @return uuid_ The unique identifier for the given dispute game parameters.
view
returns (IDisputeGame proxy_, Timestamp timestamp_);
function getGameUUID(
GameType _gameType,
Claim _rootClaim,
......@@ -120,18 +61,12 @@ interface IDisputeGameFactory {
external
pure
returns (Hash uuid_);
/// @notice Finds the `_n` most recent `GameId`'s of type `_gameType` starting at `_start`. If there are less than
/// `_n` games of type `_gameType` starting at `_start`, then the returned array will be shorter than `_n`.
/// @param _gameType The type of game to find.
/// @param _start The index to start the reverse search from.
/// @param _n The number of games to find.
function findLatestGames(
GameType _gameType,
uint256 _start,
uint256 _n
)
external
view
returns (GameSearchResult[] memory games_);
function initBonds(GameType) external view returns (uint256);
function initialize(address _owner) external;
function owner() external view returns (address);
function renounceOwnership() external;
function setImplementation(GameType _gameType, IDisputeGame _impl) external;
function setInitBond(GameType _gameType, uint256 _initBond) external;
function transferOwnership(address newOwner) external;
function version() external view returns (string memory);
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import { IDisputeGame } from "./IDisputeGame.sol";
import { IDisputeGame } from "src/dispute/interfaces/IDisputeGame.sol";
import { IDelayedWETH } from "src/dispute/interfaces/IDelayedWETH.sol";
import { IAnchorStateRegistry } from "src/dispute/interfaces/IAnchorStateRegistry.sol";
import { IBigStepper } from "src/dispute/interfaces/IBigStepper.sol";
import { Types } from "src/libraries/Types.sol";
import "src/dispute/lib/Types.sol";
/// @title IFaultDisputeGame
/// @notice The interface for a fault proof backed dispute game.
interface IFaultDisputeGame is IDisputeGame {
/// @notice The `ClaimData` struct represents the data associated with a Claim.
struct ClaimData {
uint32 parentIndex;
address counteredBy;
......@@ -19,7 +19,6 @@ interface IFaultDisputeGame is IDisputeGame {
Clock clock;
}
/// @notice The `ResolutionCheckpoint` struct represents the data associated with an in-progress claim resolution.
struct ResolutionCheckpoint {
bool initialCheckpointComplete;
uint32 subgameIndex;
......@@ -27,73 +26,90 @@ interface IFaultDisputeGame is IDisputeGame {
address counteredBy;
}
/// @notice Emitted when a new claim is added to the DAG by `claimant`
/// @param parentIndex The index within the `claimData` array of the parent claim
/// @param claim The claim being added
/// @param claimant The address of the claimant
error AlreadyInitialized();
error AnchorRootNotFound();
error BlockNumberMatches();
error BondTransferFailed();
error CannotDefendRootClaim();
error ClaimAboveSplit();
error ClaimAlreadyExists();
error ClaimAlreadyResolved();
error ClockNotExpired();
error ClockTimeExceeded();
error ContentLengthMismatch();
error DuplicateStep();
error EmptyItem();
error GameDepthExceeded();
error GameNotInProgress();
error IncorrectBondAmount();
error InvalidChallengePeriod();
error InvalidClockExtension();
error InvalidDataRemainder();
error InvalidDisputedClaimIndex();
error InvalidHeader();
error InvalidHeaderRLP();
error InvalidLocalIdent();
error InvalidOutputRootProof();
error InvalidParent();
error InvalidPrestate();
error InvalidSplitDepth();
error L2BlockNumberChallenged();
error MaxDepthTooLarge();
error NoCreditToClaim();
error OutOfOrderResolution();
error UnexpectedList();
error UnexpectedRootClaim(Claim rootClaim);
error UnexpectedString();
error ValidStep();
event Move(uint256 indexed parentIndex, Claim indexed claim, address indexed claimant);
/// @notice Attack a disagreed upon `Claim`.
/// @param _disputed The `Claim` being attacked.
/// @param _parentIndex Index of the `Claim` to attack in the `claimData` array. This must match the `_disputed`
/// claim.
/// @param _claim The `Claim` at the relative attack position.
function absolutePrestate() external view returns (Claim absolutePrestate_);
function addLocalData(uint256 _ident, uint256 _execLeafIdx, uint256 _partOffset) external;
function anchorStateRegistry() external view returns (IAnchorStateRegistry registry_);
function attack(Claim _disputed, uint256 _parentIndex, Claim _claim) external payable;
/// @notice Defend an agreed upon `Claim`.
/// @notice _disputed The `Claim` being defended.
/// @param _parentIndex Index of the claim to defend in the `claimData` array. This must match the `_disputed`
/// claim.
/// @param _claim The `Claim` at the relative defense position.
function challengeRootL2Block(Types.OutputRootProof memory _outputRootProof, bytes memory _headerRLP) external;
function claimCredit(address _recipient) external;
function claimData(uint256)
external
view
returns (
uint32 parentIndex,
address counteredBy,
address claimant,
uint128 bond,
Claim claim,
Position position,
Clock clock
);
function claimDataLen() external view returns (uint256 len_);
function claims(Hash) external view returns (bool);
function clockExtension() external view returns (Duration clockExtension_);
function credit(address) external view returns (uint256);
function defend(Claim _disputed, uint256 _parentIndex, Claim _claim) external payable;
/// @notice Perform an instruction step via an on-chain fault proof processor.
/// @dev This function should point to a fault proof processor in order to execute
/// a step in the fault proof program on-chain. The interface of the fault proof
/// processor contract should adhere to the `IBigStepper` interface.
/// @param _claimIndex The index of the challenged claim within `claimData`.
/// @param _isAttack Whether or not the step is an attack or a defense.
/// @param _stateData The stateData of the step is the preimage of the claim at the given
/// prestate, which is at `_stateIndex` if the move is an attack and `_claimIndex` if
/// the move is a defense. If the step is an attack on the first instruction, it is
/// the absolute prestate of the fault proof VM.
/// @param _proof Proof to access memory nodes in the VM's merkle state tree.
function step(uint256 _claimIndex, bool _isAttack, bytes calldata _stateData, bytes calldata _proof) external;
/// @notice Posts the requested local data to the VM's `PreimageOralce`.
/// @param _ident The local identifier of the data to post.
/// @param _execLeafIdx The index of the leaf claim in an execution subgame that requires the local data for a step.
/// @param _partOffset The offset of the data to post.
function addLocalData(uint256 _ident, uint256 _execLeafIdx, uint256 _partOffset) external;
/// @notice Resolves the subgame rooted at the given claim index. `_numToResolve` specifies how many children of
/// the subgame will be checked in this call. If `_numToResolve` is less than the number of children, an
/// internal cursor will be updated and this function may be called again to complete resolution of the
/// subgame.
/// @dev This function must be called bottom-up in the DAG
/// A subgame is a tree of claims that has a maximum depth of 1.
/// A subgame root claims is valid if, and only if, all of its child claims are invalid.
/// At the deepest level in the DAG, a claim is invalid if there's a successful step against it.
/// @param _claimIndex The index of the subgame root claim to resolve.
/// @param _numToResolve The number of subgames to resolve in this call. If the input is `0`, and this is the first
/// page, this function will attempt to check all of the subgame's children at once.
function resolveClaim(uint256 _claimIndex, uint256 _numToResolve) external;
/// @notice Returns the number of children that still need to be resolved in order to fully resolve a subgame rooted
/// at `_claimIndex`.
/// @param _claimIndex The subgame root claim's index within `claimData`.
/// @return numRemainingChildren_ The number of children that still need to be checked to resolve the subgame.
function getChallengerDuration(uint256 _claimIndex) external view returns (Duration duration_);
function getNumToResolve(uint256 _claimIndex) external view returns (uint256 numRemainingChildren_);
/// @notice The l2BlockNumber of the disputed output root in the `L2OutputOracle`.
function l2BlockNumber() external view returns (uint256 l2BlockNumber_);
/// @notice Starting output root and block number of the game.
function startingOutputRoot() external view returns (Hash startingRoot_, uint256 l2BlockNumber_);
/// @notice Only the starting block number of the game.
function getRequiredBond(Position _position) external view returns (uint256 requiredBond_);
function l2BlockNumber() external pure returns (uint256 l2BlockNumber_);
function l2BlockNumberChallenged() external view returns (bool);
function l2BlockNumberChallenger() external view returns (address);
function l2ChainId() external view returns (uint256 l2ChainId_);
function maxClockDuration() external view returns (Duration maxClockDuration_);
function maxGameDepth() external view returns (uint256 maxGameDepth_);
function move(Claim _disputed, uint256 _challengeIndex, Claim _claim, bool _isAttack) external payable;
function resolutionCheckpoints(uint256)
external
view
returns (bool initialCheckpointComplete, uint32 subgameIndex, Position leftmostPosition, address counteredBy);
function resolveClaim(uint256 _claimIndex, uint256 _numToResolve) external;
function resolvedSubgames(uint256) external view returns (bool);
function splitDepth() external view returns (uint256 splitDepth_);
function startingBlockNumber() external view returns (uint256 startingBlockNumber_);
/// @notice Only the starting output root of the game.
function startingOutputRoot() external view returns (Hash root, uint256 l2BlockNumber);
function startingRootHash() external view returns (Hash startingRootHash_);
function step(uint256 _claimIndex, bool _isAttack, bytes memory _stateData, bytes memory _proof) external;
function subgames(uint256, uint256) external view returns (uint256);
function version() external view returns (string memory);
function vm() external view returns (IBigStepper vm_);
function weth() external view returns (IDelayedWETH weth_);
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/// @title IInitializable
/// @notice An interface for initializable contracts.
interface IInitializable {
/// @notice Initializes the contract.
/// @dev This function may only be called once.
function initialize() external payable;
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import { IFaultDisputeGame } from "src/dispute/interfaces/IFaultDisputeGame.sol";
interface IPermissionedDisputeGame is IFaultDisputeGame {
error BadAuth();
function proposer() external view returns (address proposer_);
function challenger() external view returns (address challenger_);
}
......@@ -5,14 +5,12 @@ pragma solidity 0.8.15;
import { GnosisSafe as Safe } from "safe-contracts/GnosisSafe.sol";
import { Enum } from "safe-contracts/common/Enum.sol";
// Contracts
import { AnchorStateRegistry } from "src/dispute/AnchorStateRegistry.sol";
// Libraries
import { Unauthorized } from "src/libraries/PortalErrors.sol";
import "src/dispute/lib/Types.sol";
// Interfaces
import { IAnchorStateRegistry } from "src/dispute/interfaces/IAnchorStateRegistry.sol";
import { IFaultDisputeGame } from "src/dispute/interfaces/IFaultDisputeGame.sol";
import { ISuperchainConfig } from "src/L1/interfaces/ISuperchainConfig.sol";
import { IOptimismPortal2 } from "src/L1/interfaces/IOptimismPortal2.sol";
......@@ -50,8 +48,8 @@ contract DeputyGuardianModule is ISemver {
address internal immutable DEPUTY_GUARDIAN;
/// @notice Semantic version.
/// @custom:semver 2.0.1-beta.2
string public constant version = "2.0.1-beta.2";
/// @custom:semver 2.0.1-beta.3
string public constant version = "2.0.1-beta.3";
// Constructor to initialize the Safe and baseModule instances
constructor(Safe _safe, ISuperchainConfig _superchainConfig, address _deputyGuardian) {
......@@ -118,12 +116,12 @@ contract DeputyGuardianModule is ISemver {
/// @notice Calls the Security Council Safe's `execTransactionFromModuleReturnData()`, with the arguments
/// necessary to call `setAnchorState()` on the `AnchorStateRegistry` contract.
/// Only the deputy guardian can call this function.
/// @param _registry The `AnchorStateRegistry` contract instance.
/// @param _registry The `IAnchorStateRegistry` contract instance.
/// @param _game The `IFaultDisputeGame` contract instance.
function setAnchorState(AnchorStateRegistry _registry, IFaultDisputeGame _game) external {
function setAnchorState(IAnchorStateRegistry _registry, IFaultDisputeGame _game) external {
_onlyDeputyGuardian();
bytes memory data = abi.encodeCall(AnchorStateRegistry.setAnchorState, (_game));
bytes memory data = abi.encodeCall(IAnchorStateRegistry.setAnchorState, (_game));
(bool success, bytes memory returnData) =
SAFE.execTransactionFromModuleReturnData(address(_registry), 0, data, Enum.Operation.Call);
if (!success) {
......
......@@ -12,7 +12,6 @@ import { EIP1967Helper } from "test/mocks/EIP1967Helper.sol";
// Contracts
import { Proxy } from "src/universal/Proxy.sol";
import { SuperchainConfig } from "src/L1/SuperchainConfig.sol";
import { FaultDisputeGame, IDisputeGame } from "src/dispute/FaultDisputeGame.sol";
// Libraries
import { Types } from "src/libraries/Types.sol";
......@@ -28,6 +27,8 @@ import "src/libraries/PortalErrors.sol";
import { IResourceMetering } from "src/L1/interfaces/IResourceMetering.sol";
import { IL1Block } from "src/L2/interfaces/IL1Block.sol";
import { IOptimismPortal2 } from "src/L1/interfaces/IOptimismPortal2.sol";
import { IDisputeGame } from "src/dispute/interfaces/IDisputeGame.sol";
import { IFaultDisputeGame } from "src/dispute/interfaces/IFaultDisputeGame.sol";
contract OptimismPortal2_Test is CommonTest {
address depositor;
......@@ -423,7 +424,7 @@ contract OptimismPortal2_FinalizeWithdrawal_Test is CommonTest {
// Reusable default values for a test withdrawal
Types.WithdrawalTransaction _defaultTx;
FaultDisputeGame game;
IFaultDisputeGame game;
uint256 _proposedGameIndex;
uint256 _proposedBlockNumber;
bytes32 _stateRoot;
......@@ -462,7 +463,7 @@ contract OptimismPortal2_FinalizeWithdrawal_Test is CommonTest {
/// @dev Setup the system for a ready-to-use state.
function setUp() public virtual override {
_proposedBlockNumber = 0xFF;
game = FaultDisputeGame(
game = IFaultDisputeGame(
payable(
address(
disputeGameFactory.create(
......
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.15;
// Testing
import { CommonBase } from "forge-std/Base.sol";
import { FaultDisputeGame } from "src/dispute/FaultDisputeGame.sol";
import { IFaultDisputeGame } from "src/dispute/interfaces/IFaultDisputeGame.sol";
// Libraries
import "src/dispute/lib/Types.sol";
// Interfaces
import { IFaultDisputeGame } from "src/dispute/interfaces/IFaultDisputeGame.sol";
/// @title GameSolver
/// @notice The `GameSolver` contract is a contract that can produce an array of available
/// moves for a given `FaultDisputeGame` contract, from the eyes of an honest
......@@ -15,7 +17,7 @@ import "src/dispute/lib/Types.sol";
/// it suggests.
abstract contract GameSolver is CommonBase {
/// @notice The `FaultDisputeGame` proxy that the `GameSolver` will be solving.
FaultDisputeGame public immutable GAME;
IFaultDisputeGame public immutable GAME;
/// @notice The split depth of the game
uint256 internal immutable SPLIT_DEPTH;
/// @notice The max depth of the game
......@@ -55,7 +57,7 @@ abstract contract GameSolver is CommonBase {
}
constructor(
FaultDisputeGame _gameProxy,
IFaultDisputeGame _gameProxy,
uint256[] memory _l2Outputs,
bytes memory _trace,
bytes memory _preStateData
......@@ -89,7 +91,7 @@ contract HonestGameSolver is GameSolver {
}
constructor(
FaultDisputeGame _gameProxy,
IFaultDisputeGame _gameProxy,
uint256[] memory _l2Outputs,
bytes memory _trace,
bytes memory _preStateData
......@@ -223,7 +225,7 @@ contract HonestGameSolver is GameSolver {
move_ = Move({
kind: isAttack ? MoveKind.Attack : MoveKind.Defend,
value: bond,
data: abi.encodeCall(FaultDisputeGame.move, (disputed, _challengeIndex, claimAt(_movePos), isAttack))
data: abi.encodeCall(IFaultDisputeGame.move, (disputed, _challengeIndex, claimAt(_movePos), isAttack))
});
}
......@@ -263,7 +265,7 @@ contract HonestGameSolver is GameSolver {
move_ = Move({
kind: MoveKind.Step,
value: 0,
data: abi.encodeCall(FaultDisputeGame.step, (_challengeIndex, isAttack, preStateTrace, hex""))
data: abi.encodeCall(IFaultDisputeGame.step, (_challengeIndex, isAttack, preStateTrace, hex""))
});
}
......@@ -366,10 +368,10 @@ abstract contract DisputeActor {
/// that this actor *can* be dishonest if the trace is faulty, but it will always follow
/// the rules of the honest actor.
contract HonestDisputeActor is DisputeActor {
FaultDisputeGame public immutable GAME;
IFaultDisputeGame public immutable GAME;
constructor(
FaultDisputeGame _gameProxy,
IFaultDisputeGame _gameProxy,
uint256[] memory _l2Outputs,
bytes memory _trace,
bytes memory _preStateData
......
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.15;
// Testing
import { Test } from "forge-std/Test.sol";
import { FaultDisputeGame_Init, _changeClaimStatus } from "test/dispute/FaultDisputeGame.t.sol";
// Libraries
import "src/dispute/lib/Types.sol";
import "src/dispute/lib/Errors.sol";
import { Test } from "forge-std/Test.sol";
import { FaultDisputeGame_Init, IDisputeGame, _changeClaimStatus } from "test/dispute/FaultDisputeGame.t.sol";
contract AnchorStateRegistry_Init is FaultDisputeGame_Init {
function setUp() public virtual override {
// Duplicating the initialization/setup logic of FaultDisputeGame_Test.
......
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.15;
import "src/dispute/lib/Types.sol";
import "src/dispute/lib/Errors.sol";
// Testing
import { Test } from "forge-std/Test.sol";
import { DisputeGameFactory, IDisputeGameFactory } from "src/dispute/DisputeGameFactory.sol";
import { IDisputeGame } from "src/dispute/interfaces/IDisputeGame.sol";
import { DelayedWETH } from "src/dispute/DelayedWETH.sol";
import { Proxy } from "src/universal/Proxy.sol";
import { Burn } from "src/libraries/Burn.sol";
import { CommonTest } from "test/setup/CommonTest.sol";
// Libraries
import { Burn } from "src/libraries/Burn.sol";
import "src/dispute/lib/Types.sol";
import "src/dispute/lib/Errors.sol";
contract DelayedWETH_Init is CommonTest {
event Approval(address indexed src, address indexed guy, uint256 wad);
event Transfer(address indexed src, address indexed dst, uint256 wad);
......
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.15;
// Testing
import { Test } from "forge-std/Test.sol";
import { CommonTest } from "test/setup/CommonTest.sol";
// Contracts
import { Proxy } from "src/universal/Proxy.sol";
// Libraries
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";
// Interfaces
import { IDisputeGameFactory } from "src/dispute/interfaces/IDisputeGameFactory.sol";
import { IDisputeGame } from "src/dispute/interfaces/IDisputeGame.sol";
import { Proxy } from "src/universal/Proxy.sol";
import { CommonTest } from "test/setup/CommonTest.sol";
contract DisputeGameFactory_Init is CommonTest {
FakeClone fakeClone;
......
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.15;
// Testing
import { Test } from "forge-std/Test.sol";
import { Vm } from "forge-std/Vm.sol";
import { DisputeGameFactory_Init } from "test/dispute/DisputeGameFactory.t.sol";
import { DisputeGameFactory } from "src/dispute/DisputeGameFactory.sol";
import { FaultDisputeGame, IDisputeGame } from "src/dispute/FaultDisputeGame.sol";
import { DelayedWETH } from "src/dispute/DelayedWETH.sol";
import { AlphabetVM } from "test/mocks/AlphabetVM.sol";
// Contracts
import { PreimageOracle } from "src/cannon/PreimageOracle.sol";
import { FaultDisputeGame } from "src/dispute/FaultDisputeGame.sol";
import { DisputeActor, HonestDisputeActor } from "test/actors/FaultDisputeActors.sol";
import "src/dispute/lib/Types.sol";
import "src/dispute/lib/Errors.sol";
// Libraries
import { Types } from "src/libraries/Types.sol";
import { Hashing } from "src/libraries/Hashing.sol";
import { RLPWriter } from "src/libraries/rlp/RLPWriter.sol";
import { LibClock } from "src/dispute/lib/LibUDT.sol";
import { LibPosition } from "src/dispute/lib/LibPosition.sol";
import "src/dispute/lib/Types.sol";
import "src/dispute/lib/Errors.sol";
// Interfaces
import { IDisputeGame } from "src/dispute/interfaces/IDisputeGame.sol";
import { IPreimageOracle } from "src/dispute/interfaces/IBigStepper.sol";
import { IAnchorStateRegistry } from "src/dispute/interfaces/IAnchorStateRegistry.sol";
import { AlphabetVM } from "test/mocks/AlphabetVM.sol";
import { DisputeActor, HonestDisputeActor } from "test/actors/FaultDisputeActors.sol";
import { IFaultDisputeGame } from "src/dispute/interfaces/IFaultDisputeGame.sol";
import { IDelayedWETH } from "src/dispute/interfaces/IDelayedWETH.sol";
contract FaultDisputeGame_Init is DisputeGameFactory_Init {
/// @dev The type of the game being tested.
GameType internal constant GAME_TYPE = GameType.wrap(0);
/// @dev The implementation of the game.
FaultDisputeGame internal gameImpl;
IFaultDisputeGame internal gameImpl;
/// @dev The `Clone` proxy of the game.
FaultDisputeGame internal gameProxy;
IFaultDisputeGame internal gameProxy;
/// @dev The extra data passed to the game for initialization.
bytes internal extraData;
......@@ -51,23 +57,27 @@ contract FaultDisputeGame_Init is DisputeGameFactory_Init {
AlphabetVM _vm = new AlphabetVM(absolutePrestate, oracle);
// Deploy an implementation of the fault game
gameImpl = new FaultDisputeGame({
_gameType: GAME_TYPE,
_absolutePrestate: absolutePrestate,
_maxGameDepth: 2 ** 3,
_splitDepth: 2 ** 2,
_clockExtension: Duration.wrap(3 hours),
_maxClockDuration: Duration.wrap(3.5 days),
_vm: _vm,
_weth: delayedWeth,
_anchorStateRegistry: anchorStateRegistry,
_l2ChainId: 10
});
gameImpl = IFaultDisputeGame(
address(
new FaultDisputeGame({
_gameType: GAME_TYPE,
_absolutePrestate: absolutePrestate,
_maxGameDepth: 2 ** 3,
_splitDepth: 2 ** 2,
_clockExtension: Duration.wrap(3 hours),
_maxClockDuration: Duration.wrap(3.5 days),
_vm: _vm,
_weth: delayedWeth,
_anchorStateRegistry: anchorStateRegistry,
_l2ChainId: 10
})
)
);
// Register the game implementation with the factory.
disputeGameFactory.setImplementation(GAME_TYPE, gameImpl);
// Create a new game.
gameProxy = FaultDisputeGame(payable(address(disputeGameFactory.create(GAME_TYPE, rootClaim, extraData))));
gameProxy = IFaultDisputeGame(payable(address(disputeGameFactory.create(GAME_TYPE, rootClaim, extraData))));
// Check immutables
assertEq(gameProxy.gameType().raw(), GAME_TYPE.raw());
......@@ -125,7 +135,7 @@ contract FaultDisputeGame_Test is FaultDisputeGame_Init {
_clockExtension: Duration.wrap(3 hours),
_maxClockDuration: Duration.wrap(3.5 days),
_vm: alphabetVM,
_weth: DelayedWETH(payable(address(0))),
_weth: IDelayedWETH(payable(address(0))),
_anchorStateRegistry: IAnchorStateRegistry(address(0)),
_l2ChainId: 10
});
......@@ -156,7 +166,7 @@ contract FaultDisputeGame_Test is FaultDisputeGame_Init {
_clockExtension: Duration.wrap(3 hours),
_maxClockDuration: Duration.wrap(3.5 days),
_vm: alphabetVM,
_weth: DelayedWETH(payable(address(0))),
_weth: IDelayedWETH(payable(address(0))),
_anchorStateRegistry: IAnchorStateRegistry(address(0)),
_l2ChainId: 10
});
......@@ -178,7 +188,7 @@ contract FaultDisputeGame_Test is FaultDisputeGame_Init {
_clockExtension: Duration.wrap(3 hours),
_maxClockDuration: Duration.wrap(3.5 days),
_vm: alphabetVM,
_weth: DelayedWETH(payable(address(0))),
_weth: IDelayedWETH(payable(address(0))),
_anchorStateRegistry: IAnchorStateRegistry(address(0)),
_l2ChainId: 10
});
......@@ -200,7 +210,7 @@ contract FaultDisputeGame_Test is FaultDisputeGame_Init {
_clockExtension: Duration.wrap(3 hours),
_maxClockDuration: Duration.wrap(3.5 days),
_vm: alphabetVM,
_weth: DelayedWETH(payable(address(0))),
_weth: IDelayedWETH(payable(address(0))),
_anchorStateRegistry: IAnchorStateRegistry(address(0)),
_l2ChainId: 10
});
......@@ -230,7 +240,7 @@ contract FaultDisputeGame_Test is FaultDisputeGame_Init {
_clockExtension: Duration.wrap(_clockExtension),
_maxClockDuration: Duration.wrap(_maxClockDuration),
_vm: alphabetVM,
_weth: DelayedWETH(payable(address(0))),
_weth: IDelayedWETH(payable(address(0))),
_anchorStateRegistry: IAnchorStateRegistry(address(0)),
_l2ChainId: 10
});
......@@ -278,7 +288,7 @@ contract FaultDisputeGame_Test is FaultDisputeGame_Init {
Claim claim = _dummyClaim();
vm.expectRevert(abi.encodeWithSelector(UnexpectedRootClaim.selector, claim));
gameProxy =
FaultDisputeGame(payable(address(disputeGameFactory.create(GAME_TYPE, claim, abi.encode(_blockNumber)))));
IFaultDisputeGame(payable(address(disputeGameFactory.create(GAME_TYPE, claim, abi.encode(_blockNumber)))));
}
/// @dev Tests that the proxy receives ETH from the dispute game factory.
......@@ -287,7 +297,7 @@ contract FaultDisputeGame_Test is FaultDisputeGame_Init {
vm.deal(address(this), _value);
assertEq(address(gameProxy).balance, 0);
gameProxy = FaultDisputeGame(
gameProxy = IFaultDisputeGame(
payable(address(disputeGameFactory.create{ value: _value }(GAME_TYPE, ROOT_CLAIM, abi.encode(1))))
);
assertEq(address(gameProxy).balance, 0);
......@@ -315,7 +325,7 @@ contract FaultDisputeGame_Test is FaultDisputeGame_Init {
Claim claim = _dummyClaim();
vm.expectRevert(abi.encodeWithSelector(BadExtraData.selector));
gameProxy = FaultDisputeGame(payable(address(disputeGameFactory.create(GAME_TYPE, claim, _extraData))));
gameProxy = IFaultDisputeGame(payable(address(disputeGameFactory.create(GAME_TYPE, claim, _extraData))));
}
/// @dev Tests that the game is initialized with the correct data.
......@@ -2568,10 +2578,10 @@ contract FaultDispute_1v1_Actors_Test is FaultDisputeGame_Init {
contract ClaimCreditReenter {
Vm internal immutable vm;
FaultDisputeGame internal immutable GAME;
IFaultDisputeGame internal immutable GAME;
uint256 public numCalls;
constructor(FaultDisputeGame _gameProxy, Vm _vm) {
constructor(IFaultDisputeGame _gameProxy, Vm _vm) {
GAME = _gameProxy;
vm = _vm;
}
......
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.15;
// Testing
import { Test } from "forge-std/Test.sol";
import { Vm } from "forge-std/Vm.sol";
import { DisputeGameFactory_Init } from "test/dispute/DisputeGameFactory.t.sol";
import { DisputeGameFactory } from "src/dispute/DisputeGameFactory.sol";
import { AlphabetVM } from "test/mocks/AlphabetVM.sol";
// Contracts
import { PermissionedDisputeGame } from "src/dispute/PermissionedDisputeGame.sol";
import { DelayedWETH } from "src/dispute/DelayedWETH.sol";
import { PreimageOracle } from "src/cannon/PreimageOracle.sol";
import { PreimageKeyLib } from "src/cannon/PreimageKeyLib.sol";
import { DelayedWETH } from "src/dispute/DelayedWETH.sol";
// Libraries
import { Types } from "src/libraries/Types.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";
import { IBigStepper, IPreimageOracle } from "src/dispute/interfaces/IBigStepper.sol";
import { AlphabetVM } from "test/mocks/AlphabetVM.sol";
import { DisputeActor, HonestDisputeActor } from "test/actors/FaultDisputeActors.sol";
// Interfaces
import { IBigStepper, IPreimageOracle } from "src/dispute/interfaces/IBigStepper.sol";
import { IDelayedWETH } from "src/dispute/interfaces/IDelayedWETH.sol";
import { IPermissionedDisputeGame } from "src/dispute/interfaces/IPermissionedDisputeGame.sol";
contract PermissionedDisputeGame_Init is DisputeGameFactory_Init {
/// @dev The type of the game being tested.
......@@ -29,9 +31,9 @@ contract PermissionedDisputeGame_Init is DisputeGameFactory_Init {
address internal constant CHALLENGER = address(0xfacadec);
/// @dev The implementation of the game.
PermissionedDisputeGame internal gameImpl;
IPermissionedDisputeGame internal gameImpl;
/// @dev The `Clone` proxy of the game.
PermissionedDisputeGame internal gameProxy;
IPermissionedDisputeGame internal gameProxy;
/// @dev The extra data passed to the game for initialization.
bytes internal extraData;
......@@ -48,29 +50,33 @@ contract PermissionedDisputeGame_Init is DisputeGameFactory_Init {
AlphabetVM _vm = new AlphabetVM(absolutePrestate, new PreimageOracle(0, 0));
// Use a 7 day delayed WETH to simulate withdrawals.
DelayedWETH _weth = new DelayedWETH(7 days);
IDelayedWETH _weth = IDelayedWETH(payable(new DelayedWETH(7 days)));
// Deploy an implementation of the fault game
gameImpl = new PermissionedDisputeGame({
_gameType: GAME_TYPE,
_absolutePrestate: absolutePrestate,
_maxGameDepth: 2 ** 3,
_splitDepth: 2 ** 2,
_clockExtension: Duration.wrap(3 hours),
_maxClockDuration: Duration.wrap(3.5 days),
_vm: _vm,
_weth: _weth,
_anchorStateRegistry: anchorStateRegistry,
_l2ChainId: 10,
_proposer: PROPOSER,
_challenger: CHALLENGER
});
gameImpl = IPermissionedDisputeGame(
address(
new PermissionedDisputeGame({
_gameType: GAME_TYPE,
_absolutePrestate: absolutePrestate,
_maxGameDepth: 2 ** 3,
_splitDepth: 2 ** 2,
_clockExtension: Duration.wrap(3 hours),
_maxClockDuration: Duration.wrap(3.5 days),
_vm: _vm,
_weth: _weth,
_anchorStateRegistry: anchorStateRegistry,
_l2ChainId: 10,
_proposer: PROPOSER,
_challenger: CHALLENGER
})
)
);
// Register the game implementation with the factory.
disputeGameFactory.setImplementation(GAME_TYPE, gameImpl);
// Create a new game.
vm.prank(PROPOSER, PROPOSER);
gameProxy =
PermissionedDisputeGame(payable(address(disputeGameFactory.create(GAME_TYPE, rootClaim, extraData))));
IPermissionedDisputeGame(payable(address(disputeGameFactory.create(GAME_TYPE, rootClaim, extraData))));
// Check immutables
assertEq(gameProxy.proposer(), PROPOSER);
......
// SPDX-License-Identifier: MIT
pragma solidity 0.8.15;
// Testing
import { Vm } from "forge-std/Vm.sol";
import { StdUtils } from "forge-std/StdUtils.sol";
import { FaultDisputeGame } from "src/dispute/FaultDisputeGame.sol";
import { FaultDisputeGame_Init } from "test/dispute/FaultDisputeGame.t.sol";
// Libraries
import "src/dispute/lib/Types.sol";
import "src/dispute/lib/Errors.sol";
// Interfaces
import { IFaultDisputeGame } from "src/dispute/interfaces/IFaultDisputeGame.sol";
contract FaultDisputeGame_Solvency_Invariant is FaultDisputeGame_Init {
Claim internal constant ROOT_CLAIM = Claim.wrap(bytes32(uint256(10)));
Claim internal constant ABSOLUTE_PRESTATE = Claim.wrap(bytes32((uint256(3) << 248) | uint256(0)));
......@@ -73,12 +77,12 @@ contract FaultDisputeGame_Solvency_Invariant is FaultDisputeGame_Init {
}
contract RandomClaimActor is StdUtils {
FaultDisputeGame internal immutable GAME;
IFaultDisputeGame internal immutable GAME;
Vm internal immutable VM;
uint256 public totalBonded;
constructor(FaultDisputeGame _gameProxy, Vm _vm) {
constructor(IFaultDisputeGame _gameProxy, Vm _vm) {
GAME = _gameProxy;
VM = _vm;
}
......
// SPDX-License-Identifier: MIT
pragma solidity 0.8.15;
// Testing
import { StdUtils } from "forge-std/Test.sol";
import { Vm } from "forge-std/Vm.sol";
import { CommonTest } from "test/setup/CommonTest.sol";
import { EIP1967Helper } from "test/mocks/EIP1967Helper.sol";
import { IOptimismPortal2 } from "src/L1/interfaces/IOptimismPortal2.sol";
import { AddressAliasHelper } from "src/vendor/AddressAliasHelper.sol";
// Contracts
import { ResourceMetering } from "src/L1/ResourceMetering.sol";
import { IResourceMetering } from "src/L1/interfaces/IResourceMetering.sol";
import { Constants } from "src/libraries/Constants.sol";
import { CommonTest } from "test/setup/CommonTest.sol";
import { EIP1967Helper } from "test/mocks/EIP1967Helper.sol";
// Libraries
import { Constants } from "src/libraries/Constants.sol";
import { Types } from "src/libraries/Types.sol";
import { FaultDisputeGame } from "src/dispute/FaultDisputeGame.sol";
import "src/dispute/lib/Types.sol";
import "src/libraries/PortalErrors.sol";
// Interfaces
import { IOptimismPortal2 } from "src/L1/interfaces/IOptimismPortal2.sol";
import { IResourceMetering } from "src/L1/interfaces/IResourceMetering.sol";
import { IFaultDisputeGame } from "src/dispute/interfaces/IFaultDisputeGame.sol";
contract OptimismPortal2_Depositor is StdUtils, ResourceMetering {
Vm internal vm;
IOptimismPortal2 internal portal;
......@@ -118,7 +121,7 @@ contract OptimismPortal2_Invariant_Harness is CommonTest {
// Create a dispute game with the output root we've proposed.
_proposedBlockNumber = 0xFF;
FaultDisputeGame game = FaultDisputeGame(
IFaultDisputeGame game = IFaultDisputeGame(
payable(
address(
disputeGameFactory.create(
......
// SPDX-License-Identifier: MIT
pragma solidity 0.8.15;
// Testing
import { CommonTest } from "test/setup/CommonTest.sol";
import { ForgeArtifacts, Abi } from "scripts/libraries/ForgeArtifacts.sol";
import { GnosisSafe as Safe } from "safe-contracts/GnosisSafe.sol";
import "test/safe-tools/SafeTestTools.sol";
import { IDisputeGame } from "src/dispute/interfaces/IDisputeGame.sol";
import { IFaultDisputeGame } from "src/dispute/interfaces/IFaultDisputeGame.sol";
import { AnchorStateRegistry } from "src/dispute/AnchorStateRegistry.sol";
// Contracts
import { DeputyGuardianModule } from "src/safe/DeputyGuardianModule.sol";
// Libraries
import "src/dispute/lib/Types.sol";
// Interfaces
import { IDisputeGame } from "src/dispute/interfaces/IDisputeGame.sol";
import { IFaultDisputeGame } from "src/dispute/interfaces/IFaultDisputeGame.sol";
import { IAnchorStateRegistry } from "src/dispute/interfaces/IAnchorStateRegistry.sol";
contract DeputyGuardianModule_TestInit is CommonTest, SafeTestTools {
using SafeTestLib for SafeInstance;
......@@ -152,13 +157,13 @@ contract DeputyGuardianModule_Unpause_TestFail is DeputyGuardianModule_Unpause_T
contract DeputyGuardianModule_SetAnchorState_TestFail is DeputyGuardianModule_TestInit {
function test_setAnchorState_notDeputyGuardian_reverts() external {
AnchorStateRegistry asr = AnchorStateRegistry(makeAddr("asr"));
IAnchorStateRegistry asr = IAnchorStateRegistry(makeAddr("asr"));
vm.expectRevert(abi.encodeWithSelector(Unauthorized.selector));
deputyGuardianModule.setAnchorState(asr, IFaultDisputeGame(address(0)));
}
function test_setAnchorState_targetReverts_reverts() external {
AnchorStateRegistry asr = AnchorStateRegistry(makeAddr("asr"));
IAnchorStateRegistry asr = IAnchorStateRegistry(makeAddr("asr"));
vm.mockCallRevert(
address(asr),
abi.encodeWithSelector(asr.setAnchorState.selector),
......@@ -174,10 +179,10 @@ contract DeputyGuardianModule_SetAnchorState_TestFail is DeputyGuardianModule_Te
contract DeputyGuardianModule_SetAnchorState_Test is DeputyGuardianModule_TestInit {
function test_setAnchorState_succeeds() external {
AnchorStateRegistry asr = AnchorStateRegistry(makeAddr("asr"));
IAnchorStateRegistry asr = IAnchorStateRegistry(makeAddr("asr"));
vm.mockCall(
address(asr),
abi.encodeWithSelector(AnchorStateRegistry.setAnchorState.selector, IFaultDisputeGame(address(0))),
abi.encodeWithSelector(IAnchorStateRegistry.setAnchorState.selector, IFaultDisputeGame(address(0))),
""
);
vm.expectEmit(address(safeInstance.safe));
......
......@@ -13,11 +13,6 @@ import { L2Genesis, L1Dependencies } from "scripts/L2Genesis.s.sol";
import { OutputMode, Fork, ForkUtils } from "scripts/libraries/Config.sol";
import { Executables } from "scripts/libraries/Executables.sol";
// Contracts
import { DisputeGameFactory } from "src/dispute/DisputeGameFactory.sol";
import { DelayedWETH } from "src/dispute/DelayedWETH.sol";
import { AnchorStateRegistry } from "src/dispute/AnchorStateRegistry.sol";
// Libraries
import { Predeploys } from "src/libraries/Predeploys.sol";
import { Preinstalls } from "src/libraries/Preinstalls.sol";
......@@ -34,6 +29,9 @@ import { IDataAvailabilityChallenge } from "src/L1/interfaces/IDataAvailabilityC
import { IL1StandardBridge } from "src/L1/interfaces/IL1StandardBridge.sol";
import { IProtocolVersions } from "src/L1/interfaces/IProtocolVersions.sol";
import { IL1ERC721Bridge } from "src/L1/interfaces/IL1ERC721Bridge.sol";
import { IDisputeGameFactory } from "src/dispute/interfaces/IDisputeGameFactory.sol";
import { IDelayedWETH } from "src/dispute/interfaces/IDelayedWETH.sol";
import { IAnchorStateRegistry } from "src/dispute/interfaces/IAnchorStateRegistry.sol";
import { IL2CrossDomainMessenger } from "src/L2/interfaces/IL2CrossDomainMessenger.sol";
import { IL2StandardBridgeInterop } from "src/L2/interfaces/IL2StandardBridgeInterop.sol";
import { IL2ToL1MessagePasser } from "src/L2/interfaces/IL2ToL1MessagePasser.sol";
......@@ -74,9 +72,9 @@ contract Setup {
Fork l2Fork = LATEST_FORK;
// L1 contracts
DisputeGameFactory disputeGameFactory;
AnchorStateRegistry anchorStateRegistry;
DelayedWETH delayedWeth;
IDisputeGameFactory disputeGameFactory;
IAnchorStateRegistry anchorStateRegistry;
IDelayedWETH delayedWeth;
IOptimismPortal optimismPortal;
IOptimismPortal2 optimismPortal2;
IL2OutputOracle l2OutputOracle;
......@@ -147,8 +145,8 @@ contract Setup {
optimismPortal = IOptimismPortal(deploy.mustGetAddress("OptimismPortalProxy"));
optimismPortal2 = IOptimismPortal2(deploy.mustGetAddress("OptimismPortalProxy"));
disputeGameFactory = DisputeGameFactory(deploy.mustGetAddress("DisputeGameFactoryProxy"));
delayedWeth = DelayedWETH(deploy.mustGetAddress("DelayedWETHProxy"));
disputeGameFactory = IDisputeGameFactory(deploy.mustGetAddress("DisputeGameFactoryProxy"));
delayedWeth = IDelayedWETH(deploy.mustGetAddress("DelayedWETHProxy"));
l2OutputOracle = IL2OutputOracle(deploy.mustGetAddress("L2OutputOracleProxy"));
systemConfig = ISystemConfig(deploy.mustGetAddress("SystemConfigProxy"));
l1StandardBridge = IL1StandardBridge(deploy.mustGetAddress("L1StandardBridgeProxy"));
......@@ -159,7 +157,7 @@ contract Setup {
IOptimismMintableERC20Factory(deploy.mustGetAddress("OptimismMintableERC20FactoryProxy"));
protocolVersions = IProtocolVersions(deploy.mustGetAddress("ProtocolVersionsProxy"));
superchainConfig = ISuperchainConfig(deploy.mustGetAddress("SuperchainConfigProxy"));
anchorStateRegistry = AnchorStateRegistry(deploy.mustGetAddress("AnchorStateRegistryProxy"));
anchorStateRegistry = IAnchorStateRegistry(deploy.mustGetAddress("AnchorStateRegistryProxy"));
vm.label(address(l2OutputOracle), "L2OutputOracle");
vm.label(deploy.mustGetAddress("L2OutputOracleProxy"), "L2OutputOracleProxy");
......
......@@ -9,11 +9,6 @@ import { Executables } from "scripts/libraries/Executables.sol";
import { ForgeArtifacts, StorageSlot } from "scripts/libraries/ForgeArtifacts.sol";
import { Process } from "scripts/libraries/Process.sol";
// Contracts
import { AnchorStateRegistry } from "src/dispute/AnchorStateRegistry.sol";
import { FaultDisputeGame } from "src/dispute/FaultDisputeGame.sol";
import { PermissionedDisputeGame } from "src/dispute/PermissionedDisputeGame.sol";
// Libraries
import { LibString } from "@solady/utils/LibString.sol";
import { Constants } from "src/libraries/Constants.sol";
......@@ -26,6 +21,7 @@ import { ISystemConfig } from "src/L1/interfaces/ISystemConfig.sol";
import { IResourceMetering } from "src/L1/interfaces/IResourceMetering.sol";
import { ISuperchainConfig } from "src/L1/interfaces/ISuperchainConfig.sol";
import { ProtocolVersion } from "src/L1/interfaces/IProtocolVersions.sol";
import { IAnchorStateRegistry } from "src/dispute/interfaces/IAnchorStateRegistry.sol";
/// @title Initializer_Test
/// @dev Ensures that the `initialize()` function on contracts cannot be called more than
......@@ -372,7 +368,7 @@ contract Initializer_Test is Bridge_Initializer {
target: address(anchorStateRegistry),
initCalldata: abi.encodeCall(
anchorStateRegistry.initialize,
(new AnchorStateRegistry.StartingAnchorRoot[](1), ISuperchainConfig(address(0)))
(new IAnchorStateRegistry.StartingAnchorRoot[](1), ISuperchainConfig(address(0)))
)
})
);
......@@ -383,7 +379,7 @@ contract Initializer_Test is Bridge_Initializer {
target: address(anchorStateRegistry),
initCalldata: abi.encodeCall(
anchorStateRegistry.initialize,
(new AnchorStateRegistry.StartingAnchorRoot[](1), ISuperchainConfig(address(0)))
(new IAnchorStateRegistry.StartingAnchorRoot[](1), ISuperchainConfig(address(0)))
)
})
);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment