diff --git a/packages/contracts-bedrock/.gas-snapshot b/packages/contracts-bedrock/.gas-snapshot index b28d6b6c9cad..af4acca99719 100644 --- a/packages/contracts-bedrock/.gas-snapshot +++ b/packages/contracts-bedrock/.gas-snapshot @@ -4,14 +4,14 @@ GasBenchMark_L1BlockIsthmus_SetValuesIsthmus:test_setL1BlockValuesIsthmus_benchm GasBenchMark_L1BlockIsthmus_SetValuesIsthmus_Warm:test_setL1BlockValuesIsthmus_benchmark() (gas: 5121) GasBenchMark_L1Block_SetValuesEcotone:test_setL1BlockValuesEcotone_benchmark() (gas: 158531) GasBenchMark_L1Block_SetValuesEcotone_Warm:test_setL1BlockValuesEcotone_benchmark() (gas: 7597) -GasBenchMark_L1CrossDomainMessenger:test_sendMessage_benchmark_0() (gas: 369356) -GasBenchMark_L1CrossDomainMessenger:test_sendMessage_benchmark_1() (gas: 2967496) -GasBenchMark_L1StandardBridge_Deposit:test_depositERC20_benchmark_0() (gas: 564483) -GasBenchMark_L1StandardBridge_Deposit:test_depositERC20_benchmark_1() (gas: 4076526) -GasBenchMark_L1StandardBridge_Deposit:test_depositETH_benchmark_0() (gas: 466947) -GasBenchMark_L1StandardBridge_Deposit:test_depositETH_benchmark_1() (gas: 3512629) +GasBenchMark_L1CrossDomainMessenger:test_sendMessage_benchmark_0() (gas: 369242) +GasBenchMark_L1CrossDomainMessenger:test_sendMessage_benchmark_1() (gas: 2967382) +GasBenchMark_L1StandardBridge_Deposit:test_depositERC20_benchmark_0() (gas: 564365) +GasBenchMark_L1StandardBridge_Deposit:test_depositERC20_benchmark_1() (gas: 4076580) +GasBenchMark_L1StandardBridge_Deposit:test_depositETH_benchmark_0() (gas: 467007) +GasBenchMark_L1StandardBridge_Deposit:test_depositETH_benchmark_1() (gas: 3512689) GasBenchMark_L1StandardBridge_Finalize:test_finalizeETHWithdrawal_benchmark() (gas: 72624) GasBenchMark_L2OutputOracle:test_proposeL2Output_benchmark() (gas: 92973) -GasBenchMark_OptimismPortal:test_depositTransaction_benchmark() (gas: 68433) -GasBenchMark_OptimismPortal:test_depositTransaction_benchmark_1() (gas: 68903) +GasBenchMark_OptimismPortal:test_depositTransaction_benchmark() (gas: 68320) +GasBenchMark_OptimismPortal:test_depositTransaction_benchmark_1() (gas: 68962) GasBenchMark_OptimismPortal:test_proveWithdrawalTransaction_benchmark() (gas: 155618) \ No newline at end of file diff --git a/packages/contracts-bedrock/invariant-docs/OptimismPortal.md b/packages/contracts-bedrock/invariant-docs/OptimismPortal.md index c13d0212128d..b1b2c38cb278 100644 --- a/packages/contracts-bedrock/invariant-docs/OptimismPortal.md +++ b/packages/contracts-bedrock/invariant-docs/OptimismPortal.md @@ -1,21 +1,21 @@ # `OptimismPortal` Invariants ## Deposits of any value should always succeed unless `_to` = `address(0)` or `_isCreation` = `true`. -**Test:** [`OptimismPortal.t.sol#L148`](../test/invariants/OptimismPortal.t.sol#L148) +**Test:** [`OptimismPortal.t.sol#L151`](../test/invariants/OptimismPortal.t.sol#L151) All deposits, barring creation transactions and transactions sent to `address(0)`, should always succeed. ## `finalizeWithdrawalTransaction` should revert if the finalization period has not elapsed. -**Test:** [`OptimismPortal.t.sol#L171`](../test/invariants/OptimismPortal.t.sol#L171) +**Test:** [`OptimismPortal.t.sol#L174`](../test/invariants/OptimismPortal.t.sol#L174) A withdrawal that has been proven should not be able to be finalized until after the finalization period has elapsed. ## `finalizeWithdrawalTransaction` should revert if the withdrawal has already been finalized. -**Test:** [`OptimismPortal.t.sol#L201`](../test/invariants/OptimismPortal.t.sol#L201) +**Test:** [`OptimismPortal.t.sol#L204`](../test/invariants/OptimismPortal.t.sol#L204) Ensures that there is no chain of calls that can be made that allows a withdrawal to be finalized twice. ## A withdrawal should **always** be able to be finalized `FINALIZATION_PERIOD_SECONDS` after it was successfully proven. -**Test:** [`OptimismPortal.t.sol#L230`](../test/invariants/OptimismPortal.t.sol#L230) +**Test:** [`OptimismPortal.t.sol#L233`](../test/invariants/OptimismPortal.t.sol#L233) This invariant asserts that there is no chain of calls that can be made that will prevent a withdrawal from being finalized exactly `FINALIZATION_PERIOD_SECONDS` after it was successfully proven. \ No newline at end of file diff --git a/packages/contracts-bedrock/invariant-docs/OptimismPortal2.md b/packages/contracts-bedrock/invariant-docs/OptimismPortal2.md index c9a00ec0941e..b3c1eb0d4576 100644 --- a/packages/contracts-bedrock/invariant-docs/OptimismPortal2.md +++ b/packages/contracts-bedrock/invariant-docs/OptimismPortal2.md @@ -1,21 +1,21 @@ # `OptimismPortal2` Invariants ## Deposits of any value should always succeed unless `_to` = `address(0)` or `_isCreation` = `true`. -**Test:** [`OptimismPortal2.t.sol#L161`](../test/invariants/OptimismPortal2.t.sol#L161) +**Test:** [`OptimismPortal2.t.sol#L163`](../test/invariants/OptimismPortal2.t.sol#L163) All deposits, barring creation transactions and transactions sent to `address(0)`, should always succeed. ## `finalizeWithdrawalTransaction` should revert if the proof maturity period has not elapsed. -**Test:** [`OptimismPortal2.t.sol#L183`](../test/invariants/OptimismPortal2.t.sol#L183) +**Test:** [`OptimismPortal2.t.sol#L185`](../test/invariants/OptimismPortal2.t.sol#L185) A withdrawal that has been proven should not be able to be finalized until after the proof maturity period has elapsed. ## `finalizeWithdrawalTransaction` should revert if the withdrawal has already been finalized. -**Test:** [`OptimismPortal2.t.sol#L212`](../test/invariants/OptimismPortal2.t.sol#L212) +**Test:** [`OptimismPortal2.t.sol#L214`](../test/invariants/OptimismPortal2.t.sol#L214) Ensures that there is no chain of calls that can be made that allows a withdrawal to be finalized twice. ## A withdrawal should **always** be able to be finalized `PROOF_MATURITY_DELAY_SECONDS` after it was successfully proven, if the game has resolved and passed the air-gap. -**Test:** [`OptimismPortal2.t.sol#L240`](../test/invariants/OptimismPortal2.t.sol#L240) +**Test:** [`OptimismPortal2.t.sol#L242`](../test/invariants/OptimismPortal2.t.sol#L242) This invariant asserts that there is no chain of calls that can be made that will prevent a withdrawal from being finalized exactly `PROOF_MATURITY_DELAY_SECONDS` after it was successfully proven and the game has resolved and passed the air-gap. \ No newline at end of file diff --git a/packages/contracts-bedrock/invariant-docs/ResourceMetering.md b/packages/contracts-bedrock/invariant-docs/ResourceMetering.md index 967c24bf886f..2f97937d2b84 100644 --- a/packages/contracts-bedrock/invariant-docs/ResourceMetering.md +++ b/packages/contracts-bedrock/invariant-docs/ResourceMetering.md @@ -1,36 +1,36 @@ # `ResourceMetering` Invariants ## The base fee should increase if the last block used more than the target amount of gas. -**Test:** [`ResourceMetering.t.sol#L163`](../test/invariants/ResourceMetering.t.sol#L163) +**Test:** [`ResourceMetering.t.sol#L166`](../test/invariants/ResourceMetering.t.sol#L166) If the last block used more than the target amount of gas (and there were no empty blocks in between), ensure this block's baseFee increased, but not by more than the max amount per block. ## The base fee should decrease if the last block used less than the target amount of gas. -**Test:** [`ResourceMetering.t.sol#L172`](../test/invariants/ResourceMetering.t.sol#L172) +**Test:** [`ResourceMetering.t.sol#L175`](../test/invariants/ResourceMetering.t.sol#L175) If the previous block used less than the target amount of gas, the base fee should decrease, but not more than the max amount. ## A block's base fee should never be below `MINIMUM_BASE_FEE`. -**Test:** [`ResourceMetering.t.sol#L180`](../test/invariants/ResourceMetering.t.sol#L180) +**Test:** [`ResourceMetering.t.sol#L183`](../test/invariants/ResourceMetering.t.sol#L183) This test asserts that a block's base fee can never drop below the `MINIMUM_BASE_FEE` threshold. ## A block can never consume more than `MAX_RESOURCE_LIMIT` gas. -**Test:** [`ResourceMetering.t.sol#L188`](../test/invariants/ResourceMetering.t.sol#L188) +**Test:** [`ResourceMetering.t.sol#L191`](../test/invariants/ResourceMetering.t.sol#L191) This test asserts that a block can never consume more than the `MAX_RESOURCE_LIMIT` gas threshold. ## The base fee can never be raised more than the max base fee change. -**Test:** [`ResourceMetering.t.sol#L198`](../test/invariants/ResourceMetering.t.sol#L198) +**Test:** [`ResourceMetering.t.sol#L201`](../test/invariants/ResourceMetering.t.sol#L201) After a block consumes more gas than the target gas, the base fee cannot be raised more than the maximum amount allowed. The max base fee change (per-block) is derived as follows: `prevBaseFee / BASE_FEE_MAX_CHANGE_DENOMINATOR` ## The base fee can never be lowered more than the max base fee change. -**Test:** [`ResourceMetering.t.sol#L208`](../test/invariants/ResourceMetering.t.sol#L208) +**Test:** [`ResourceMetering.t.sol#L211`](../test/invariants/ResourceMetering.t.sol#L211) After a block consumes less than the target gas, the base fee cannot be lowered more than the maximum amount allowed. The max base fee change (per-block) is derived as follows: `prevBaseFee / BASE_FEE_MAX_CHANGE_DENOMINATOR` ## The `maxBaseFeeChange` calculation over multiple blocks can never underflow. -**Test:** [`ResourceMetering.t.sol#L217`](../test/invariants/ResourceMetering.t.sol#L217) +**Test:** [`ResourceMetering.t.sol#L220`](../test/invariants/ResourceMetering.t.sol#L220) When calculating the `maxBaseFeeChange` after multiple empty blocks, the calculation should never be allowed to underflow. \ No newline at end of file diff --git a/packages/contracts-bedrock/invariant-docs/SystemConfig.md b/packages/contracts-bedrock/invariant-docs/SystemConfig.md index 59f9a999f10c..b3d711972f6b 100644 --- a/packages/contracts-bedrock/invariant-docs/SystemConfig.md +++ b/packages/contracts-bedrock/invariant-docs/SystemConfig.md @@ -1,6 +1,6 @@ # `SystemConfig` Invariants ## Gas limit boundaries -**Test:** [`SystemConfig.t.sol#L70`](../test/invariants/SystemConfig.t.sol#L70) +**Test:** [`SystemConfig.t.sol#L71`](../test/invariants/SystemConfig.t.sol#L71) The gas limit of the `SystemConfig` contract can never be lower than the hard-coded lower bound or higher than the hard-coded upper bound. The lower bound must never be higher than the upper bound. \ No newline at end of file diff --git a/packages/contracts-bedrock/scripts/L2Genesis.s.sol b/packages/contracts-bedrock/scripts/L2Genesis.s.sol index eb2f8d396365..e6040f4eec2f 100644 --- a/packages/contracts-bedrock/scripts/L2Genesis.s.sol +++ b/packages/contracts-bedrock/scripts/L2Genesis.s.sol @@ -21,7 +21,7 @@ import { OptimismMintableERC721Factory } from "src/universal/OptimismMintableERC import { BaseFeeVault } from "src/L2/BaseFeeVault.sol"; import { L1FeeVault } from "src/L2/L1FeeVault.sol"; import { GovernanceToken } from "src/governance/GovernanceToken.sol"; -import { L1CrossDomainMessenger } from "src/L1/L1CrossDomainMessenger.sol"; +import { CrossDomainMessenger } from "src/universal/CrossDomainMessenger.sol"; import { L1StandardBridge } from "src/L1/L1StandardBridge.sol"; import { FeeVault } from "src/universal/FeeVault.sol"; import { EIP1967Helper } from "test/mocks/EIP1967Helper.sol"; @@ -277,10 +277,10 @@ contract L2Genesis is Deployer { function setL2CrossDomainMessenger(address payable _l1CrossDomainMessengerProxy) public { address impl = _setImplementationCode(Predeploys.L2_CROSS_DOMAIN_MESSENGER); - L2CrossDomainMessenger(impl).initialize({ _l1CrossDomainMessenger: L1CrossDomainMessenger(address(0)) }); + L2CrossDomainMessenger(impl).initialize({ _l1CrossDomainMessenger: CrossDomainMessenger(address(0)) }); L2CrossDomainMessenger(Predeploys.L2_CROSS_DOMAIN_MESSENGER).initialize({ - _l1CrossDomainMessenger: L1CrossDomainMessenger(_l1CrossDomainMessengerProxy) + _l1CrossDomainMessenger: CrossDomainMessenger(_l1CrossDomainMessengerProxy) }); } diff --git a/packages/contracts-bedrock/scripts/checks/check-interfaces.sh b/packages/contracts-bedrock/scripts/checks/check-interfaces.sh index 827ae5ee4452..89a62e3c4ce0 100755 --- a/packages/contracts-bedrock/scripts/checks/check-interfaces.sh +++ b/packages/contracts-bedrock/scripts/checks/check-interfaces.sh @@ -180,8 +180,24 @@ for interface_file in $JSON_FILES; do interface_abi=$(jq '[.abi[] | select(.type != "constructor")]' < "$interface_file") contract_abi=$(jq '[.abi[] | select(.type != "constructor")]' < "$corresponding_contract_file") + # Function to normalize ABI by replacing interface name with contract name. + # Base contracts aren't allowed to inherit from their interfaces in order + # to guarantee a 1:1 match between interfaces and contracts. This means + # that the interface will redefine types in the base contract. We normalize + # the ABI as if the interface and contract are the same name + normalize_abi() { + local abi="$1" + local interface_name="$2" + local contract_name="$3" + echo "${abi//$interface_name/$contract_name}" + } + + # Normalize the ABIs + normalized_interface_abi=$(normalize_abi "$interface_abi" "$contract_name" "$contract_basename") + normalized_contract_abi="$contract_abi" + # Use jq to compare the ABIs - if ! diff_result=$(diff -u <(echo "$interface_abi" | jq -S .) <(echo "$contract_abi" | jq -S .)); then + if ! diff_result=$(diff -u <(echo "$normalized_interface_abi" | jq -S .) <(echo "$normalized_contract_abi" | jq -S .)); then if ! grep -q "^$contract_name$" "$REPORTED_INTERFACES_FILE"; then echo "$contract_name" >> "$REPORTED_INTERFACES_FILE" if ! is_excluded "$contract_name"; then diff --git a/packages/contracts-bedrock/scripts/deploy/ChainAssertions.sol b/packages/contracts-bedrock/scripts/deploy/ChainAssertions.sol index ce10bb0993f7..0ebb848f23a3 100644 --- a/packages/contracts-bedrock/scripts/deploy/ChainAssertions.sol +++ b/packages/contracts-bedrock/scripts/deploy/ChainAssertions.sol @@ -1,28 +1,37 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; -import { ProxyAdmin } from "src/universal/ProxyAdmin.sol"; -import { ResourceMetering } from "src/L1/ResourceMetering.sol"; +// Testing +import { Vm } from "forge-std/Vm.sol"; +import { console2 as console } from "forge-std/console2.sol"; + +// Scripts import { DeployConfig } from "scripts/deploy/DeployConfig.s.sol"; import { Deployer } from "scripts/deploy/Deployer.sol"; -import { SystemConfig } from "src/L1/SystemConfig.sol"; -import { Constants } from "src/libraries/Constants.sol"; + +// Contracts +import { ProxyAdmin } from "src/universal/ProxyAdmin.sol"; import { L1StandardBridge } from "src/L1/L1StandardBridge.sol"; -import { IL2OutputOracle } from "src/L1/interfaces/IL2OutputOracle.sol"; import { DisputeGameFactory } from "src/dispute/DisputeGameFactory.sol"; import { DelayedWETH } from "src/dispute/weth/DelayedWETH.sol"; import { ProtocolVersion, ProtocolVersions } from "src/L1/ProtocolVersions.sol"; -import { SuperchainConfig } from "src/L1/SuperchainConfig.sol"; -import { OptimismPortal } from "src/L1/OptimismPortal.sol"; -import { OptimismPortal2 } from "src/L1/OptimismPortal2.sol"; -import { L1CrossDomainMessenger } from "src/L1/L1CrossDomainMessenger.sol"; import { OptimismMintableERC20Factory } from "src/universal/OptimismMintableERC20Factory.sol"; import { L1ERC721Bridge } from "src/L1/L1ERC721Bridge.sol"; + +// Libraries +import { Constants } from "src/libraries/Constants.sol"; import { Predeploys } from "src/libraries/Predeploys.sol"; import { Types } from "scripts/libraries/Types.sol"; -import { Vm } from "forge-std/Vm.sol"; + +// Interfaces +import { IResourceMetering } from "src/L1/interfaces/IResourceMetering.sol"; +import { ISystemConfig } from "src/L1/interfaces/ISystemConfig.sol"; +import { IL2OutputOracle } from "src/L1/interfaces/IL2OutputOracle.sol"; +import { ISuperchainConfig } from "src/L1/interfaces/ISuperchainConfig.sol"; +import { IL1CrossDomainMessenger } from "src/L1/interfaces/IL1CrossDomainMessenger.sol"; +import { IOptimismPortal } from "src/L1/interfaces/IOptimismPortal.sol"; +import { IOptimismPortal2 } from "src/L1/interfaces/IOptimismPortal2.sol"; import { ISystemConfigV0 } from "scripts/interfaces/ISystemConfigV0.sol"; -import { console2 as console } from "forge-std/console2.sol"; library ChainAssertions { Vm internal constant vm = Vm(0x7109709ECfa91a80626fF3989D68f67F5b1DD12D); @@ -39,8 +48,8 @@ library ChainAssertions { view { console.log("Running post-deploy assertions"); - ResourceMetering.ResourceConfig memory rcfg = SystemConfig(_prox.SystemConfig).resourceConfig(); - ResourceMetering.ResourceConfig memory dflt = Constants.DEFAULT_RESOURCE_CONFIG(); + IResourceMetering.ResourceConfig memory rcfg = ISystemConfig(_prox.SystemConfig).resourceConfig(); + IResourceMetering.ResourceConfig memory dflt = Constants.DEFAULT_RESOURCE_CONFIG(); require(keccak256(abi.encode(rcfg)) == keccak256(abi.encode(dflt))); checkSystemConfig({ _contracts: _prox, _cfg: _cfg, _isProxy: true }); @@ -62,12 +71,12 @@ library ChainAssertions { /// @notice Asserts that the SystemConfig is setup correctly function checkSystemConfig(Types.ContractSet memory _contracts, DeployConfig _cfg, bool _isProxy) internal view { console.log("Running chain assertions on the SystemConfig"); - SystemConfig config = SystemConfig(_contracts.SystemConfig); + ISystemConfig config = ISystemConfig(_contracts.SystemConfig); // Check that the contract is initialized assertSlotValueIsOne({ _contractAddress: address(config), _slot: 0, _offset: 0 }); - ResourceMetering.ResourceConfig memory resourceConfig = config.resourceConfig(); + IResourceMetering.ResourceConfig memory resourceConfig = config.resourceConfig(); if (_isProxy) { require(config.owner() == _cfg.finalSystemOwner()); @@ -78,7 +87,7 @@ library ChainAssertions { require(config.unsafeBlockSigner() == _cfg.p2pSequencerAddress()); require(config.scalar() >> 248 == 1); // Check _config - ResourceMetering.ResourceConfig memory rconfig = Constants.DEFAULT_RESOURCE_CONFIG(); + IResourceMetering.ResourceConfig memory rconfig = Constants.DEFAULT_RESOURCE_CONFIG(); require(resourceConfig.maxResourceLimit == rconfig.maxResourceLimit); require(resourceConfig.elasticityMultiplier == rconfig.elasticityMultiplier); require(resourceConfig.baseFeeMaxChangeDenominator == rconfig.baseFeeMaxChangeDenominator); @@ -127,7 +136,7 @@ library ChainAssertions { /// @notice Asserts that the L1CrossDomainMessenger is setup correctly function checkL1CrossDomainMessenger(Types.ContractSet memory _contracts, Vm _vm, bool _isProxy) internal view { console.log("Running chain assertions on the L1CrossDomainMessenger"); - L1CrossDomainMessenger messenger = L1CrossDomainMessenger(_contracts.L1CrossDomainMessenger); + IL1CrossDomainMessenger messenger = IL1CrossDomainMessenger(_contracts.L1CrossDomainMessenger); // Check that the contract is initialized assertSlotValueIsOne({ _contractAddress: address(messenger), _slot: 0, _offset: 20 }); @@ -201,7 +210,7 @@ library ChainAssertions { if (_isProxy) { require(weth.owner() == _expectedOwner); require(weth.delay() == _cfg.faultGameWithdrawalDelay()); - require(weth.config() == SuperchainConfig(_contracts.SuperchainConfig)); + require(weth.config() == ISuperchainConfig(_contracts.SuperchainConfig)); } else { require(weth.owner() == _expectedOwner); require(weth.delay() == _cfg.faultGameWithdrawalDelay()); @@ -227,7 +236,7 @@ library ChainAssertions { if (_isProxy) { require(weth.owner() == _expectedOwner); require(weth.delay() == _cfg.faultGameWithdrawalDelay()); - require(weth.config() == SuperchainConfig(_contracts.SuperchainConfig)); + require(weth.config() == ISuperchainConfig(_contracts.SuperchainConfig)); } else { require(weth.owner() == _expectedOwner); require(weth.delay() == _cfg.faultGameWithdrawalDelay()); @@ -322,7 +331,7 @@ library ChainAssertions { function checkOptimismPortal(Types.ContractSet memory _contracts, DeployConfig _cfg, bool _isProxy) internal view { console.log("Running chain assertions on the OptimismPortal"); - OptimismPortal portal = OptimismPortal(payable(_contracts.OptimismPortal)); + IOptimismPortal portal = IOptimismPortal(payable(_contracts.OptimismPortal)); // Check that the contract is initialized assertSlotValueIsOne({ _contractAddress: address(portal), _slot: 0, _offset: 0 }); @@ -337,7 +346,7 @@ library ChainAssertions { require(address(portal.systemConfig()) == _contracts.SystemConfig); require(portal.guardian() == guardian); require(address(portal.superchainConfig()) == address(_contracts.SuperchainConfig)); - require(portal.paused() == SuperchainConfig(_contracts.SuperchainConfig).paused()); + require(portal.paused() == ISuperchainConfig(_contracts.SuperchainConfig).paused()); require(portal.l2Sender() == Constants.DEFAULT_L2_SENDER); } else { require(address(portal.l2Oracle()) == address(0)); @@ -358,7 +367,7 @@ library ChainAssertions { { console.log("Running chain assertions on the OptimismPortal2"); - OptimismPortal2 portal = OptimismPortal2(payable(_contracts.OptimismPortal2)); + IOptimismPortal2 portal = IOptimismPortal2(payable(_contracts.OptimismPortal2)); // Check that the contract is initialized assertSlotValueIsOne({ _contractAddress: address(portal), _slot: 0, _offset: 0 }); @@ -373,7 +382,7 @@ library ChainAssertions { require(address(portal.systemConfig()) == _contracts.SystemConfig); require(portal.guardian() == guardian); require(address(portal.superchainConfig()) == address(_contracts.SuperchainConfig)); - require(portal.paused() == SuperchainConfig(_contracts.SuperchainConfig).paused()); + require(portal.paused() == ISuperchainConfig(_contracts.SuperchainConfig).paused()); require(portal.l2Sender() == Constants.DEFAULT_L2_SENDER); } else { require(address(portal.disputeGameFactory()) == address(0)); @@ -422,7 +431,7 @@ library ChainAssertions { view { console.log("Running chain assertions on the SuperchainConfig"); - SuperchainConfig superchainConfig = SuperchainConfig(_contracts.SuperchainConfig); + ISuperchainConfig superchainConfig = ISuperchainConfig(_contracts.SuperchainConfig); // Check that the contract is initialized assertSlotValueIsOne({ _contractAddress: address(superchainConfig), _slot: 0, _offset: 0 }); diff --git a/packages/contracts-bedrock/scripts/deploy/Deploy.s.sol b/packages/contracts-bedrock/scripts/deploy/Deploy.s.sol index 659eb2b338dd..71828ebc3ba1 100644 --- a/packages/contracts-bedrock/scripts/deploy/Deploy.s.sol +++ b/packages/contracts-bedrock/scripts/deploy/Deploy.s.sol @@ -1,38 +1,39 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; +// Testing import { VmSafe } from "forge-std/Vm.sol"; import { Script } from "forge-std/Script.sol"; - import { console2 as console } from "forge-std/console2.sol"; import { stdJson } from "forge-std/StdJson.sol"; +import { AlphabetVM } from "test/mocks/AlphabetVM.sol"; +import { EIP1967Helper } from "test/mocks/EIP1967Helper.sol"; +// Safe import { GnosisSafe as Safe } from "safe-contracts/GnosisSafe.sol"; import { OwnerManager } from "safe-contracts/base/OwnerManager.sol"; import { GnosisSafeProxyFactory as SafeProxyFactory } from "safe-contracts/proxies/GnosisSafeProxyFactory.sol"; import { Enum as SafeOps } from "safe-contracts/common/Enum.sol"; +// Scripts import { Deployer } from "scripts/deploy/Deployer.sol"; +import { Chains } from "scripts/libraries/Chains.sol"; +import { Config } from "scripts/libraries/Config.sol"; +import { LibStateDiff } from "scripts/libraries/LibStateDiff.sol"; +import { Process } from "scripts/libraries/Process.sol"; +import { ForgeArtifacts } from "scripts/libraries/ForgeArtifacts.sol"; +import { ChainAssertions } from "scripts/deploy/ChainAssertions.sol"; +// Contracts import { ProxyAdmin } from "src/universal/ProxyAdmin.sol"; import { AddressManager } from "src/legacy/AddressManager.sol"; import { Proxy } from "src/universal/Proxy.sol"; import { L1StandardBridge } from "src/L1/L1StandardBridge.sol"; import { StandardBridge } from "src/universal/StandardBridge.sol"; -import { OptimismPortal } from "src/L1/OptimismPortal.sol"; -import { OptimismPortal2 } from "src/L1/OptimismPortal2.sol"; -import { OptimismPortalInterop } from "src/L1/OptimismPortalInterop.sol"; import { L1ChugSplashProxy } from "src/legacy/L1ChugSplashProxy.sol"; import { ResolvedDelegateProxy } from "src/legacy/ResolvedDelegateProxy.sol"; -import { L1CrossDomainMessenger } from "src/L1/L1CrossDomainMessenger.sol"; -import { IL2OutputOracle } from "src/L1/interfaces/IL2OutputOracle.sol"; import { OptimismMintableERC20Factory } from "src/universal/OptimismMintableERC20Factory.sol"; -import { SuperchainConfig } from "src/L1/SuperchainConfig.sol"; -import { SystemConfig } from "src/L1/SystemConfig.sol"; import { SystemConfigInterop } from "src/L1/SystemConfigInterop.sol"; -import { ResourceMetering } from "src/L1/ResourceMetering.sol"; -import { DataAvailabilityChallenge } from "src/L1/DataAvailabilityChallenge.sol"; -import { Constants } from "src/libraries/Constants.sol"; import { DisputeGameFactory } from "src/dispute/DisputeGameFactory.sol"; import { FaultDisputeGame } from "src/dispute/FaultDisputeGame.sol"; import { PermissionedDisputeGame } from "src/dispute/PermissionedDisputeGame.sol"; @@ -43,20 +44,25 @@ import { MIPS } from "src/cannon/MIPS.sol"; import { L1ERC721Bridge } from "src/L1/L1ERC721Bridge.sol"; import { ProtocolVersions, ProtocolVersion } from "src/L1/ProtocolVersions.sol"; import { StorageSetter } from "src/universal/StorageSetter.sol"; + +// Libraries +import { Constants } from "src/libraries/Constants.sol"; import { Predeploys } from "src/libraries/Predeploys.sol"; -import { Chains } from "scripts/libraries/Chains.sol"; -import { Config } from "scripts/libraries/Config.sol"; +import { Types } from "scripts/libraries/Types.sol"; +import "src/dispute/lib/Types.sol"; +// Interfaces +import { IOptimismPortal } from "src/L1/interfaces/IOptimismPortal.sol"; +import { IOptimismPortal2 } from "src/L1/interfaces/IOptimismPortal2.sol"; +import { IOptimismPortalInterop } from "src/L1/interfaces/IOptimismPortalInterop.sol"; +import { ICrossDomainMessenger } from "src/universal/interfaces/ICrossDomainMessenger.sol"; +import { IL1CrossDomainMessenger } from "src/L1/interfaces/IL1CrossDomainMessenger.sol"; +import { IL2OutputOracle } from "src/L1/interfaces/IL2OutputOracle.sol"; +import { ISuperchainConfig } from "src/L1/interfaces/ISuperchainConfig.sol"; +import { ISystemConfig } from "src/L1/interfaces/ISystemConfig.sol"; +import { IDataAvailabilityChallenge } from "src/L1/interfaces/IDataAvailabilityChallenge.sol"; import { IBigStepper } from "src/dispute/interfaces/IBigStepper.sol"; import { IPreimageOracle } from "src/cannon/interfaces/IPreimageOracle.sol"; -import { AlphabetVM } from "test/mocks/AlphabetVM.sol"; -import "src/dispute/lib/Types.sol"; -import { ChainAssertions } from "scripts/deploy/ChainAssertions.sol"; -import { Types } from "scripts/libraries/Types.sol"; -import { LibStateDiff } from "scripts/libraries/LibStateDiff.sol"; -import { EIP1967Helper } from "test/mocks/EIP1967Helper.sol"; -import { ForgeArtifacts } from "scripts/libraries/ForgeArtifacts.sol"; -import { Process } from "scripts/libraries/Process.sol"; /// @title Deploy /// @notice Script used to deploy a bedrock system. The entire system is deployed within the `run` function. @@ -613,23 +619,16 @@ contract Deploy is Deployer { /// @notice Deploy the SuperchainConfig contract function deploySuperchainConfig() public broadcast { - SuperchainConfig superchainConfig = new SuperchainConfig{ salt: _implSalt() }(); + ISuperchainConfig superchainConfig = ISuperchainConfig(_deploy("SuperchainConfig", hex"")); require(superchainConfig.guardian() == address(0)); bytes32 initialized = vm.load(address(superchainConfig), bytes32(0)); require(initialized != 0); - - save("SuperchainConfig", address(superchainConfig)); - console.log("SuperchainConfig deployed at %s", address(superchainConfig)); } /// @notice Deploy the L1CrossDomainMessenger function deployL1CrossDomainMessenger() public broadcast returns (address addr_) { - console.log("Deploying L1CrossDomainMessenger implementation"); - L1CrossDomainMessenger messenger = new L1CrossDomainMessenger{ salt: _implSalt() }(); - - save("L1CrossDomainMessenger", address(messenger)); - console.log("L1CrossDomainMessenger deployed at %s", address(messenger)); + IL1CrossDomainMessenger messenger = IL1CrossDomainMessenger(_deploy("L1CrossDomainMessenger", hex"")); // Override the `L1CrossDomainMessenger` contract to the deployed implementation. This is necessary // to check the `L1CrossDomainMessenger` implementation alongside dependent contracts, which @@ -643,13 +642,11 @@ contract Deploy is Deployer { /// @notice Deploy the OptimismPortal function deployOptimismPortal() public broadcast returns (address addr_) { - console.log("Deploying OptimismPortal implementation"); if (cfg.useInterop()) { console.log("Attempting to deploy OptimismPortal with interop, this config is a noop"); } - addr_ = address(new OptimismPortal{ salt: _implSalt() }()); - save("OptimismPortal", addr_); - console.log("OptimismPortal deployed at %s", addr_); + + addr_ = _deploy("OptimismPortal", hex""); // Override the `OptimismPortal` contract to the deployed implementation. This is necessary // to check the `OptimismPortal` implementation alongside dependent contracts, which @@ -661,32 +658,23 @@ contract Deploy is Deployer { /// @notice Deploy the OptimismPortal2 function deployOptimismPortal2() public broadcast returns (address addr_) { - console.log("Deploying OptimismPortal2 implementation"); - // Could also verify this inside DeployConfig but doing it here is a bit more reliable. require( uint32(cfg.respectedGameType()) == cfg.respectedGameType(), "Deploy: respectedGameType must fit into uint32" ); if (cfg.useInterop()) { - addr_ = address( - new OptimismPortalInterop{ salt: _implSalt() }({ - _proofMaturityDelaySeconds: cfg.proofMaturityDelaySeconds(), - _disputeGameFinalityDelaySeconds: cfg.disputeGameFinalityDelaySeconds() - }) + addr_ = _deploy( + "OptimismPortalInterop", + abi.encode(cfg.proofMaturityDelaySeconds(), cfg.disputeGameFinalityDelaySeconds()) ); + save("OptimismPortal2", addr_); } else { - addr_ = address( - new OptimismPortal2{ salt: _implSalt() }({ - _proofMaturityDelaySeconds: cfg.proofMaturityDelaySeconds(), - _disputeGameFinalityDelaySeconds: cfg.disputeGameFinalityDelaySeconds() - }) + addr_ = _deploy( + "OptimismPortal2", abi.encode(cfg.proofMaturityDelaySeconds(), cfg.disputeGameFinalityDelaySeconds()) ); } - save("OptimismPortal2", addr_); - console.log("OptimismPortal2 deployed at %s", addr_); - // Override the `OptimismPortal2` contract to the deployed implementation. This is necessary // to check the `OptimismPortal2` implementation alongside dependent contracts, which // are always proxies. @@ -822,14 +810,12 @@ contract Deploy is Deployer { /// @notice Deploy the SystemConfig function deploySystemConfig() public broadcast returns (address addr_) { - console.log("Deploying SystemConfig implementation"); if (cfg.useInterop()) { - addr_ = address(new SystemConfigInterop{ salt: _implSalt() }()); + addr_ = _deploy("SystemConfigInterop", hex""); + save("SystemConfig", addr_); } else { - addr_ = address(new SystemConfig{ salt: _implSalt() }()); + addr_ = _deploy("SystemConfig", hex""); } - save("SystemConfig", addr_); - console.log("SystemConfig deployed at %s", addr_); // Override the `SystemConfig` contract to the deployed implementation. This is necessary // to check the `SystemConfig` implementation alongside dependent contracts, which @@ -893,11 +879,8 @@ contract Deploy is Deployer { /// @notice Deploy the DataAvailabilityChallenge function deployDataAvailabilityChallenge() public broadcast returns (address addr_) { - console.log("Deploying DataAvailabilityChallenge implementation"); - DataAvailabilityChallenge dac = new DataAvailabilityChallenge(); - save("DataAvailabilityChallenge", address(dac)); - console.log("DataAvailabilityChallenge deployed at %s", address(dac)); - + IDataAvailabilityChallenge dac = + IDataAvailabilityChallenge(payable(_deploy("DataAvailabilityChallenge", hex""))); addr_ = address(dac); } @@ -912,7 +895,7 @@ contract Deploy is Deployer { _upgradeAndCallViaSafe({ _proxy: superchainConfigProxy, _implementation: superchainConfig, - _innerCallData: abi.encodeCall(SuperchainConfig.initialize, (cfg.superchainConfigGuardian(), false)) + _innerCallData: abi.encodeCall(ISuperchainConfig.initialize, (cfg.superchainConfigGuardian(), false)) }); ChainAssertions.checkSuperchainConfig({ _contracts: _proxiesUnstrict(), _cfg: cfg, _isPaused: false }); @@ -945,7 +928,7 @@ contract Deploy is Deployer { _upgradeAndCallViaSafe({ _proxy: payable(delayedWETHProxy), _implementation: delayedWETH, - _innerCallData: abi.encodeCall(DelayedWETH.initialize, (msg.sender, SuperchainConfig(superchainConfigProxy))) + _innerCallData: abi.encodeCall(DelayedWETH.initialize, (msg.sender, ISuperchainConfig(superchainConfigProxy))) }); string memory version = DelayedWETH(payable(delayedWETHProxy)).version(); @@ -968,7 +951,7 @@ contract Deploy is Deployer { _upgradeAndCallViaSafe({ _proxy: payable(delayedWETHProxy), _implementation: delayedWETH, - _innerCallData: abi.encodeCall(DelayedWETH.initialize, (msg.sender, SuperchainConfig(superchainConfigProxy))) + _innerCallData: abi.encodeCall(DelayedWETH.initialize, (msg.sender, ISuperchainConfig(superchainConfigProxy))) }); string memory version = DelayedWETH(payable(delayedWETHProxy)).version(); @@ -986,7 +969,7 @@ contract Deploy is Deployer { console.log("Upgrading and initializing AnchorStateRegistry proxy"); address anchorStateRegistryProxy = mustGetAddress("AnchorStateRegistryProxy"); address anchorStateRegistry = mustGetAddress("AnchorStateRegistry"); - SuperchainConfig superchainConfig = SuperchainConfig(mustGetAddress("SuperchainConfigProxy")); + ISuperchainConfig superchainConfig = ISuperchainConfig(mustGetAddress("SuperchainConfigProxy")); AnchorStateRegistry.StartingAnchorRoot[] memory roots = new AnchorStateRegistry.StartingAnchorRoot[](5); roots[0] = AnchorStateRegistry.StartingAnchorRoot({ @@ -1052,7 +1035,7 @@ contract Deploy is Deployer { _proxy: payable(systemConfigProxy), _implementation: systemConfig, _innerCallData: abi.encodeCall( - SystemConfig.initialize, + ISystemConfig.initialize, ( cfg.finalSystemOwner(), cfg.basefeeScalar(), @@ -1062,7 +1045,7 @@ contract Deploy is Deployer { cfg.p2pSequencerAddress(), Constants.DEFAULT_RESOURCE_CONFIG(), cfg.batchInboxAddress(), - SystemConfig.Addresses({ + ISystemConfig.Addresses({ l1CrossDomainMessenger: mustGetAddress("L1CrossDomainMessengerProxy"), l1ERC721Bridge: mustGetAddress("L1ERC721BridgeProxy"), l1StandardBridge: mustGetAddress("L1StandardBridgeProxy"), @@ -1075,7 +1058,7 @@ contract Deploy is Deployer { ) }); - SystemConfig config = SystemConfig(systemConfigProxy); + ISystemConfig config = ISystemConfig(systemConfigProxy); string memory version = config.version(); console.log("SystemConfig version: %s", version); @@ -1109,9 +1092,9 @@ contract Deploy is Deployer { _innerCallData: abi.encodeCall( L1StandardBridge.initialize, ( - L1CrossDomainMessenger(l1CrossDomainMessengerProxy), - SuperchainConfig(superchainConfigProxy), - SystemConfig(systemConfigProxy) + ICrossDomainMessenger(l1CrossDomainMessengerProxy), + ISuperchainConfig(superchainConfigProxy), + ISystemConfig(systemConfigProxy) ) ) }); @@ -1135,7 +1118,7 @@ contract Deploy is Deployer { _implementation: l1ERC721Bridge, _innerCallData: abi.encodeCall( L1ERC721Bridge.initialize, - (L1CrossDomainMessenger(payable(l1CrossDomainMessengerProxy)), SuperchainConfig(superchainConfigProxy)) + (ICrossDomainMessenger(payable(l1CrossDomainMessengerProxy)), ISuperchainConfig(superchainConfigProxy)) ) }); @@ -1205,16 +1188,16 @@ contract Deploy is Deployer { _proxy: payable(l1CrossDomainMessengerProxy), _implementation: l1CrossDomainMessenger, _innerCallData: abi.encodeCall( - L1CrossDomainMessenger.initialize, + IL1CrossDomainMessenger.initialize, ( - SuperchainConfig(superchainConfigProxy), - OptimismPortal(payable(optimismPortalProxy)), - SystemConfig(systemConfigProxy) + ISuperchainConfig(superchainConfigProxy), + IOptimismPortal(payable(optimismPortalProxy)), + ISystemConfig(systemConfigProxy) ) ) }); - L1CrossDomainMessenger messenger = L1CrossDomainMessenger(l1CrossDomainMessengerProxy); + IL1CrossDomainMessenger messenger = IL1CrossDomainMessenger(l1CrossDomainMessengerProxy); string memory version = messenger.version(); console.log("L1CrossDomainMessenger version: %s", version); @@ -1269,16 +1252,16 @@ contract Deploy is Deployer { _proxy: payable(optimismPortalProxy), _implementation: optimismPortal, _innerCallData: abi.encodeCall( - OptimismPortal.initialize, + IOptimismPortal.initialize, ( IL2OutputOracle(l2OutputOracleProxy), - SystemConfig(systemConfigProxy), - SuperchainConfig(superchainConfigProxy) + ISystemConfig(systemConfigProxy), + ISuperchainConfig(superchainConfigProxy) ) ) }); - OptimismPortal portal = OptimismPortal(payable(optimismPortalProxy)); + IOptimismPortal portal = IOptimismPortal(payable(optimismPortalProxy)); string memory version = portal.version(); console.log("OptimismPortal version: %s", version); @@ -1298,17 +1281,17 @@ contract Deploy is Deployer { _proxy: payable(optimismPortalProxy), _implementation: optimismPortal2, _innerCallData: abi.encodeCall( - OptimismPortal2.initialize, + IOptimismPortal2.initialize, ( DisputeGameFactory(disputeGameFactoryProxy), - SystemConfig(systemConfigProxy), - SuperchainConfig(superchainConfigProxy), + ISystemConfig(systemConfigProxy), + ISuperchainConfig(superchainConfigProxy), GameType.wrap(uint32(cfg.respectedGameType())) ) ) }); - OptimismPortal2 portal = OptimismPortal2(payable(optimismPortalProxy)); + IOptimismPortal2 portal = IOptimismPortal2(payable(optimismPortalProxy)); string memory version = portal.version(); console.log("OptimismPortal2 version: %s", version); @@ -1596,12 +1579,12 @@ contract Deploy is Deployer { _proxy: payable(dataAvailabilityChallengeProxy), _implementation: dataAvailabilityChallenge, _innerCallData: abi.encodeCall( - DataAvailabilityChallenge.initialize, + IDataAvailabilityChallenge.initialize, (finalSystemOwner, daChallengeWindow, daResolveWindow, daBondSize, daResolverRefundPercentage) ) }); - DataAvailabilityChallenge dac = DataAvailabilityChallenge(payable(dataAvailabilityChallengeProxy)); + IDataAvailabilityChallenge dac = IDataAvailabilityChallenge(payable(dataAvailabilityChallengeProxy)); string memory version = dac.version(); console.log("DataAvailabilityChallenge version: %s", version); diff --git a/packages/contracts-bedrock/scripts/deploy/DeployOwnership.s.sol b/packages/contracts-bedrock/scripts/deploy/DeployOwnership.s.sol index 05fbfd54df93..a40c06a17c0f 100644 --- a/packages/contracts-bedrock/scripts/deploy/DeployOwnership.s.sol +++ b/packages/contracts-bedrock/scripts/deploy/DeployOwnership.s.sol @@ -14,7 +14,7 @@ import { Deployer } from "scripts/deploy/Deployer.sol"; import { LivenessGuard } from "src/Safe/LivenessGuard.sol"; import { LivenessModule } from "src/Safe/LivenessModule.sol"; import { DeputyGuardianModule } from "src/Safe/DeputyGuardianModule.sol"; -import { SuperchainConfig } from "src/L1/SuperchainConfig.sol"; +import { ISuperchainConfig } from "src/L1/interfaces/ISuperchainConfig.sol"; import { Deploy } from "./Deploy.s.sol"; @@ -41,7 +41,7 @@ struct SecurityCouncilConfig { /// @notice Configuration for the Deputy Guardian Module struct DeputyGuardianModuleConfig { address deputyGuardian; - SuperchainConfig superchainConfig; + ISuperchainConfig superchainConfig; } /// @notice Configuration for the Guardian Safe. @@ -89,7 +89,7 @@ contract DeployOwnership is Deploy { safeConfig: SafeConfig({ threshold: 1, owners: exampleGuardianOwners }), deputyGuardianModuleConfig: DeputyGuardianModuleConfig({ deputyGuardian: mustGetAddress("FoundationOperationsSafe"), - superchainConfig: SuperchainConfig(mustGetAddress("SuperchainConfig")) + superchainConfig: ISuperchainConfig(mustGetAddress("SuperchainConfig")) }) }); } diff --git a/packages/contracts-bedrock/scripts/fpac/FPACOPS.s.sol b/packages/contracts-bedrock/scripts/fpac/FPACOPS.s.sol index 9d6ad4b719e7..cc00d1a8c866 100644 --- a/packages/contracts-bedrock/scripts/fpac/FPACOPS.s.sol +++ b/packages/contracts-bedrock/scripts/fpac/FPACOPS.s.sol @@ -86,14 +86,14 @@ contract FPACOPS is Deploy, StdAssertions { address superchainConfigProxy = mustGetAddress("SuperchainConfigProxy"); Proxy(payable(wethProxy)).upgradeToAndCall( mustGetAddress("DelayedWETH"), - abi.encodeCall(DelayedWETH.initialize, (msg.sender, SuperchainConfig(superchainConfigProxy))) + abi.encodeCall(DelayedWETH.initialize, (msg.sender, ISuperchainConfig(superchainConfigProxy))) ); } function initializeAnchorStateRegistryProxy() internal broadcast { console.log("Initializing AnchorStateRegistryProxy with AnchorStateRegistry."); address superchainConfigProxy = mustGetAddress("SuperchainConfigProxy"); - SuperchainConfig superchainConfig = SuperchainConfig(superchainConfigProxy); + ISuperchainConfig superchainConfig = ISuperchainConfig(superchainConfigProxy); AnchorStateRegistry.StartingAnchorRoot[] memory roots = new AnchorStateRegistry.StartingAnchorRoot[](2); roots[0] = AnchorStateRegistry.StartingAnchorRoot({ diff --git a/packages/contracts-bedrock/scripts/fpac/FPACOPS2.s.sol b/packages/contracts-bedrock/scripts/fpac/FPACOPS2.s.sol index 09171538010c..4d5f3e4d9af3 100644 --- a/packages/contracts-bedrock/scripts/fpac/FPACOPS2.s.sol +++ b/packages/contracts-bedrock/scripts/fpac/FPACOPS2.s.sol @@ -134,7 +134,7 @@ contract FPACOPS2 is Deploy, StdAssertions { address superchainConfigProxy = mustGetAddress("SuperchainConfigProxy"); Proxy(payable(wethProxy)).upgradeToAndCall( mustGetAddress("DelayedWETH"), - abi.encodeCall(DelayedWETH.initialize, (msg.sender, SuperchainConfig(superchainConfigProxy))) + abi.encodeCall(DelayedWETH.initialize, (msg.sender, ISuperchainConfig(superchainConfigProxy))) ); } @@ -146,7 +146,7 @@ contract FPACOPS2 is Deploy, StdAssertions { address superchainConfigProxy = mustGetAddress("SuperchainConfigProxy"); Proxy(payable(wethProxy)).upgradeToAndCall( mustGetAddress("DelayedWETH"), - abi.encodeCall(DelayedWETH.initialize, (msg.sender, SuperchainConfig(superchainConfigProxy))) + abi.encodeCall(DelayedWETH.initialize, (msg.sender, ISuperchainConfig(superchainConfigProxy))) ); } diff --git a/packages/contracts-bedrock/scripts/interfaces/ISystemConfigV0.sol b/packages/contracts-bedrock/scripts/interfaces/ISystemConfigV0.sol index 07f911e762a9..af1397d72645 100644 --- a/packages/contracts-bedrock/scripts/interfaces/ISystemConfigV0.sol +++ b/packages/contracts-bedrock/scripts/interfaces/ISystemConfigV0.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; -import { ResourceMetering } from "src/L1/ResourceMetering.sol"; +import { IResourceMetering } from "src/L1/interfaces/IResourceMetering.sol"; /// @title ISystemConfigV0 /// @notice Minimal interface of the Legacy SystemConfig containing only getters. @@ -14,6 +14,6 @@ interface ISystemConfigV0 { function scalar() external view returns (uint256); function batcherHash() external view returns (bytes32); function gasLimit() external view returns (uint64); - function resourceConfig() external view returns (ResourceMetering.ResourceConfig memory); + function resourceConfig() external view returns (IResourceMetering.ResourceConfig memory); function unsafeBlockSigner() external view returns (address); } diff --git a/packages/contracts-bedrock/semver-lock.json b/packages/contracts-bedrock/semver-lock.json index 5f885b995732..8f44a70958a7 100644 --- a/packages/contracts-bedrock/semver-lock.json +++ b/packages/contracts-bedrock/semver-lock.json @@ -9,23 +9,23 @@ }, "src/L1/DataAvailabilityChallenge.sol": { "initCodeHash": "0xcc96cf2e4d841adb7ecb9dd84abeb0893dd62d913c0d47ab5b66a893c6e47e88", - "sourceCodeHash": "0x3260f2721af58ab77d4eae50365f3afe021a03b6383139e69779ac40f511b792" + "sourceCodeHash": "0xce01773740f4d50ac77f868343d654f6ca24f85d2770eb7e4043e98f609b1c15" }, "src/L1/DelayedVetoable.sol": { "initCodeHash": "0xd504ab0568719a0fb960ebe73d0437645f5c4bd8f6619219858209ef002516dd", - "sourceCodeHash": "0x1806db090be1a0bd8cba1b0b44a4f1c28a3cfc58a174a025fc292163bfff8cee" + "sourceCodeHash": "0x60af558156543d639a0a92e983ad0f045aac1f9ac4c3adaa1d4d97b37175e03a" }, "src/L1/L1CrossDomainMessenger.sol": { "initCodeHash": "0x48db42620b9f16e0dec2355f4076314f82fd0f60ef04c10cdbc266eac9472515", - "sourceCodeHash": "0xca37e50dd6c1aa86bbc5f9ec640410bf234cd911158ba91af984fd2ed94c19c5" + "sourceCodeHash": "0xb77342e6b55b835e9597f7a1c4a2d52ddd56f5cfb7cd38da0bcc488c79a9011e" }, "src/L1/L1ERC721Bridge.sol": { "initCodeHash": "0xda80d225e332f9ab38d5f3ae655df3eea1dd56dbb523036a25c78859d2931ada", - "sourceCodeHash": "0xcef23f69992fa6cb5ad051858dbec924a06fa3b7b44f03caa2415804d6ce7bd0" + "sourceCodeHash": "0x0454bb88f7b52c362309935fa21ecc8be7bd6f0d888270b8a00677c60c1014cb" }, "src/L1/L1StandardBridge.sol": { "initCodeHash": "0x2868b09ecbe9f2bbc885605c2886b4c79f1c8e4171626c63776603b1b84698a8", - "sourceCodeHash": "0x35f27059e5a7421ddf6394f9739a8c9f434de17e1736644695791c19b8240e74" + "sourceCodeHash": "0xc03da137b3ea72e0109fb284229283b21a0303104afbe37d2fe86ad806392a7f" }, "src/L1/L2OutputOracle.sol": { "initCodeHash": "0x433fac9de52d8ce8fc3471b78ef6cc9cff1019f480c9ad91b6e09ab8738a8edb", @@ -36,16 +36,16 @@ "sourceCodeHash": "0x5182a2678dadb200dd255ecdfa395e5f7b1e1e27288e78ddf8802ab51ed2dd81" }, "src/L1/OptimismPortal.sol": { - "initCodeHash": "0x6bf59539298b20221de6c51db21016be8d3278bdbe0be1cdd49638dc828e003e", - "sourceCodeHash": "0x07f6f4c0cc14be4aeb9a29ec4a238ea3748d5cb6b244e0054845a18308c16ab5" + "initCodeHash": "0xb7a7a28d5b3b88334e7cb4bc1c5fbbf9f691d934e907a2fed6a30e461eb1c0f6", + "sourceCodeHash": "0x17404b6cc3f62f66786c314e2abdf021a19c00845e2cbb2ec7796f2fa469991c" }, "src/L1/OptimismPortal2.sol": { - "initCodeHash": "0x414ad1fdb6296ac32fc67ce01288b6e67bedd2ed239d7eb8ed40c7f55f9021f2", - "sourceCodeHash": "0xa70bdc0bb666baa731ab32c79a7b8b15cee23bd46ddfec5f259eaf19b5653fe1" + "initCodeHash": "0x6c1168834a0d2a23d9bfb995dd458ef5c2fd059c874d453988ef648de8300730", + "sourceCodeHash": "0xa8053edf2ddd421615c7570e5dbb435980b88e0f08e3189e2fc69b7a476e80a2" }, "src/L1/OptimismPortalInterop.sol": { - "initCodeHash": "0x9222fba222d1ab66898eef09ecea3ea757e64c8ae98def4da7808cd7cc8f39a8", - "sourceCodeHash": "0x57353b84bbcb05634f135ad8090d96f07467dd3dbf159650714449d0667efc62" + "initCodeHash": "0xc95dd89962e301ce1fe773337463ea6e3b32b362971e5ad4f69e0881af7f4b7d", + "sourceCodeHash": "0xe6a7794799915f408cb57c73af266670de8a3f02408d3dbc2c97db25d3e42635" }, "src/L1/ProtocolVersions.sol": { "initCodeHash": "0x8f033874dd8b36615b2209d553660dcff1ff91ca2bad3ca1de7b441dbfba4842", @@ -57,11 +57,11 @@ }, "src/L1/SystemConfig.sol": { "initCodeHash": "0x2fc36af5b3c493a423a19e0b597f6ff230b756b861b68099f3192d69b6088dc0", - "sourceCodeHash": "0xacffbb4e73d39a642adc24baaa50c92604f4c0b04ff31287e24a46bda5277033" + "sourceCodeHash": "0x06a50ac992175fdb434b13e8461893e83862c23ce399e697e6e8109728ad1a3d" }, "src/L1/SystemConfigInterop.sol": { "initCodeHash": "0xc5a3ffc59dd7bf1ef238087414cfa04b37f0d83fc9a4f5e6d62a1059a23359f3", - "sourceCodeHash": "0x272bcfafab62516609250c85cd73815bf0a243fdb9d34fc603f71e801299b57c" + "sourceCodeHash": "0xd7b6ebf03ead541917b1bdfcf1293ca3c8a8e3865b8a8548bee69956a4ce71cc" }, "src/L2/BaseFeeVault.sol": { "initCodeHash": "0x3bfcd57e25ad54b66c374f63e24e33a6cf107044aa8f5f69ef21202c380b5c5b", @@ -97,11 +97,11 @@ }, "src/L2/L2ERC721Bridge.sol": { "initCodeHash": "0x827077e1a0ce6c8f9ee1196c409ea77d831efd440992b3969b05259083cdf0bd", - "sourceCodeHash": "0xaef911601556f93deac78cb3329fdcc1507ea248c3986548e76997938c43391b" + "sourceCodeHash": "0xdc5e08a5a9ee8d61e843ac630126629ccfedb49a3b0dd167863dd48d75629a95" }, "src/L2/L2StandardBridge.sol": { "initCodeHash": "0x01692b613e3d4e649d877a0fd8f0798a26401ba8ccc4cda0e61f1f9079729320", - "sourceCodeHash": "0x3efb2dabff452f5d2584839d1460183cb8aecd5456fbfa3a72d80de40df783b7" + "sourceCodeHash": "0x5c8e8ba3ecdae116f98caf67cca5fb3594bf7085e186f0a14bad1d6f143b6bc8" }, "src/L2/L2StandardBridgeInterop.sol": { "initCodeHash": "0x5c9ef6b0817f715d1b8b097f3fc19e33bc54453426ca12bb48e4cea143076339", @@ -133,7 +133,7 @@ }, "src/Safe/DeputyGuardianModule.sol": { "initCodeHash": "0xce6cd0e4f21693a32e7a8ef463b8233b0dde83bdb426f5adc3eef822d4de7bec", - "sourceCodeHash": "0x45fdf6b414a6eae662392051a5e0acc5b95f23ca33f739ddfb35ae2e7ce81728" + "sourceCodeHash": "0x7b0f24df9af4cf5a52e23b98898b884d8175ad89cc24046d6463c3e9b3599d4d" }, "src/Safe/LivenessGuard.sol": { "initCodeHash": "0xfd74ff89e7b689b38ab97515d64429ffaf6c0cd1ea6488c6a4743a0665419c85", @@ -157,7 +157,7 @@ }, "src/dispute/AnchorStateRegistry.sol": { "initCodeHash": "0x6198f305686e6fdfd94db7aeb840a12e263036dcdc234550db49d3f0b87039a8", - "sourceCodeHash": "0x384d4e7067d423dc32b8588341b61a504a28505aa5ed7dd76f115991be072ee0" + "sourceCodeHash": "0x8450bdccf5039bad48284c73c9cfa657cbcc0a435965d9e13ac88f388c591779" }, "src/dispute/DisputeGameFactory.sol": { "initCodeHash": "0xc1a10f65287c414076b68a7de6c238b91bc6252213187bdef35657d0f00f9382", @@ -169,7 +169,7 @@ }, "src/dispute/weth/DelayedWETH.sol": { "initCodeHash": "0x3e687c928b6c890b91c82584ccb1fec47b025b8e58cd9cbfa65229b38b304bae", - "sourceCodeHash": "0x7ebe0d9771fc8adfd97386972a571eb1753065a202d4711c0b9587d99f3bd261" + "sourceCodeHash": "0x9d6667536161b3fa655dfb3e9a01db070cd0e84d800e34947b10b3b2168a3d56" }, "src/legacy/DeployerWhitelist.sol": { "initCodeHash": "0x0b8177ed75b69eddbb9ce6537683f69a9935efed86a1d6faa8feaafbd151c1bd", diff --git a/packages/contracts-bedrock/snapshots/abi/AnchorStateRegistry.json b/packages/contracts-bedrock/snapshots/abi/AnchorStateRegistry.json index aaa832eb1b70..c1a0fc693a9a 100644 --- a/packages/contracts-bedrock/snapshots/abi/AnchorStateRegistry.json +++ b/packages/contracts-bedrock/snapshots/abi/AnchorStateRegistry.json @@ -79,7 +79,7 @@ "type": "tuple[]" }, { - "internalType": "contract SuperchainConfig", + "internalType": "contract ISuperchainConfig", "name": "_superchainConfig", "type": "address" } @@ -107,7 +107,7 @@ "name": "superchainConfig", "outputs": [ { - "internalType": "contract SuperchainConfig", + "internalType": "contract ISuperchainConfig", "name": "", "type": "address" } diff --git a/packages/contracts-bedrock/snapshots/abi/DelayedWETH.json b/packages/contracts-bedrock/snapshots/abi/DelayedWETH.json index fe4fd5b63f61..a84394e6b003 100644 --- a/packages/contracts-bedrock/snapshots/abi/DelayedWETH.json +++ b/packages/contracts-bedrock/snapshots/abi/DelayedWETH.json @@ -90,7 +90,7 @@ "name": "config", "outputs": [ { - "internalType": "contract SuperchainConfig", + "internalType": "contract ISuperchainConfig", "name": "", "type": "address" } @@ -157,7 +157,7 @@ "type": "address" }, { - "internalType": "contract SuperchainConfig", + "internalType": "contract ISuperchainConfig", "name": "_config", "type": "address" } diff --git a/packages/contracts-bedrock/snapshots/abi/DeputyGuardianModule.json b/packages/contracts-bedrock/snapshots/abi/DeputyGuardianModule.json index 688d68f6f271..6e5c45fc3d8a 100644 --- a/packages/contracts-bedrock/snapshots/abi/DeputyGuardianModule.json +++ b/packages/contracts-bedrock/snapshots/abi/DeputyGuardianModule.json @@ -7,7 +7,7 @@ "type": "address" }, { - "internalType": "contract SuperchainConfig", + "internalType": "contract ISuperchainConfig", "name": "_superchainConfig", "type": "address" }, @@ -23,7 +23,7 @@ { "inputs": [ { - "internalType": "contract OptimismPortal2", + "internalType": "contract IOptimismPortal2", "name": "_portal", "type": "address" }, @@ -92,7 +92,7 @@ { "inputs": [ { - "internalType": "contract OptimismPortal2", + "internalType": "contract IOptimismPortal2", "name": "_portal", "type": "address" }, @@ -112,7 +112,7 @@ "name": "superchainConfig", "outputs": [ { - "internalType": "contract SuperchainConfig", + "internalType": "contract ISuperchainConfig", "name": "superchainConfig_", "type": "address" } diff --git a/packages/contracts-bedrock/snapshots/abi/L1CrossDomainMessenger.json b/packages/contracts-bedrock/snapshots/abi/L1CrossDomainMessenger.json index cc99f64c449e..22a4353cc656 100644 --- a/packages/contracts-bedrock/snapshots/abi/L1CrossDomainMessenger.json +++ b/packages/contracts-bedrock/snapshots/abi/L1CrossDomainMessenger.json @@ -74,7 +74,7 @@ "name": "PORTAL", "outputs": [ { - "internalType": "contract OptimismPortal", + "internalType": "contract IOptimismPortal", "name": "", "type": "address" } @@ -180,17 +180,17 @@ { "inputs": [ { - "internalType": "contract SuperchainConfig", + "internalType": "contract ISuperchainConfig", "name": "_superchainConfig", "type": "address" }, { - "internalType": "contract OptimismPortal", + "internalType": "contract IOptimismPortal", "name": "_portal", "type": "address" }, { - "internalType": "contract SystemConfig", + "internalType": "contract ISystemConfig", "name": "_systemConfig", "type": "address" } @@ -244,7 +244,7 @@ "name": "portal", "outputs": [ { - "internalType": "contract OptimismPortal", + "internalType": "contract IOptimismPortal", "name": "", "type": "address" } @@ -337,7 +337,7 @@ "name": "superchainConfig", "outputs": [ { - "internalType": "contract SuperchainConfig", + "internalType": "contract ISuperchainConfig", "name": "", "type": "address" } @@ -350,7 +350,7 @@ "name": "systemConfig", "outputs": [ { - "internalType": "contract SystemConfig", + "internalType": "contract ISystemConfig", "name": "", "type": "address" } diff --git a/packages/contracts-bedrock/snapshots/abi/L1ERC721Bridge.json b/packages/contracts-bedrock/snapshots/abi/L1ERC721Bridge.json index 386c8413a9ff..33cd5b0a850b 100644 --- a/packages/contracts-bedrock/snapshots/abi/L1ERC721Bridge.json +++ b/packages/contracts-bedrock/snapshots/abi/L1ERC721Bridge.json @@ -9,7 +9,7 @@ "name": "MESSENGER", "outputs": [ { - "internalType": "contract CrossDomainMessenger", + "internalType": "contract ICrossDomainMessenger", "name": "", "type": "address" } @@ -171,12 +171,12 @@ { "inputs": [ { - "internalType": "contract CrossDomainMessenger", + "internalType": "contract ICrossDomainMessenger", "name": "_messenger", "type": "address" }, { - "internalType": "contract SuperchainConfig", + "internalType": "contract ISuperchainConfig", "name": "_superchainConfig", "type": "address" } @@ -191,7 +191,7 @@ "name": "messenger", "outputs": [ { - "internalType": "contract CrossDomainMessenger", + "internalType": "contract ICrossDomainMessenger", "name": "", "type": "address" } @@ -230,7 +230,7 @@ "name": "superchainConfig", "outputs": [ { - "internalType": "contract SuperchainConfig", + "internalType": "contract ISuperchainConfig", "name": "", "type": "address" } diff --git a/packages/contracts-bedrock/snapshots/abi/L1StandardBridge.json b/packages/contracts-bedrock/snapshots/abi/L1StandardBridge.json index 2a93a9f8da24..45480499fe9f 100644 --- a/packages/contracts-bedrock/snapshots/abi/L1StandardBridge.json +++ b/packages/contracts-bedrock/snapshots/abi/L1StandardBridge.json @@ -13,7 +13,7 @@ "name": "MESSENGER", "outputs": [ { - "internalType": "contract CrossDomainMessenger", + "internalType": "contract ICrossDomainMessenger", "name": "", "type": "address" } @@ -417,17 +417,17 @@ { "inputs": [ { - "internalType": "contract CrossDomainMessenger", + "internalType": "contract ICrossDomainMessenger", "name": "_messenger", "type": "address" }, { - "internalType": "contract SuperchainConfig", + "internalType": "contract ISuperchainConfig", "name": "_superchainConfig", "type": "address" }, { - "internalType": "contract SystemConfig", + "internalType": "contract ISystemConfig", "name": "_systemConfig", "type": "address" } @@ -455,7 +455,7 @@ "name": "messenger", "outputs": [ { - "internalType": "contract CrossDomainMessenger", + "internalType": "contract ICrossDomainMessenger", "name": "", "type": "address" } @@ -494,7 +494,7 @@ "name": "superchainConfig", "outputs": [ { - "internalType": "contract SuperchainConfig", + "internalType": "contract ISuperchainConfig", "name": "", "type": "address" } @@ -507,7 +507,7 @@ "name": "systemConfig", "outputs": [ { - "internalType": "contract SystemConfig", + "internalType": "contract ISystemConfig", "name": "", "type": "address" } diff --git a/packages/contracts-bedrock/snapshots/abi/L2ERC721Bridge.json b/packages/contracts-bedrock/snapshots/abi/L2ERC721Bridge.json index d0df33b56960..e9578ad9726c 100644 --- a/packages/contracts-bedrock/snapshots/abi/L2ERC721Bridge.json +++ b/packages/contracts-bedrock/snapshots/abi/L2ERC721Bridge.json @@ -9,7 +9,7 @@ "name": "MESSENGER", "outputs": [ { - "internalType": "contract CrossDomainMessenger", + "internalType": "contract ICrossDomainMessenger", "name": "", "type": "address" } @@ -157,7 +157,7 @@ "name": "messenger", "outputs": [ { - "internalType": "contract CrossDomainMessenger", + "internalType": "contract ICrossDomainMessenger", "name": "", "type": "address" } diff --git a/packages/contracts-bedrock/snapshots/abi/L2StandardBridge.json b/packages/contracts-bedrock/snapshots/abi/L2StandardBridge.json index da71bae10f06..e562034818d5 100644 --- a/packages/contracts-bedrock/snapshots/abi/L2StandardBridge.json +++ b/packages/contracts-bedrock/snapshots/abi/L2StandardBridge.json @@ -13,7 +13,7 @@ "name": "MESSENGER", "outputs": [ { - "internalType": "contract CrossDomainMessenger", + "internalType": "contract ICrossDomainMessenger", "name": "", "type": "address" } @@ -267,7 +267,7 @@ "name": "messenger", "outputs": [ { - "internalType": "contract CrossDomainMessenger", + "internalType": "contract ICrossDomainMessenger", "name": "", "type": "address" } diff --git a/packages/contracts-bedrock/snapshots/abi/L2StandardBridgeInterop.json b/packages/contracts-bedrock/snapshots/abi/L2StandardBridgeInterop.json index d870c7180a30..b2dc8dddd050 100644 --- a/packages/contracts-bedrock/snapshots/abi/L2StandardBridgeInterop.json +++ b/packages/contracts-bedrock/snapshots/abi/L2StandardBridgeInterop.json @@ -8,7 +8,7 @@ "name": "MESSENGER", "outputs": [ { - "internalType": "contract CrossDomainMessenger", + "internalType": "contract ICrossDomainMessenger", "name": "", "type": "address" } @@ -285,7 +285,7 @@ "name": "messenger", "outputs": [ { - "internalType": "contract CrossDomainMessenger", + "internalType": "contract ICrossDomainMessenger", "name": "", "type": "address" } diff --git a/packages/contracts-bedrock/snapshots/abi/OptimismPortal.json b/packages/contracts-bedrock/snapshots/abi/OptimismPortal.json index 12ab9e26b9b3..7ccee328a984 100644 --- a/packages/contracts-bedrock/snapshots/abi/OptimismPortal.json +++ b/packages/contracts-bedrock/snapshots/abi/OptimismPortal.json @@ -184,12 +184,12 @@ "type": "address" }, { - "internalType": "contract SystemConfig", + "internalType": "contract ISystemConfig", "name": "_systemConfig", "type": "address" }, { - "internalType": "contract SuperchainConfig", + "internalType": "contract ISuperchainConfig", "name": "_superchainConfig", "type": "address" } @@ -443,7 +443,7 @@ "name": "superchainConfig", "outputs": [ { - "internalType": "contract SuperchainConfig", + "internalType": "contract ISuperchainConfig", "name": "", "type": "address" } @@ -456,7 +456,7 @@ "name": "systemConfig", "outputs": [ { - "internalType": "contract SystemConfig", + "internalType": "contract ISystemConfig", "name": "", "type": "address" } diff --git a/packages/contracts-bedrock/snapshots/abi/OptimismPortal2.json b/packages/contracts-bedrock/snapshots/abi/OptimismPortal2.json index 92610763d6f0..2f52ed573d37 100644 --- a/packages/contracts-bedrock/snapshots/abi/OptimismPortal2.json +++ b/packages/contracts-bedrock/snapshots/abi/OptimismPortal2.json @@ -158,7 +158,7 @@ "name": "disputeGameFactory", "outputs": [ { - "internalType": "contract DisputeGameFactory", + "internalType": "contract IDisputeGameFactory", "name": "", "type": "address" } @@ -316,17 +316,17 @@ { "inputs": [ { - "internalType": "contract DisputeGameFactory", + "internalType": "contract IDisputeGameFactory", "name": "_disputeGameFactory", "type": "address" }, { - "internalType": "contract SystemConfig", + "internalType": "contract ISystemConfig", "name": "_systemConfig", "type": "address" }, { - "internalType": "contract SuperchainConfig", + "internalType": "contract ISuperchainConfig", "name": "_superchainConfig", "type": "address" }, @@ -648,7 +648,7 @@ "name": "superchainConfig", "outputs": [ { - "internalType": "contract SuperchainConfig", + "internalType": "contract ISuperchainConfig", "name": "", "type": "address" } @@ -661,7 +661,7 @@ "name": "systemConfig", "outputs": [ { - "internalType": "contract SystemConfig", + "internalType": "contract ISystemConfig", "name": "", "type": "address" } diff --git a/packages/contracts-bedrock/snapshots/abi/OptimismPortalInterop.json b/packages/contracts-bedrock/snapshots/abi/OptimismPortalInterop.json index 4d9979bee344..5b9f72b9446c 100644 --- a/packages/contracts-bedrock/snapshots/abi/OptimismPortalInterop.json +++ b/packages/contracts-bedrock/snapshots/abi/OptimismPortalInterop.json @@ -158,7 +158,7 @@ "name": "disputeGameFactory", "outputs": [ { - "internalType": "contract DisputeGameFactory", + "internalType": "contract IDisputeGameFactory", "name": "", "type": "address" } @@ -316,17 +316,17 @@ { "inputs": [ { - "internalType": "contract DisputeGameFactory", + "internalType": "contract IDisputeGameFactory", "name": "_disputeGameFactory", "type": "address" }, { - "internalType": "contract SystemConfig", + "internalType": "contract ISystemConfig", "name": "_systemConfig", "type": "address" }, { - "internalType": "contract SuperchainConfig", + "internalType": "contract ISuperchainConfig", "name": "_superchainConfig", "type": "address" }, @@ -666,7 +666,7 @@ "name": "superchainConfig", "outputs": [ { - "internalType": "contract SuperchainConfig", + "internalType": "contract ISuperchainConfig", "name": "", "type": "address" } @@ -679,7 +679,7 @@ "name": "systemConfig", "outputs": [ { - "internalType": "contract SystemConfig", + "internalType": "contract ISystemConfig", "name": "", "type": "address" } @@ -949,11 +949,6 @@ "name": "Unauthorized", "type": "error" }, - { - "inputs": [], - "name": "Unauthorized", - "type": "error" - }, { "inputs": [], "name": "UnexpectedList", diff --git a/packages/contracts-bedrock/snapshots/abi/SystemConfig.json b/packages/contracts-bedrock/snapshots/abi/SystemConfig.json index 4b4ddd6c70a1..695231b9b119 100644 --- a/packages/contracts-bedrock/snapshots/abi/SystemConfig.json +++ b/packages/contracts-bedrock/snapshots/abi/SystemConfig.json @@ -321,7 +321,7 @@ "type": "uint128" } ], - "internalType": "struct ResourceMetering.ResourceConfig", + "internalType": "struct IResourceMetering.ResourceConfig", "name": "_config", "type": "tuple" }, @@ -552,7 +552,7 @@ "type": "uint128" } ], - "internalType": "struct ResourceMetering.ResourceConfig", + "internalType": "struct IResourceMetering.ResourceConfig", "name": "", "type": "tuple" } diff --git a/packages/contracts-bedrock/snapshots/abi/SystemConfigInterop.json b/packages/contracts-bedrock/snapshots/abi/SystemConfigInterop.json index b32316ec9e42..64f72945615b 100644 --- a/packages/contracts-bedrock/snapshots/abi/SystemConfigInterop.json +++ b/packages/contracts-bedrock/snapshots/abi/SystemConfigInterop.json @@ -342,7 +342,7 @@ "type": "uint128" } ], - "internalType": "struct ResourceMetering.ResourceConfig", + "internalType": "struct IResourceMetering.ResourceConfig", "name": "_config", "type": "tuple" }, @@ -469,7 +469,7 @@ "type": "uint128" } ], - "internalType": "struct ResourceMetering.ResourceConfig", + "internalType": "struct IResourceMetering.ResourceConfig", "name": "_config", "type": "tuple" }, @@ -713,7 +713,7 @@ "type": "uint128" } ], - "internalType": "struct ResourceMetering.ResourceConfig", + "internalType": "struct IResourceMetering.ResourceConfig", "name": "", "type": "tuple" } diff --git a/packages/contracts-bedrock/snapshots/storageLayout/AnchorStateRegistry.json b/packages/contracts-bedrock/snapshots/storageLayout/AnchorStateRegistry.json index 3511e68eb879..3900f4552584 100644 --- a/packages/contracts-bedrock/snapshots/storageLayout/AnchorStateRegistry.json +++ b/packages/contracts-bedrock/snapshots/storageLayout/AnchorStateRegistry.json @@ -25,6 +25,6 @@ "label": "superchainConfig", "offset": 0, "slot": "2", - "type": "contract SuperchainConfig" + "type": "contract ISuperchainConfig" } ] \ No newline at end of file diff --git a/packages/contracts-bedrock/snapshots/storageLayout/DelayedWETH.json b/packages/contracts-bedrock/snapshots/storageLayout/DelayedWETH.json index efc43f45893c..b20b276476e9 100644 --- a/packages/contracts-bedrock/snapshots/storageLayout/DelayedWETH.json +++ b/packages/contracts-bedrock/snapshots/storageLayout/DelayedWETH.json @@ -60,6 +60,6 @@ "label": "config", "offset": 0, "slot": "104", - "type": "contract SuperchainConfig" + "type": "contract ISuperchainConfig" } ] \ No newline at end of file diff --git a/packages/contracts-bedrock/snapshots/storageLayout/L1CrossDomainMessenger.json b/packages/contracts-bedrock/snapshots/storageLayout/L1CrossDomainMessenger.json index 5c88be3ca9ae..c68ec541baba 100644 --- a/packages/contracts-bedrock/snapshots/storageLayout/L1CrossDomainMessenger.json +++ b/packages/contracts-bedrock/snapshots/storageLayout/L1CrossDomainMessenger.json @@ -130,20 +130,20 @@ "label": "superchainConfig", "offset": 0, "slot": "251", - "type": "contract SuperchainConfig" + "type": "contract ISuperchainConfig" }, { "bytes": "20", "label": "portal", "offset": 0, "slot": "252", - "type": "contract OptimismPortal" + "type": "contract IOptimismPortal" }, { "bytes": "20", "label": "systemConfig", "offset": 0, "slot": "253", - "type": "contract SystemConfig" + "type": "contract ISystemConfig" } ] \ No newline at end of file diff --git a/packages/contracts-bedrock/snapshots/storageLayout/L1ERC721Bridge.json b/packages/contracts-bedrock/snapshots/storageLayout/L1ERC721Bridge.json index b08068ee9aeb..2c14ad25904b 100644 --- a/packages/contracts-bedrock/snapshots/storageLayout/L1ERC721Bridge.json +++ b/packages/contracts-bedrock/snapshots/storageLayout/L1ERC721Bridge.json @@ -25,7 +25,7 @@ "label": "messenger", "offset": 0, "slot": "1", - "type": "contract CrossDomainMessenger" + "type": "contract ICrossDomainMessenger" }, { "bytes": "20", @@ -53,6 +53,6 @@ "label": "superchainConfig", "offset": 0, "slot": "50", - "type": "contract SuperchainConfig" + "type": "contract ISuperchainConfig" } ] \ No newline at end of file diff --git a/packages/contracts-bedrock/snapshots/storageLayout/L1StandardBridge.json b/packages/contracts-bedrock/snapshots/storageLayout/L1StandardBridge.json index 1ed5eac5d183..5562a214e4fe 100644 --- a/packages/contracts-bedrock/snapshots/storageLayout/L1StandardBridge.json +++ b/packages/contracts-bedrock/snapshots/storageLayout/L1StandardBridge.json @@ -39,7 +39,7 @@ "label": "messenger", "offset": 0, "slot": "3", - "type": "contract CrossDomainMessenger" + "type": "contract ICrossDomainMessenger" }, { "bytes": "20", @@ -60,13 +60,13 @@ "label": "superchainConfig", "offset": 0, "slot": "50", - "type": "contract SuperchainConfig" + "type": "contract ISuperchainConfig" }, { "bytes": "20", "label": "systemConfig", "offset": 0, "slot": "51", - "type": "contract SystemConfig" + "type": "contract ISystemConfig" } ] \ No newline at end of file diff --git a/packages/contracts-bedrock/snapshots/storageLayout/L2ERC721Bridge.json b/packages/contracts-bedrock/snapshots/storageLayout/L2ERC721Bridge.json index e9facc6579e6..546b37ba6398 100644 --- a/packages/contracts-bedrock/snapshots/storageLayout/L2ERC721Bridge.json +++ b/packages/contracts-bedrock/snapshots/storageLayout/L2ERC721Bridge.json @@ -25,7 +25,7 @@ "label": "messenger", "offset": 0, "slot": "1", - "type": "contract CrossDomainMessenger" + "type": "contract ICrossDomainMessenger" }, { "bytes": "20", diff --git a/packages/contracts-bedrock/snapshots/storageLayout/L2StandardBridge.json b/packages/contracts-bedrock/snapshots/storageLayout/L2StandardBridge.json index f5effc6ae799..c6ccc0fc2e03 100644 --- a/packages/contracts-bedrock/snapshots/storageLayout/L2StandardBridge.json +++ b/packages/contracts-bedrock/snapshots/storageLayout/L2StandardBridge.json @@ -39,7 +39,7 @@ "label": "messenger", "offset": 0, "slot": "3", - "type": "contract CrossDomainMessenger" + "type": "contract ICrossDomainMessenger" }, { "bytes": "20", diff --git a/packages/contracts-bedrock/snapshots/storageLayout/L2StandardBridgeInterop.json b/packages/contracts-bedrock/snapshots/storageLayout/L2StandardBridgeInterop.json index f5effc6ae799..c6ccc0fc2e03 100644 --- a/packages/contracts-bedrock/snapshots/storageLayout/L2StandardBridgeInterop.json +++ b/packages/contracts-bedrock/snapshots/storageLayout/L2StandardBridgeInterop.json @@ -39,7 +39,7 @@ "label": "messenger", "offset": 0, "slot": "3", - "type": "contract CrossDomainMessenger" + "type": "contract ICrossDomainMessenger" }, { "bytes": "20", diff --git a/packages/contracts-bedrock/snapshots/storageLayout/OptimismPortal.json b/packages/contracts-bedrock/snapshots/storageLayout/OptimismPortal.json index 3795f987b280..d129ef1b87e3 100644 --- a/packages/contracts-bedrock/snapshots/storageLayout/OptimismPortal.json +++ b/packages/contracts-bedrock/snapshots/storageLayout/OptimismPortal.json @@ -60,7 +60,7 @@ "label": "superchainConfig", "offset": 1, "slot": "53", - "type": "contract SuperchainConfig" + "type": "contract ISuperchainConfig" }, { "bytes": "20", @@ -74,7 +74,7 @@ "label": "systemConfig", "offset": 0, "slot": "55", - "type": "contract SystemConfig" + "type": "contract ISystemConfig" }, { "bytes": "20", diff --git a/packages/contracts-bedrock/snapshots/storageLayout/OptimismPortal2.json b/packages/contracts-bedrock/snapshots/storageLayout/OptimismPortal2.json index 807e966b6edd..0fdd65b3e88f 100644 --- a/packages/contracts-bedrock/snapshots/storageLayout/OptimismPortal2.json +++ b/packages/contracts-bedrock/snapshots/storageLayout/OptimismPortal2.json @@ -60,7 +60,7 @@ "label": "superchainConfig", "offset": 1, "slot": "53", - "type": "contract SuperchainConfig" + "type": "contract ISuperchainConfig" }, { "bytes": "20", @@ -74,14 +74,14 @@ "label": "systemConfig", "offset": 0, "slot": "55", - "type": "contract SystemConfig" + "type": "contract ISystemConfig" }, { "bytes": "20", "label": "disputeGameFactory", "offset": 0, "slot": "56", - "type": "contract DisputeGameFactory" + "type": "contract IDisputeGameFactory" }, { "bytes": "32", diff --git a/packages/contracts-bedrock/snapshots/storageLayout/OptimismPortalInterop.json b/packages/contracts-bedrock/snapshots/storageLayout/OptimismPortalInterop.json index 807e966b6edd..0fdd65b3e88f 100644 --- a/packages/contracts-bedrock/snapshots/storageLayout/OptimismPortalInterop.json +++ b/packages/contracts-bedrock/snapshots/storageLayout/OptimismPortalInterop.json @@ -60,7 +60,7 @@ "label": "superchainConfig", "offset": 1, "slot": "53", - "type": "contract SuperchainConfig" + "type": "contract ISuperchainConfig" }, { "bytes": "20", @@ -74,14 +74,14 @@ "label": "systemConfig", "offset": 0, "slot": "55", - "type": "contract SystemConfig" + "type": "contract ISystemConfig" }, { "bytes": "20", "label": "disputeGameFactory", "offset": 0, "slot": "56", - "type": "contract DisputeGameFactory" + "type": "contract IDisputeGameFactory" }, { "bytes": "32", diff --git a/packages/contracts-bedrock/snapshots/storageLayout/SystemConfig.json b/packages/contracts-bedrock/snapshots/storageLayout/SystemConfig.json index 648245156248..b0946e1bc4db 100644 --- a/packages/contracts-bedrock/snapshots/storageLayout/SystemConfig.json +++ b/packages/contracts-bedrock/snapshots/storageLayout/SystemConfig.json @@ -81,6 +81,6 @@ "label": "_resourceConfig", "offset": 0, "slot": "105", - "type": "struct ResourceMetering.ResourceConfig" + "type": "struct IResourceMetering.ResourceConfig" } ] \ No newline at end of file diff --git a/packages/contracts-bedrock/snapshots/storageLayout/SystemConfigInterop.json b/packages/contracts-bedrock/snapshots/storageLayout/SystemConfigInterop.json index 648245156248..b0946e1bc4db 100644 --- a/packages/contracts-bedrock/snapshots/storageLayout/SystemConfigInterop.json +++ b/packages/contracts-bedrock/snapshots/storageLayout/SystemConfigInterop.json @@ -81,6 +81,6 @@ "label": "_resourceConfig", "offset": 0, "slot": "105", - "type": "struct ResourceMetering.ResourceConfig" + "type": "struct IResourceMetering.ResourceConfig" } ] \ No newline at end of file diff --git a/packages/contracts-bedrock/src/L1/DataAvailabilityChallenge.sol b/packages/contracts-bedrock/src/L1/DataAvailabilityChallenge.sol index fa45c47b2d09..1bb0d1bf6680 100644 --- a/packages/contracts-bedrock/src/L1/DataAvailabilityChallenge.sol +++ b/packages/contracts-bedrock/src/L1/DataAvailabilityChallenge.sol @@ -1,10 +1,15 @@ // SPDX-License-Identifier: MIT pragma solidity 0.8.15; +// Contracts import { OwnableUpgradeable } from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; -import { ISemver } from "src/universal/interfaces/ISemver.sol"; + +// Libraries import { SafeCall } from "src/libraries/SafeCall.sol"; +// Interfaces +import { ISemver } from "src/universal/interfaces/ISemver.sol"; + /// @dev An enum representing the status of a DA challenge. enum ChallengeStatus { Uninitialized, diff --git a/packages/contracts-bedrock/src/L1/DelayedVetoable.sol b/packages/contracts-bedrock/src/L1/DelayedVetoable.sol index 113f8a03bea2..ad45b4c9b20a 100644 --- a/packages/contracts-bedrock/src/L1/DelayedVetoable.sol +++ b/packages/contracts-bedrock/src/L1/DelayedVetoable.sol @@ -1,6 +1,7 @@ // SPDX-License-Identifier: MIT pragma solidity 0.8.15; +// Interfaces import { ISemver } from "src/universal/interfaces/ISemver.sol"; /// @title DelayedVetoable diff --git a/packages/contracts-bedrock/src/L1/L1CrossDomainMessenger.sol b/packages/contracts-bedrock/src/L1/L1CrossDomainMessenger.sol index 56d8218ac08c..8df4d9bfe765 100644 --- a/packages/contracts-bedrock/src/L1/L1CrossDomainMessenger.sol +++ b/packages/contracts-bedrock/src/L1/L1CrossDomainMessenger.sol @@ -1,12 +1,17 @@ // SPDX-License-Identifier: MIT pragma solidity 0.8.15; -import { Predeploys } from "src/libraries/Predeploys.sol"; -import { OptimismPortal } from "src/L1/OptimismPortal.sol"; +// Contracts import { CrossDomainMessenger } from "src/universal/CrossDomainMessenger.sol"; + +// Libraries +import { Predeploys } from "src/libraries/Predeploys.sol"; + +// Interfaces import { ISemver } from "src/universal/interfaces/ISemver.sol"; -import { SuperchainConfig } from "src/L1/SuperchainConfig.sol"; -import { SystemConfig } from "src/L1/SystemConfig.sol"; +import { ISuperchainConfig } from "src/L1/interfaces/ISuperchainConfig.sol"; +import { ISystemConfig } from "src/L1/interfaces/ISystemConfig.sol"; +import { IOptimismPortal } from "src/L1/interfaces/IOptimismPortal.sol"; /// @custom:proxied true /// @title L1CrossDomainMessenger @@ -15,14 +20,14 @@ import { SystemConfig } from "src/L1/SystemConfig.sol"; /// interface instead of interacting with lower-level contracts directly. contract L1CrossDomainMessenger is CrossDomainMessenger, ISemver { /// @notice Contract of the SuperchainConfig. - SuperchainConfig public superchainConfig; + ISuperchainConfig public superchainConfig; /// @notice Contract of the OptimismPortal. /// @custom:network-specific - OptimismPortal public portal; + IOptimismPortal public portal; /// @notice Address of the SystemConfig contract. - SystemConfig public systemConfig; + ISystemConfig public systemConfig; /// @notice Semantic version. /// @custom:semver 2.4.1-beta.1 @@ -31,9 +36,9 @@ contract L1CrossDomainMessenger is CrossDomainMessenger, ISemver { /// @notice Constructs the L1CrossDomainMessenger contract. constructor() CrossDomainMessenger() { initialize({ - _superchainConfig: SuperchainConfig(address(0)), - _portal: OptimismPortal(payable(address(0))), - _systemConfig: SystemConfig(address(0)) + _superchainConfig: ISuperchainConfig(address(0)), + _portal: IOptimismPortal(payable(address(0))), + _systemConfig: ISystemConfig(address(0)) }); } @@ -42,9 +47,9 @@ contract L1CrossDomainMessenger is CrossDomainMessenger, ISemver { /// @param _portal Contract of the OptimismPortal contract on this network. /// @param _systemConfig Contract of the SystemConfig contract on this network. function initialize( - SuperchainConfig _superchainConfig, - OptimismPortal _portal, - SystemConfig _systemConfig + ISuperchainConfig _superchainConfig, + IOptimismPortal _portal, + ISystemConfig _systemConfig ) public initializer @@ -64,7 +69,7 @@ contract L1CrossDomainMessenger is CrossDomainMessenger, ISemver { /// Public getter is legacy and will be removed in the future. Use `portal()` instead. /// @return Contract of the OptimismPortal on this chain. /// @custom:legacy - function PORTAL() external view returns (OptimismPortal) { + function PORTAL() external view returns (IOptimismPortal) { return portal; } diff --git a/packages/contracts-bedrock/src/L1/L1ERC721Bridge.sol b/packages/contracts-bedrock/src/L1/L1ERC721Bridge.sol index 014a501f58c9..04ea2a6cc82e 100644 --- a/packages/contracts-bedrock/src/L1/L1ERC721Bridge.sol +++ b/packages/contracts-bedrock/src/L1/L1ERC721Bridge.sol @@ -1,15 +1,19 @@ // SPDX-License-Identifier: MIT pragma solidity 0.8.15; +// Contracts import { ERC721Bridge } from "src/universal/ERC721Bridge.sol"; -import { IERC721 } from "@openzeppelin/contracts/token/ERC721/IERC721.sol"; import { L2ERC721Bridge } from "src/L2/L2ERC721Bridge.sol"; -import { ISemver } from "src/universal/interfaces/ISemver.sol"; + +// Libraries import { Predeploys } from "src/libraries/Predeploys.sol"; -import { CrossDomainMessenger } from "src/universal/CrossDomainMessenger.sol"; -import { StandardBridge } from "src/universal/StandardBridge.sol"; import { Constants } from "src/libraries/Constants.sol"; -import { SuperchainConfig } from "src/L1/SuperchainConfig.sol"; + +// Interfaces +import { IERC721 } from "@openzeppelin/contracts/token/ERC721/IERC721.sol"; +import { ISemver } from "src/universal/interfaces/ISemver.sol"; +import { ICrossDomainMessenger } from "src/universal/interfaces/ICrossDomainMessenger.sol"; +import { ISuperchainConfig } from "src/L1/interfaces/ISuperchainConfig.sol"; /// @custom:proxied true /// @title L1ERC721Bridge @@ -22,7 +26,7 @@ contract L1ERC721Bridge is ERC721Bridge, ISemver { mapping(address => mapping(address => mapping(uint256 => bool))) public deposits; /// @notice Address of the SuperchainConfig contract. - SuperchainConfig public superchainConfig; + ISuperchainConfig public superchainConfig; /// @notice Semantic version. /// @custom:semver 2.1.1-beta.2 @@ -30,13 +34,13 @@ contract L1ERC721Bridge is ERC721Bridge, ISemver { /// @notice Constructs the L1ERC721Bridge contract. constructor() ERC721Bridge() { - initialize({ _messenger: CrossDomainMessenger(address(0)), _superchainConfig: SuperchainConfig(address(0)) }); + initialize({ _messenger: ICrossDomainMessenger(address(0)), _superchainConfig: ISuperchainConfig(address(0)) }); } /// @notice Initializes the contract. /// @param _messenger Contract of the CrossDomainMessenger on this network. /// @param _superchainConfig Contract of the SuperchainConfig contract on this network. - function initialize(CrossDomainMessenger _messenger, SuperchainConfig _superchainConfig) public initializer { + function initialize(ICrossDomainMessenger _messenger, ISuperchainConfig _superchainConfig) public initializer { superchainConfig = _superchainConfig; __ERC721Bridge_init({ _messenger: _messenger, _otherBridge: ERC721Bridge(payable(Predeploys.L2_ERC721_BRIDGE)) }); } diff --git a/packages/contracts-bedrock/src/L1/L1StandardBridge.sol b/packages/contracts-bedrock/src/L1/L1StandardBridge.sol index 107be4851e1e..6dd648f0d541 100644 --- a/packages/contracts-bedrock/src/L1/L1StandardBridge.sol +++ b/packages/contracts-bedrock/src/L1/L1StandardBridge.sol @@ -1,13 +1,17 @@ // SPDX-License-Identifier: MIT pragma solidity 0.8.15; -import { Predeploys } from "src/libraries/Predeploys.sol"; +// Contracts import { StandardBridge } from "src/universal/StandardBridge.sol"; + +// Libraries +import { Predeploys } from "src/libraries/Predeploys.sol"; + +// Interfaces import { ISemver } from "src/universal/interfaces/ISemver.sol"; -import { CrossDomainMessenger } from "src/universal/CrossDomainMessenger.sol"; -import { SuperchainConfig } from "src/L1/SuperchainConfig.sol"; -import { OptimismPortal } from "src/L1/OptimismPortal.sol"; -import { SystemConfig } from "src/L1/SystemConfig.sol"; +import { ICrossDomainMessenger } from "src/universal/interfaces/ICrossDomainMessenger.sol"; +import { ISuperchainConfig } from "src/L1/interfaces/ISuperchainConfig.sol"; +import { ISystemConfig } from "src/L1/interfaces/ISystemConfig.sol"; /// @custom:proxied true /// @title L1StandardBridge @@ -75,17 +79,17 @@ contract L1StandardBridge is StandardBridge, ISemver { string public constant version = "2.2.1-beta.1"; /// @notice Address of the SuperchainConfig contract. - SuperchainConfig public superchainConfig; + ISuperchainConfig public superchainConfig; /// @notice Address of the SystemConfig contract. - SystemConfig public systemConfig; + ISystemConfig public systemConfig; /// @notice Constructs the L1StandardBridge contract. constructor() StandardBridge() { initialize({ - _messenger: CrossDomainMessenger(address(0)), - _superchainConfig: SuperchainConfig(address(0)), - _systemConfig: SystemConfig(address(0)) + _messenger: ICrossDomainMessenger(address(0)), + _superchainConfig: ISuperchainConfig(address(0)), + _systemConfig: ISystemConfig(address(0)) }); } @@ -93,9 +97,9 @@ contract L1StandardBridge is StandardBridge, ISemver { /// @param _messenger Contract for the CrossDomainMessenger on this network. /// @param _superchainConfig Contract for the SuperchainConfig on this network. function initialize( - CrossDomainMessenger _messenger, - SuperchainConfig _superchainConfig, - SystemConfig _systemConfig + ICrossDomainMessenger _messenger, + ISuperchainConfig _superchainConfig, + ISystemConfig _systemConfig ) public initializer diff --git a/packages/contracts-bedrock/src/L1/OptimismPortal.sol b/packages/contracts-bedrock/src/L1/OptimismPortal.sol index 517131d400cc..24eaccf8cc47 100644 --- a/packages/contracts-bedrock/src/L1/OptimismPortal.sol +++ b/packages/contracts-bedrock/src/L1/OptimismPortal.sol @@ -1,24 +1,30 @@ // SPDX-License-Identifier: MIT pragma solidity 0.8.15; +// Contracts import { Initializable } from "@openzeppelin/contracts/proxy/utils/Initializable.sol"; +import { ResourceMetering } from "src/L1/ResourceMetering.sol"; +import { L1Block } from "src/L2/L1Block.sol"; + +// Libraries +import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import { SafeCall } from "src/libraries/SafeCall.sol"; -import { IL2OutputOracle } from "src/L1/interfaces/IL2OutputOracle.sol"; -import { SystemConfig } from "src/L1/SystemConfig.sol"; -import { SuperchainConfig } from "src/L1/SuperchainConfig.sol"; import { Constants } from "src/libraries/Constants.sol"; import { Types } from "src/libraries/Types.sol"; import { Hashing } from "src/libraries/Hashing.sol"; import { SecureMerkleTrie } from "src/libraries/trie/SecureMerkleTrie.sol"; -import { AddressAliasHelper } from "src/vendor/AddressAliasHelper.sol"; -import { ResourceMetering } from "src/L1/ResourceMetering.sol"; -import { ISemver } from "src/universal/interfaces/ISemver.sol"; -import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; -import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; -import { L1Block } from "src/L2/L1Block.sol"; import { Predeploys } from "src/libraries/Predeploys.sol"; +import { AddressAliasHelper } from "src/vendor/AddressAliasHelper.sol"; import "src/libraries/PortalErrors.sol"; +// Interfaces +import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; +import { IL2OutputOracle } from "src/L1/interfaces/IL2OutputOracle.sol"; +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 { ISemver } from "src/universal/interfaces/ISemver.sol"; + /// @custom:proxied true /// @title OptimismPortal /// @notice The OptimismPortal is a low-level contract responsible for passing messages between L1 @@ -64,7 +70,7 @@ contract OptimismPortal is Initializable, ResourceMetering, ISemver { bool private spacer_53_0_1; /// @notice Contract of the Superchain Config. - SuperchainConfig public superchainConfig; + ISuperchainConfig public superchainConfig; /// @notice Contract of the L2OutputOracle. /// @custom:network-specific @@ -72,7 +78,7 @@ contract OptimismPortal is Initializable, ResourceMetering, ISemver { /// @notice Contract of the SystemConfig. /// @custom:network-specific - SystemConfig public systemConfig; + ISystemConfig public systemConfig; /// @custom:spacer disputeGameFactory /// @notice Spacer for backwards compatibility. @@ -137,8 +143,8 @@ contract OptimismPortal is Initializable, ResourceMetering, ISemver { constructor() { initialize({ _l2Oracle: IL2OutputOracle(address(0)), - _systemConfig: SystemConfig(address(0)), - _superchainConfig: SuperchainConfig(address(0)) + _systemConfig: ISystemConfig(address(0)), + _superchainConfig: ISuperchainConfig(address(0)) }); } @@ -148,8 +154,8 @@ contract OptimismPortal is Initializable, ResourceMetering, ISemver { /// @param _superchainConfig Contract of the SuperchainConfig. function initialize( IL2OutputOracle _l2Oracle, - SystemConfig _systemConfig, - SuperchainConfig _superchainConfig + ISystemConfig _systemConfig, + ISuperchainConfig _superchainConfig ) public initializer @@ -222,8 +228,16 @@ contract OptimismPortal is Initializable, ResourceMetering, ISemver { /// Used internally by the ResourceMetering contract. /// The SystemConfig is the source of truth for the resource config. /// @return ResourceMetering ResourceConfig - function _resourceConfig() internal view override returns (ResourceMetering.ResourceConfig memory) { - return systemConfig.resourceConfig(); + function _resourceConfig() internal view override returns (ResourceConfig memory) { + IResourceMetering.ResourceConfig memory config = systemConfig.resourceConfig(); + return ResourceConfig({ + maxResourceLimit: config.maxResourceLimit, + elasticityMultiplier: config.elasticityMultiplier, + baseFeeMaxChangeDenominator: config.baseFeeMaxChangeDenominator, + minimumBaseFee: config.minimumBaseFee, + systemTxMaxGas: config.systemTxMaxGas, + maximumBaseFee: config.maximumBaseFee + }); } /// @notice Proves a withdrawal transaction. diff --git a/packages/contracts-bedrock/src/L1/OptimismPortal2.sol b/packages/contracts-bedrock/src/L1/OptimismPortal2.sol index ea1c4b602512..ad47652919c2 100644 --- a/packages/contracts-bedrock/src/L1/OptimismPortal2.sol +++ b/packages/contracts-bedrock/src/L1/OptimismPortal2.sol @@ -1,27 +1,32 @@ // SPDX-License-Identifier: MIT pragma solidity 0.8.15; +// Contracts import { Initializable } from "@openzeppelin/contracts/proxy/utils/Initializable.sol"; +import { ResourceMetering } from "src/L1/ResourceMetering.sol"; +import { L1Block } from "src/L2/L1Block.sol"; + +// Libraries +import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import { SafeCall } from "src/libraries/SafeCall.sol"; -import { DisputeGameFactory, IDisputeGame } from "src/dispute/DisputeGameFactory.sol"; -import { SystemConfig } from "src/L1/SystemConfig.sol"; -import { SuperchainConfig } from "src/L1/SuperchainConfig.sol"; import { Constants } from "src/libraries/Constants.sol"; import { Types } from "src/libraries/Types.sol"; import { Hashing } from "src/libraries/Hashing.sol"; import { SecureMerkleTrie } from "src/libraries/trie/SecureMerkleTrie.sol"; -import { AddressAliasHelper } from "src/vendor/AddressAliasHelper.sol"; -import { ResourceMetering } from "src/L1/ResourceMetering.sol"; -import { ISemver } from "src/universal/interfaces/ISemver.sol"; -import { Constants } from "src/libraries/Constants.sol"; -import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; -import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; -import { L1Block } from "src/L2/L1Block.sol"; import { Predeploys } from "src/libraries/Predeploys.sol"; - +import { AddressAliasHelper } from "src/vendor/AddressAliasHelper.sol"; import "src/libraries/PortalErrors.sol"; import "src/dispute/lib/Types.sol"; +// Interfaces +import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; +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 { IDisputeGameFactory } from "src/dispute/interfaces/IDisputeGameFactory.sol"; +import { IDisputeGame } from "src/dispute/interfaces/IDisputeGame.sol"; +import { ISemver } from "src/universal/interfaces/ISemver.sol"; + /// @custom:proxied true /// @title OptimismPortal2 /// @notice The OptimismPortal is a low-level contract responsible for passing messages between L1 @@ -74,7 +79,7 @@ contract OptimismPortal2 is Initializable, ResourceMetering, ISemver { bool private spacer_53_0_1; /// @notice Contract of the Superchain Config. - SuperchainConfig public superchainConfig; + ISuperchainConfig public superchainConfig; /// @custom:legacy /// @custom:spacer l2Oracle @@ -83,11 +88,11 @@ contract OptimismPortal2 is Initializable, ResourceMetering, ISemver { /// @notice Contract of the SystemConfig. /// @custom:network-specific - SystemConfig public systemConfig; + ISystemConfig public systemConfig; /// @notice Address of the DisputeGameFactory. /// @custom:network-specific - DisputeGameFactory public disputeGameFactory; + IDisputeGameFactory public disputeGameFactory; /// @notice A mapping of withdrawal hashes to proof submitters to `ProvenWithdrawal` data. mapping(bytes32 => mapping(address => ProvenWithdrawal)) public provenWithdrawals; @@ -164,9 +169,9 @@ contract OptimismPortal2 is Initializable, ResourceMetering, ISemver { DISPUTE_GAME_FINALITY_DELAY_SECONDS = _disputeGameFinalityDelaySeconds; initialize({ - _disputeGameFactory: DisputeGameFactory(address(0)), - _systemConfig: SystemConfig(address(0)), - _superchainConfig: SuperchainConfig(address(0)), + _disputeGameFactory: IDisputeGameFactory(address(0)), + _systemConfig: ISystemConfig(address(0)), + _superchainConfig: ISuperchainConfig(address(0)), _initialRespectedGameType: GameType.wrap(0) }); } @@ -176,9 +181,9 @@ contract OptimismPortal2 is Initializable, ResourceMetering, ISemver { /// @param _systemConfig Contract of the SystemConfig. /// @param _superchainConfig Contract of the SuperchainConfig. function initialize( - DisputeGameFactory _disputeGameFactory, - SystemConfig _systemConfig, - SuperchainConfig _superchainConfig, + IDisputeGameFactory _disputeGameFactory, + ISystemConfig _systemConfig, + ISuperchainConfig _superchainConfig, GameType _initialRespectedGameType ) public @@ -271,9 +276,12 @@ contract OptimismPortal2 is Initializable, ResourceMetering, ISemver { /// @notice Getter for the resource config. /// Used internally by the ResourceMetering contract. /// The SystemConfig is the source of truth for the resource config. - /// @return ResourceMetering ResourceConfig - function _resourceConfig() internal view override returns (ResourceMetering.ResourceConfig memory) { - return systemConfig.resourceConfig(); + /// @return config_ ResourceMetering ResourceConfig + function _resourceConfig() internal view override returns (ResourceMetering.ResourceConfig memory config_) { + IResourceMetering.ResourceConfig memory config = systemConfig.resourceConfig(); + assembly ("memory-safe") { + config_ := config + } } /// @notice Proves a withdrawal transaction. diff --git a/packages/contracts-bedrock/src/L1/OptimismPortalInterop.sol b/packages/contracts-bedrock/src/L1/OptimismPortalInterop.sol index ffbb1afefa5a..fd33c5286ebd 100644 --- a/packages/contracts-bedrock/src/L1/OptimismPortalInterop.sol +++ b/packages/contracts-bedrock/src/L1/OptimismPortalInterop.sol @@ -1,10 +1,14 @@ // SPDX-License-Identifier: MIT pragma solidity 0.8.15; +// Contracts import { OptimismPortal2 } from "src/L1/OptimismPortal2.sol"; import { L1BlockIsthmus, ConfigType } from "src/L2/L1BlockIsthmus.sol"; + +// Libraries import { Predeploys } from "src/libraries/Predeploys.sol"; import { Constants } from "src/libraries/Constants.sol"; +import "src/libraries/PortalErrors.sol"; /// @custom:proxied true /// @title OptimismPortalInterop @@ -12,9 +16,6 @@ import { Constants } from "src/libraries/Constants.sol"; /// and L2. Messages sent directly to the OptimismPortal have no form of replayability. /// Users are encouraged to use the L1CrossDomainMessenger for a higher-level interface. contract OptimismPortalInterop is OptimismPortal2 { - /// @notice Thrown when a non-depositor account attempts update static configuration. - error Unauthorized(); - constructor( uint256 _proofMaturityDelaySeconds, uint256 _disputeGameFinalityDelaySeconds diff --git a/packages/contracts-bedrock/src/L1/ResourceMetering.sol b/packages/contracts-bedrock/src/L1/ResourceMetering.sol index feeabe14ee17..196a1573d7e4 100644 --- a/packages/contracts-bedrock/src/L1/ResourceMetering.sol +++ b/packages/contracts-bedrock/src/L1/ResourceMetering.sol @@ -1,7 +1,10 @@ // SPDX-License-Identifier: MIT pragma solidity 0.8.15; +// Contracts import { Initializable } from "@openzeppelin/contracts/proxy/utils/Initializable.sol"; + +// Libraries import { Math } from "@openzeppelin/contracts/utils/math/Math.sol"; import { Burn } from "src/libraries/Burn.sol"; import { Arithmetic } from "src/libraries/Arithmetic.sol"; diff --git a/packages/contracts-bedrock/src/L1/SystemConfig.sol b/packages/contracts-bedrock/src/L1/SystemConfig.sol index d1dc30fb75ec..032cb3227984 100644 --- a/packages/contracts-bedrock/src/L1/SystemConfig.sol +++ b/packages/contracts-bedrock/src/L1/SystemConfig.sol @@ -1,14 +1,19 @@ // SPDX-License-Identifier: MIT pragma solidity 0.8.15; +// Contracts import { OwnableUpgradeable } from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; -import { ISemver } from "src/universal/interfaces/ISemver.sol"; -import { ResourceMetering } from "src/L1/ResourceMetering.sol"; +import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; + +// Libraries import { Storage } from "src/libraries/Storage.sol"; import { Constants } from "src/libraries/Constants.sol"; -import { OptimismPortal } from "src/L1/OptimismPortal.sol"; import { GasPayingToken, IGasToken } from "src/libraries/GasPayingToken.sol"; -import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; + +// Interfaces +import { ISemver } from "src/universal/interfaces/ISemver.sol"; +import { IOptimismPortal } from "src/L1/interfaces/IOptimismPortal.sol"; +import { IResourceMetering } from "src/L1/interfaces/IResourceMetering.sol"; /// @custom:proxied true /// @title SystemConfig @@ -116,7 +121,7 @@ contract SystemConfig is OwnableUpgradeable, ISemver, IGasToken { /// @notice The configuration for the deposit fee market. /// Used by the OptimismPortal to meter the cost of buying L2 gas on L1. /// Set as internal with a getter so that the struct is returned instead of a tuple. - ResourceMetering.ResourceConfig internal _resourceConfig; + IResourceMetering.ResourceConfig internal _resourceConfig; /// @notice Emitted when configuration is updated. /// @param version SystemConfig version. @@ -144,7 +149,7 @@ contract SystemConfig is OwnableUpgradeable, ISemver, IGasToken { _batcherHash: bytes32(0), _gasLimit: 1, _unsafeBlockSigner: address(0), - _config: ResourceMetering.ResourceConfig({ + _config: IResourceMetering.ResourceConfig({ maxResourceLimit: 1, elasticityMultiplier: 1, baseFeeMaxChangeDenominator: 2, @@ -184,7 +189,7 @@ contract SystemConfig is OwnableUpgradeable, ISemver, IGasToken { bytes32 _batcherHash, uint64 _gasLimit, address _unsafeBlockSigner, - ResourceMetering.ResourceConfig memory _config, + IResourceMetering.ResourceConfig memory _config, address _batchInbox, SystemConfig.Addresses memory _addresses ) @@ -318,7 +323,7 @@ contract SystemConfig is OwnableUpgradeable, ISemver, IGasToken { // Set the gas paying token in storage and in the OptimismPortal. GasPayingToken.set({ _token: _token, _decimals: GAS_PAYING_TOKEN_DECIMALS, _name: name, _symbol: symbol }); - OptimismPortal(payable(optimismPortal())).setGasPayingToken({ + IOptimismPortal(payable(optimismPortal())).setGasPayingToken({ _token: _token, _decimals: GAS_PAYING_TOKEN_DECIMALS, _name: name, @@ -433,7 +438,7 @@ contract SystemConfig is OwnableUpgradeable, ISemver, IGasToken { /// @notice A getter for the resource config. /// Ensures that the struct is returned instead of a tuple. /// @return ResourceConfig - function resourceConfig() external view returns (ResourceMetering.ResourceConfig memory) { + function resourceConfig() external view returns (IResourceMetering.ResourceConfig memory) { return _resourceConfig; } @@ -442,7 +447,7 @@ contract SystemConfig is OwnableUpgradeable, ISemver, IGasToken { /// In the future, this method may emit an event that the `op-node` picks up /// for when the resource config is changed. /// @param _config The new resource config. - function _setResourceConfig(ResourceMetering.ResourceConfig memory _config) internal { + function _setResourceConfig(IResourceMetering.ResourceConfig memory _config) internal { // Min base fee must be less than or equal to max base fee. require( _config.minimumBaseFee <= _config.maximumBaseFee, "SystemConfig: min base fee must be less than max base" diff --git a/packages/contracts-bedrock/src/L1/SystemConfigInterop.sol b/packages/contracts-bedrock/src/L1/SystemConfigInterop.sol index 0033bfa54fae..f948459f5e38 100644 --- a/packages/contracts-bedrock/src/L1/SystemConfigInterop.sol +++ b/packages/contracts-bedrock/src/L1/SystemConfigInterop.sol @@ -1,16 +1,21 @@ // SPDX-License-Identifier: MIT pragma solidity 0.8.15; -import { Constants } from "src/libraries/Constants.sol"; -import { OptimismPortalInterop as OptimismPortal } from "src/L1/OptimismPortalInterop.sol"; -import { GasPayingToken } from "src/libraries/GasPayingToken.sol"; +// Contracts import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; +import { IOptimismPortalInterop as IOptimismPortal } from "src/L1/interfaces/IOptimismPortalInterop.sol"; import { SystemConfig } from "src/L1/SystemConfig.sol"; import { ConfigType } from "src/L2/L1BlockIsthmus.sol"; + +// Libraries +import { Constants } from "src/libraries/Constants.sol"; +import { GasPayingToken } from "src/libraries/GasPayingToken.sol"; import { StaticConfig } from "src/libraries/StaticConfig.sol"; -import { ResourceMetering } from "src/L1/ResourceMetering.sol"; import { Storage } from "src/libraries/Storage.sol"; +// Interfaces +import { IResourceMetering } from "src/L1/interfaces/IResourceMetering.sol"; + /// @custom:proxied true /// @title SystemConfigInterop /// @notice The SystemConfig contract is used to manage configuration of an Optimism network. @@ -41,7 +46,7 @@ contract SystemConfigInterop is SystemConfig { bytes32 _batcherHash, uint64 _gasLimit, address _unsafeBlockSigner, - ResourceMetering.ResourceConfig memory _config, + IResourceMetering.ResourceConfig memory _config, address _batchInbox, SystemConfig.Addresses memory _addresses, address _dependencyManager @@ -85,7 +90,7 @@ contract SystemConfigInterop is SystemConfig { // Set the gas paying token in storage and in the OptimismPortal. GasPayingToken.set({ _token: _token, _decimals: GAS_PAYING_TOKEN_DECIMALS, _name: name, _symbol: symbol }); - OptimismPortal(payable(optimismPortal())).setConfig( + IOptimismPortal(payable(optimismPortal())).setConfig( ConfigType.SET_GAS_PAYING_TOKEN, StaticConfig.encodeSetGasPayingToken({ _token: _token, @@ -101,7 +106,7 @@ contract SystemConfigInterop is SystemConfig { /// @param _chainId Chain ID of chain to add. function addDependency(uint256 _chainId) external { require(msg.sender == dependencyManager(), "SystemConfig: caller is not the dependency manager"); - OptimismPortal(payable(optimismPortal())).setConfig( + IOptimismPortal(payable(optimismPortal())).setConfig( ConfigType.ADD_DEPENDENCY, StaticConfig.encodeAddDependency(_chainId) ); } @@ -110,7 +115,7 @@ contract SystemConfigInterop is SystemConfig { /// @param _chainId Chain ID of the chain to remove. function removeDependency(uint256 _chainId) external { require(msg.sender == dependencyManager(), "SystemConfig: caller is not the dependency manager"); - OptimismPortal(payable(optimismPortal())).setConfig( + IOptimismPortal(payable(optimismPortal())).setConfig( ConfigType.REMOVE_DEPENDENCY, StaticConfig.encodeRemoveDependency(_chainId) ); } diff --git a/packages/contracts-bedrock/src/L1/interfaces/IDataAvailabilityChallenge.sol b/packages/contracts-bedrock/src/L1/interfaces/IDataAvailabilityChallenge.sol new file mode 100644 index 000000000000..5d89c2dac19c --- /dev/null +++ b/packages/contracts-bedrock/src/L1/interfaces/IDataAvailabilityChallenge.sol @@ -0,0 +1,92 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +enum ChallengeStatus { + Uninitialized, + Active, + Resolved, + Expired +} + +enum CommitmentType { + Keccak256 +} + +struct Challenge { + address challenger; + uint256 lockedBond; + uint256 startBlock; + uint256 resolvedBlock; +} + +interface IDataAvailabilityChallenge { + error BondTooLow(uint256 balance, uint256 required); + error ChallengeExists(); + error ChallengeNotActive(); + error ChallengeNotExpired(); + error ChallengeWindowNotOpen(); + error InvalidCommitmentLength(uint8 commitmentType, uint256 expectedLength, uint256 actualLength); + error InvalidInputData(bytes providedDataCommitment, bytes expectedCommitment); + error InvalidResolverRefundPercentage(uint256 invalidResolverRefundPercentage); + error UnknownCommitmentType(uint8 commitmentType); + error WithdrawalFailed(); + + event BalanceChanged(address account, uint256 balance); + event ChallengeStatusChanged( + uint256 indexed challengedBlockNumber, bytes challengedCommitment, ChallengeStatus status + ); + event Initialized(uint8 version); + event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); + event RequiredBondSizeChanged(uint256 challengeWindow); + event ResolverRefundPercentageChanged(uint256 resolverRefundPercentage); + + receive() external payable; + + function balances(address) external view returns (uint256); + function bondSize() external view returns (uint256); + function challenge(uint256 challengedBlockNumber, bytes memory challengedCommitment) external payable; + function challengeWindow() external view returns (uint256); + function deposit() external payable; + function fixedResolutionCost() external view returns (uint256); + function getChallenge( + uint256 challengedBlockNumber, + bytes memory challengedCommitment + ) + external + view + returns (Challenge memory); + function getChallengeStatus( + uint256 challengedBlockNumber, + bytes memory challengedCommitment + ) + external + view + returns (ChallengeStatus); + function initialize( + address _owner, + uint256 _challengeWindow, + uint256 _resolveWindow, + uint256 _bondSize, + uint256 _resolverRefundPercentage + ) + external; + function owner() external view returns (address); + function renounceOwnership() external; + function resolve( + uint256 challengedBlockNumber, + bytes memory challengedCommitment, + bytes memory resolveData + ) + external; + function resolveWindow() external view returns (uint256); + function resolverRefundPercentage() external view returns (uint256); + function setBondSize(uint256 _bondSize) external; + function setResolverRefundPercentage(uint256 _resolverRefundPercentage) external; + function transferOwnership(address newOwner) external; + function unlockBond(uint256 challengedBlockNumber, bytes memory challengedCommitment) external; + function validateCommitment(bytes memory commitment) external pure; + function variableResolutionCost() external view returns (uint256); + function variableResolutionCostPrecision() external view returns (uint256); + function version() external view returns (string memory); + function withdraw() external; +} diff --git a/packages/contracts-bedrock/src/L1/interfaces/IDelayedVetoable.sol b/packages/contracts-bedrock/src/L1/interfaces/IDelayedVetoable.sol new file mode 100644 index 000000000000..08e7b30ca6a1 --- /dev/null +++ b/packages/contracts-bedrock/src/L1/interfaces/IDelayedVetoable.sol @@ -0,0 +1,21 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +interface IDelayedVetoable { + error ForwardingEarly(); + error Unauthorized(address expected, address actual); + + event DelayActivated(uint256 delay); + event Forwarded(bytes32 indexed callHash, bytes data); + event Initiated(bytes32 indexed callHash, bytes data); + event Vetoed(bytes32 indexed callHash, bytes data); + + fallback() external; + + function delay() external returns (uint256 delay_); + function initiator() external returns (address initiator_); + function queuedAt(bytes32 callHash) external returns (uint256 queuedAt_); + function target() external returns (address target_); + function version() external view returns (string memory); + function vetoer() external returns (address vetoer_); +} diff --git a/packages/contracts-bedrock/src/L1/interfaces/IL1CrossDomainMessenger.sol b/packages/contracts-bedrock/src/L1/interfaces/IL1CrossDomainMessenger.sol new file mode 100644 index 000000000000..85478cfa257b --- /dev/null +++ b/packages/contracts-bedrock/src/L1/interfaces/IL1CrossDomainMessenger.sol @@ -0,0 +1,53 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +import { ISuperchainConfig } from "src/L1/interfaces/ISuperchainConfig.sol"; +import { IOptimismPortal } from "src/L1/interfaces/IOptimismPortal.sol"; +import { ISystemConfig } from "src/L1/interfaces/ISystemConfig.sol"; + +interface IL1CrossDomainMessenger { + event FailedRelayedMessage(bytes32 indexed msgHash); + event Initialized(uint8 version); + event RelayedMessage(bytes32 indexed msgHash); + event SentMessage(address indexed target, address sender, bytes message, uint256 messageNonce, uint256 gasLimit); + event SentMessageExtension1(address indexed sender, uint256 value); + + function MESSAGE_VERSION() external view returns (uint16); + function MIN_GAS_CALLDATA_OVERHEAD() external view returns (uint64); + function MIN_GAS_DYNAMIC_OVERHEAD_DENOMINATOR() external view returns (uint64); + function MIN_GAS_DYNAMIC_OVERHEAD_NUMERATOR() external view returns (uint64); + function OTHER_MESSENGER() external view returns (address); + function PORTAL() external view returns (address); + function RELAY_CALL_OVERHEAD() external view returns (uint64); + function RELAY_CONSTANT_OVERHEAD() external view returns (uint64); + function RELAY_GAS_CHECK_BUFFER() external view returns (uint64); + function RELAY_RESERVED_GAS() external view returns (uint64); + function baseGas(bytes memory _message, uint32 _minGasLimit) external pure returns (uint64); + function failedMessages(bytes32) external view returns (bool); + function initialize( + ISuperchainConfig _superchainConfig, + IOptimismPortal _portal, + ISystemConfig _systemConfig + ) + external; + function messageNonce() external view returns (uint256); + function otherMessenger() external view returns (address); + function paused() external view returns (bool); + function portal() external view returns (address); + function relayMessage( + uint256 _nonce, + address _sender, + address _target, + uint256 _value, + uint256 _minGasLimit, + bytes memory _message + ) + external + payable; + function sendMessage(address _target, bytes memory _message, uint32 _minGasLimit) external payable; + function successfulMessages(bytes32) external view returns (bool); + function superchainConfig() external view returns (address); + function systemConfig() external view returns (address); + function version() external view returns (string memory); + function xDomainMessageSender() external view returns (address); +} diff --git a/packages/contracts-bedrock/src/L1/interfaces/IOptimismPortal.sol b/packages/contracts-bedrock/src/L1/interfaces/IOptimismPortal.sol new file mode 100644 index 000000000000..e80bad00b910 --- /dev/null +++ b/packages/contracts-bedrock/src/L1/interfaces/IOptimismPortal.sol @@ -0,0 +1,85 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +import { Types } from "src/libraries/Types.sol"; +import { ISystemConfig } from "src/L1/interfaces/ISystemConfig.sol"; +import { ISuperchainConfig } from "src/L1/interfaces/ISuperchainConfig.sol"; +import { IL2OutputOracle } from "src/L1/interfaces/IL2OutputOracle.sol"; + +interface IOptimismPortal { + error BadTarget(); + error CallPaused(); + error ContentLengthMismatch(); + error EmptyItem(); + error GasEstimation(); + error InvalidDataRemainder(); + error InvalidHeader(); + error LargeCalldata(); + error NoValue(); + error NonReentrant(); + error OnlyCustomGasToken(); + error OutOfGas(); + error SmallGasLimit(); + error TransferFailed(); + error Unauthorized(); + error UnexpectedList(); + error UnexpectedString(); + + event Initialized(uint8 version); + event TransactionDeposited(address indexed from, address indexed to, uint256 indexed version, bytes opaqueData); + event WithdrawalFinalized(bytes32 indexed withdrawalHash, bool success); + event WithdrawalProven(bytes32 indexed withdrawalHash, address indexed from, address indexed to); + + receive() external payable; + + function balance() external view returns (uint256); + function depositERC20Transaction( + address _to, + uint256 _mint, + uint256 _value, + uint64 _gasLimit, + bool _isCreation, + bytes memory _data + ) + external; + function depositTransaction( + address _to, + uint256 _value, + uint64 _gasLimit, + bool _isCreation, + bytes memory _data + ) + external + payable; + function donateETH() external payable; + function finalizeWithdrawalTransaction(Types.WithdrawalTransaction memory _tx) external; + function finalizedWithdrawals(bytes32) external view returns (bool); + function guardian() external view returns (address); + function initialize( + IL2OutputOracle _l2Oracle, + ISystemConfig _systemConfig, + ISuperchainConfig _superchainConfig + ) + external; + function isOutputFinalized(uint256 _l2OutputIndex) external view returns (bool); + function l2Oracle() external view returns (IL2OutputOracle); + function l2Sender() external view returns (address); + function minimumGasLimit(uint64 _byteCount) external pure returns (uint64); + function params() external view returns (uint128 prevBaseFee, uint64 prevBoughtGas, uint64 prevBlockNum); + function paused() external view returns (bool paused_); + function proveWithdrawalTransaction( + Types.WithdrawalTransaction memory _tx, + uint256 _l2OutputIndex, + Types.OutputRootProof memory _outputRootProof, + bytes[] memory _withdrawalProof + ) + external; + function provenWithdrawals(bytes32) + external + view + returns (bytes32 outputRoot, uint128 timestamp, uint128 l2OutputIndex); + function setGasPayingToken(address _token, uint8 _decimals, bytes32 _name, bytes32 _symbol) external; + function superchainConfig() external view returns (ISuperchainConfig); + function systemConfig() external view returns (ISystemConfig); + function version() external pure returns (string memory); +} diff --git a/packages/contracts-bedrock/src/L1/interfaces/IOptimismPortal2.sol b/packages/contracts-bedrock/src/L1/interfaces/IOptimismPortal2.sol new file mode 100644 index 000000000000..2060b2088247 --- /dev/null +++ b/packages/contracts-bedrock/src/L1/interfaces/IOptimismPortal2.sol @@ -0,0 +1,116 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +import { Types } from "src/libraries/Types.sol"; +import { GameType, Timestamp } from "src/dispute/lib/LibUDT.sol"; +import { IDisputeGame } from "src/dispute/interfaces/IDisputeGame.sol"; +import { IDisputeGameFactory } from "src/dispute/interfaces/IDisputeGameFactory.sol"; +import { ISystemConfig } from "src/L1/interfaces/ISystemConfig.sol"; +import { ISuperchainConfig } from "src/L1/interfaces/ISuperchainConfig.sol"; + +interface IOptimismPortal2 { + error AlreadyFinalized(); + error BadTarget(); + error Blacklisted(); + error CallPaused(); + error ContentLengthMismatch(); + error EmptyItem(); + error GasEstimation(); + error InvalidDataRemainder(); + error InvalidDisputeGame(); + error InvalidGameType(); + error InvalidHeader(); + error InvalidMerkleProof(); + error InvalidProof(); + error LargeCalldata(); + error NoValue(); + error NonReentrant(); + error OnlyCustomGasToken(); + error OutOfGas(); + error ProposalNotValidated(); + error SmallGasLimit(); + error TransferFailed(); + error Unauthorized(); + error UnexpectedList(); + error UnexpectedString(); + error Unproven(); + + event DisputeGameBlacklisted(IDisputeGame indexed disputeGame); + event Initialized(uint8 version); + event RespectedGameTypeSet(GameType indexed newGameType, Timestamp indexed updatedAt); + event TransactionDeposited(address indexed from, address indexed to, uint256 indexed version, bytes opaqueData); + event WithdrawalFinalized(bytes32 indexed withdrawalHash, bool success); + event WithdrawalProven(bytes32 indexed withdrawalHash, address indexed from, address indexed to); + event WithdrawalProvenExtension1(bytes32 indexed withdrawalHash, address indexed proofSubmitter); + + receive() external payable; + + function balance() external view returns (uint256); + function blacklistDisputeGame(IDisputeGame _disputeGame) external; + function checkWithdrawal(bytes32 _withdrawalHash, address _proofSubmitter) external view; + function depositERC20Transaction( + address _to, + uint256 _mint, + uint256 _value, + uint64 _gasLimit, + bool _isCreation, + bytes memory _data + ) + external; + function depositTransaction( + address _to, + uint256 _value, + uint64 _gasLimit, + bool _isCreation, + bytes memory _data + ) + external + payable; + function disputeGameBlacklist(IDisputeGame) external view returns (bool); + function disputeGameFactory() external view returns (IDisputeGameFactory); + function disputeGameFinalityDelaySeconds() external view returns (uint256); + function donateETH() external payable; + function finalizeWithdrawalTransaction(Types.WithdrawalTransaction memory _tx) external; + function finalizeWithdrawalTransactionExternalProof( + Types.WithdrawalTransaction memory _tx, + address _proofSubmitter + ) + external; + function finalizedWithdrawals(bytes32) external view returns (bool); + function guardian() external view returns (address); + function initialize( + IDisputeGameFactory _disputeGameFactory, + ISystemConfig _systemConfig, + ISuperchainConfig _superchainConfig, + GameType _initialRespectedGameType + ) + external; + function l2Sender() external view returns (address); + function minimumGasLimit(uint64 _byteCount) external pure returns (uint64); + function numProofSubmitters(bytes32 _withdrawalHash) external view returns (uint256); + function params() external view returns (uint128 prevBaseFee, uint64 prevBoughtGas, uint64 prevBlockNum); + function paused() external view returns (bool); + function proofMaturityDelaySeconds() external view returns (uint256); + function proofSubmitters(bytes32, uint256) external view returns (address); + function proveWithdrawalTransaction( + Types.WithdrawalTransaction memory _tx, + uint256 _disputeGameIndex, + Types.OutputRootProof memory _outputRootProof, + bytes[] memory _withdrawalProof + ) + external; + function provenWithdrawals( + bytes32, + address + ) + external + view + returns (IDisputeGame disputeGameProxy, uint64 timestamp); + function respectedGameType() external view returns (GameType); + function respectedGameTypeUpdatedAt() external view returns (uint64); + function setGasPayingToken(address _token, uint8 _decimals, bytes32 _name, bytes32 _symbol) external; + function setRespectedGameType(GameType _gameType) external; + function superchainConfig() external view returns (ISuperchainConfig); + function systemConfig() external view returns (ISystemConfig); + function version() external pure returns (string memory); +} diff --git a/packages/contracts-bedrock/src/L1/interfaces/IOptimismPortalInterop.sol b/packages/contracts-bedrock/src/L1/interfaces/IOptimismPortalInterop.sol new file mode 100644 index 000000000000..0102b3462ed1 --- /dev/null +++ b/packages/contracts-bedrock/src/L1/interfaces/IOptimismPortalInterop.sol @@ -0,0 +1,118 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +import { Types } from "src/libraries/Types.sol"; +import { GameType, Timestamp } from "src/dispute/lib/LibUDT.sol"; +import { IDisputeGame } from "src/dispute/interfaces/IDisputeGame.sol"; +import { IDisputeGameFactory } from "src/dispute/interfaces/IDisputeGameFactory.sol"; +import { ISystemConfig } from "src/L1/interfaces/ISystemConfig.sol"; +import { ISuperchainConfig } from "src/L1/interfaces/ISuperchainConfig.sol"; +import { ConfigType } from "src/L2/L1BlockIsthmus.sol"; + +interface IOptimismPortalInterop { + error AlreadyFinalized(); + error BadTarget(); + error Blacklisted(); + error CallPaused(); + error ContentLengthMismatch(); + error EmptyItem(); + error GasEstimation(); + error InvalidDataRemainder(); + error InvalidDisputeGame(); + error InvalidGameType(); + error InvalidHeader(); + error InvalidMerkleProof(); + error InvalidProof(); + error LargeCalldata(); + error NoValue(); + error NonReentrant(); + error OnlyCustomGasToken(); + error OutOfGas(); + error ProposalNotValidated(); + error SmallGasLimit(); + error TransferFailed(); + error Unauthorized(); + error UnexpectedList(); + error UnexpectedString(); + error Unproven(); + + event DisputeGameBlacklisted(IDisputeGame indexed disputeGame); + event Initialized(uint8 version); + event RespectedGameTypeSet(GameType indexed newGameType, Timestamp indexed updatedAt); + event TransactionDeposited(address indexed from, address indexed to, uint256 indexed version, bytes opaqueData); + event WithdrawalFinalized(bytes32 indexed withdrawalHash, bool success); + event WithdrawalProven(bytes32 indexed withdrawalHash, address indexed from, address indexed to); + event WithdrawalProvenExtension1(bytes32 indexed withdrawalHash, address indexed proofSubmitter); + + receive() external payable; + + function balance() external view returns (uint256); + function blacklistDisputeGame(IDisputeGame _disputeGame) external; + function checkWithdrawal(bytes32 _withdrawalHash, address _proofSubmitter) external view; + function depositERC20Transaction( + address _to, + uint256 _mint, + uint256 _value, + uint64 _gasLimit, + bool _isCreation, + bytes memory _data + ) + external; + function depositTransaction( + address _to, + uint256 _value, + uint64 _gasLimit, + bool _isCreation, + bytes memory _data + ) + external + payable; + function disputeGameBlacklist(IDisputeGame) external view returns (bool); + function disputeGameFactory() external view returns (IDisputeGameFactory); + function disputeGameFinalityDelaySeconds() external view returns (uint256); + function donateETH() external payable; + function finalizeWithdrawalTransaction(Types.WithdrawalTransaction memory _tx) external; + function finalizeWithdrawalTransactionExternalProof( + Types.WithdrawalTransaction memory _tx, + address _proofSubmitter + ) + external; + function finalizedWithdrawals(bytes32) external view returns (bool); + function guardian() external view returns (address); + function initialize( + IDisputeGameFactory _disputeGameFactory, + ISystemConfig _systemConfig, + ISuperchainConfig _superchainConfig, + GameType _initialRespectedGameType + ) + external; + function l2Sender() external view returns (address); + function minimumGasLimit(uint64 _byteCount) external pure returns (uint64); + function numProofSubmitters(bytes32 _withdrawalHash) external view returns (uint256); + function params() external view returns (uint128 prevBaseFee, uint64 prevBoughtGas, uint64 prevBlockNum); + function paused() external view returns (bool); + function proofMaturityDelaySeconds() external view returns (uint256); + function proofSubmitters(bytes32, uint256) external view returns (address); + function proveWithdrawalTransaction( + Types.WithdrawalTransaction memory _tx, + uint256 _disputeGameIndex, + Types.OutputRootProof memory _outputRootProof, + bytes[] memory _withdrawalProof + ) + external; + function provenWithdrawals( + bytes32, + address + ) + external + view + returns (IDisputeGame disputeGameProxy, uint64 timestamp); + function respectedGameType() external view returns (GameType); + function respectedGameTypeUpdatedAt() external view returns (uint64); + function setConfig(ConfigType _type, bytes memory _value) external; + function setGasPayingToken(address _token, uint8 _decimals, bytes32 _name, bytes32 _symbol) external; + function setRespectedGameType(GameType _gameType) external; + function superchainConfig() external view returns (ISuperchainConfig); + function systemConfig() external view returns (ISystemConfig); + function version() external pure returns (string memory); +} diff --git a/packages/contracts-bedrock/src/L1/interfaces/IResourceMetering.sol b/packages/contracts-bedrock/src/L1/interfaces/IResourceMetering.sol new file mode 100644 index 000000000000..4a4ccc133bb8 --- /dev/null +++ b/packages/contracts-bedrock/src/L1/interfaces/IResourceMetering.sol @@ -0,0 +1,25 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +interface IResourceMetering { + struct ResourceParams { + uint128 prevBaseFee; + uint64 prevBoughtGas; + uint64 prevBlockNum; + } + + struct ResourceConfig { + uint32 maxResourceLimit; + uint8 elasticityMultiplier; + uint8 baseFeeMaxChangeDenominator; + uint32 minimumBaseFee; + uint32 systemTxMaxGas; + uint128 maximumBaseFee; + } + + error OutOfGas(); + + event Initialized(uint8 version); + + function params() external view returns (uint128 prevBaseFee, uint64 prevBoughtGas, uint64 prevBlockNum); +} diff --git a/packages/contracts-bedrock/src/L1/interfaces/ISuperchainConfig.sol b/packages/contracts-bedrock/src/L1/interfaces/ISuperchainConfig.sol new file mode 100644 index 000000000000..d30c0e074f59 --- /dev/null +++ b/packages/contracts-bedrock/src/L1/interfaces/ISuperchainConfig.sol @@ -0,0 +1,22 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +interface ISuperchainConfig { + enum UpdateType { + GUARDIAN + } + + event ConfigUpdate(UpdateType indexed updateType, bytes data); + event Initialized(uint8 version); + event Paused(string identifier); + event Unpaused(); + + function GUARDIAN_SLOT() external view returns (bytes32); + function PAUSED_SLOT() external view returns (bytes32); + function guardian() external view returns (address guardian_); + function initialize(address _guardian, bool _paused) external; + function pause(string memory _identifier) external; + function paused() external view returns (bool paused_); + function unpause() external; + function version() external view returns (string memory); +} diff --git a/packages/contracts-bedrock/src/L1/interfaces/ISystemConfig.sol b/packages/contracts-bedrock/src/L1/interfaces/ISystemConfig.sol new file mode 100644 index 000000000000..fa4a597df307 --- /dev/null +++ b/packages/contracts-bedrock/src/L1/interfaces/ISystemConfig.sol @@ -0,0 +1,81 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +import { IResourceMetering } from "src/L1/interfaces/IResourceMetering.sol"; + +interface ISystemConfig { + enum UpdateType { + BATCHER, + GAS_CONFIG, + GAS_LIMIT, + UNSAFE_BLOCK_SIGNER + } + + struct Addresses { + address l1CrossDomainMessenger; + address l1ERC721Bridge; + address l1StandardBridge; + address disputeGameFactory; + address optimismPortal; + address optimismMintableERC20Factory; + address gasPayingToken; + } + + event ConfigUpdate(uint256 indexed version, UpdateType indexed updateType, bytes data); + event Initialized(uint8 version); + event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); + + function BATCH_INBOX_SLOT() external view returns (bytes32); + function DISPUTE_GAME_FACTORY_SLOT() external view returns (bytes32); + function L1_CROSS_DOMAIN_MESSENGER_SLOT() external view returns (bytes32); + function L1_ERC_721_BRIDGE_SLOT() external view returns (bytes32); + function L1_STANDARD_BRIDGE_SLOT() external view returns (bytes32); + function OPTIMISM_MINTABLE_ERC20_FACTORY_SLOT() external view returns (bytes32); + function OPTIMISM_PORTAL_SLOT() external view returns (bytes32); + function START_BLOCK_SLOT() external view returns (bytes32); + function UNSAFE_BLOCK_SIGNER_SLOT() external view returns (bytes32); + function VERSION() external view returns (uint256); + function basefeeScalar() external view returns (uint32); + function batchInbox() external view returns (address addr_); + function batcherHash() external view returns (bytes32); + function blobbasefeeScalar() external view returns (uint32); + function disputeGameFactory() external view returns (address addr_); + function gasLimit() external view returns (uint64); + function gasPayingToken() external view returns (address addr_, uint8 decimals_); + function gasPayingTokenName() external view returns (string memory name_); + function gasPayingTokenSymbol() external view returns (string memory symbol_); + function initialize( + address _owner, + uint32 _basefeeScalar, + uint32 _blobbasefeeScalar, + bytes32 _batcherHash, + uint64 _gasLimit, + address _unsafeBlockSigner, + IResourceMetering.ResourceConfig memory _config, + address _batchInbox, + Addresses memory _addresses + ) + external; + function isCustomGasToken() external view returns (bool); + function l1CrossDomainMessenger() external view returns (address addr_); + function l1ERC721Bridge() external view returns (address addr_); + function l1StandardBridge() external view returns (address addr_); + function maximumGasLimit() external pure returns (uint64); + function minimumGasLimit() external view returns (uint64); + function optimismMintableERC20Factory() external view returns (address addr_); + function optimismPortal() external view returns (address addr_); + function overhead() external view returns (uint256); + function owner() external view returns (address); + function renounceOwnership() external; + function resourceConfig() external view returns (IResourceMetering.ResourceConfig memory); + function scalar() external view returns (uint256); + function setBatcherHash(bytes32 _batcherHash) external; + function setGasConfig(uint256 _overhead, uint256 _scalar) external; + function setGasConfigEcotone(uint32 _basefeeScalar, uint32 _blobbasefeeScalar) external; + function setGasLimit(uint64 _gasLimit) external; + function setUnsafeBlockSigner(address _unsafeBlockSigner) external; + function startBlock() external view returns (uint256 startBlock_); + function transferOwnership(address newOwner) external; + function unsafeBlockSigner() external view returns (address addr_); + function version() external pure returns (string memory); +} diff --git a/packages/contracts-bedrock/src/L2/L2ERC721Bridge.sol b/packages/contracts-bedrock/src/L2/L2ERC721Bridge.sol index 66fa24c3ef49..3ff30e8b7272 100644 --- a/packages/contracts-bedrock/src/L2/L2ERC721Bridge.sol +++ b/packages/contracts-bedrock/src/L2/L2ERC721Bridge.sol @@ -5,7 +5,7 @@ import { ERC721Bridge } from "src/universal/ERC721Bridge.sol"; import { ERC165Checker } from "@openzeppelin/contracts/utils/introspection/ERC165Checker.sol"; import { L1ERC721Bridge } from "src/L1/L1ERC721Bridge.sol"; import { IOptimismMintableERC721 } from "src/universal/interfaces/IOptimismMintableERC721.sol"; -import { CrossDomainMessenger } from "src/universal/CrossDomainMessenger.sol"; +import { ICrossDomainMessenger } from "src/universal/interfaces/ICrossDomainMessenger.sol"; import { ISemver } from "src/universal/interfaces/ISemver.sol"; import { Constants } from "src/libraries/Constants.sol"; import { Predeploys } from "src/libraries/Predeploys.sol"; @@ -34,7 +34,7 @@ contract L2ERC721Bridge is ERC721Bridge, ISemver { /// @param _l1ERC721Bridge Address of the ERC721 bridge contract on the other network. function initialize(address payable _l1ERC721Bridge) public initializer { __ERC721Bridge_init({ - _messenger: CrossDomainMessenger(Predeploys.L2_CROSS_DOMAIN_MESSENGER), + _messenger: ICrossDomainMessenger(Predeploys.L2_CROSS_DOMAIN_MESSENGER), _otherBridge: ERC721Bridge(_l1ERC721Bridge) }); } diff --git a/packages/contracts-bedrock/src/L2/L2StandardBridge.sol b/packages/contracts-bedrock/src/L2/L2StandardBridge.sol index 4ba8c62f863c..063ee398f770 100644 --- a/packages/contracts-bedrock/src/L2/L2StandardBridge.sol +++ b/packages/contracts-bedrock/src/L2/L2StandardBridge.sol @@ -5,7 +5,7 @@ import { Predeploys } from "src/libraries/Predeploys.sol"; import { StandardBridge } from "src/universal/StandardBridge.sol"; import { ISemver } from "src/universal/interfaces/ISemver.sol"; import { OptimismMintableERC20 } from "src/universal/OptimismMintableERC20.sol"; -import { CrossDomainMessenger } from "src/universal/CrossDomainMessenger.sol"; +import { ICrossDomainMessenger } from "src/universal/interfaces/ICrossDomainMessenger.sol"; import { L1Block } from "src/L2/L1Block.sol"; /// @custom:proxied true @@ -67,7 +67,7 @@ contract L2StandardBridge is StandardBridge, ISemver { /// @param _otherBridge Contract for the corresponding bridge on the other chain. function initialize(StandardBridge _otherBridge) public initializer { __StandardBridge_init({ - _messenger: CrossDomainMessenger(Predeploys.L2_CROSS_DOMAIN_MESSENGER), + _messenger: ICrossDomainMessenger(Predeploys.L2_CROSS_DOMAIN_MESSENGER), _otherBridge: _otherBridge }); } diff --git a/packages/contracts-bedrock/src/Safe/DeputyGuardianModule.sol b/packages/contracts-bedrock/src/Safe/DeputyGuardianModule.sol index abb3a7aaa9ca..c1ac18fdc0c1 100644 --- a/packages/contracts-bedrock/src/Safe/DeputyGuardianModule.sol +++ b/packages/contracts-bedrock/src/Safe/DeputyGuardianModule.sol @@ -1,19 +1,24 @@ // SPDX-License-Identifier: MIT pragma solidity 0.8.15; +// Safe import { GnosisSafe as Safe } from "safe-contracts/GnosisSafe.sol"; import { Enum } from "safe-contracts/common/Enum.sol"; -import { IFaultDisputeGame } from "src/dispute/interfaces/IFaultDisputeGame.sol"; -import { SuperchainConfig } from "src/L1/SuperchainConfig.sol"; -import { OptimismPortal2 } from "src/L1/OptimismPortal2.sol"; -import { IDisputeGame } from "src/dispute/interfaces/IDisputeGame.sol"; -import { ISemver } from "src/universal/interfaces/ISemver.sol"; -import { Unauthorized } from "src/libraries/PortalErrors.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 { IFaultDisputeGame } from "src/dispute/interfaces/IFaultDisputeGame.sol"; +import { ISuperchainConfig } from "src/L1/interfaces/ISuperchainConfig.sol"; +import { IOptimismPortal2 } from "src/L1/interfaces/IOptimismPortal2.sol"; +import { IDisputeGame } from "src/dispute/interfaces/IDisputeGame.sol"; +import { ISemver } from "src/universal/interfaces/ISemver.sol"; + /// @title DeputyGuardianModule /// @notice This module is intended to be enabled on the Security Council Safe, which will own the Guardian role in the /// SuperchainConfig contract. The DeputyGuardianModule should allow a Deputy Guardian to administer any of the @@ -39,7 +44,7 @@ contract DeputyGuardianModule is ISemver { Safe internal immutable SAFE; /// @notice The SuperchainConfig's address - SuperchainConfig internal immutable SUPERCHAIN_CONFIG; + ISuperchainConfig internal immutable SUPERCHAIN_CONFIG; /// @notice The deputy guardian's address address internal immutable DEPUTY_GUARDIAN; @@ -49,7 +54,7 @@ contract DeputyGuardianModule is ISemver { string public constant version = "2.0.1-beta.1"; // Constructor to initialize the Safe and baseModule instances - constructor(Safe _safe, SuperchainConfig _superchainConfig, address _deputyGuardian) { + constructor(Safe _safe, ISuperchainConfig _superchainConfig, address _deputyGuardian) { SAFE = _safe; SUPERCHAIN_CONFIG = _superchainConfig; DEPUTY_GUARDIAN = _deputyGuardian; @@ -63,7 +68,7 @@ contract DeputyGuardianModule is ISemver { /// @notice Getter function for the SuperchainConfig's address /// @return superchainConfig_ The SuperchainConfig's address - function superchainConfig() public view returns (SuperchainConfig superchainConfig_) { + function superchainConfig() public view returns (ISuperchainConfig superchainConfig_) { superchainConfig_ = SUPERCHAIN_CONFIG; } @@ -131,10 +136,10 @@ contract DeputyGuardianModule is ISemver { /// Only the deputy guardian can call this function. /// @param _portal The `OptimismPortal2` contract instance. /// @param _game The `IDisputeGame` contract instance. - function blacklistDisputeGame(OptimismPortal2 _portal, IDisputeGame _game) external { + function blacklistDisputeGame(IOptimismPortal2 _portal, IDisputeGame _game) external { _onlyDeputyGuardian(); - bytes memory data = abi.encodeCall(OptimismPortal2.blacklistDisputeGame, (_game)); + bytes memory data = abi.encodeCall(IOptimismPortal2.blacklistDisputeGame, (_game)); (bool success, bytes memory returnData) = SAFE.execTransactionFromModuleReturnData(address(_portal), 0, data, Enum.Operation.Call); if (!success) { @@ -148,10 +153,10 @@ contract DeputyGuardianModule is ISemver { /// Only the deputy guardian can call this function. /// @param _portal The `OptimismPortal2` contract instance. /// @param _gameType The `GameType` to set as the respected game type. - function setRespectedGameType(OptimismPortal2 _portal, GameType _gameType) external { + function setRespectedGameType(IOptimismPortal2 _portal, GameType _gameType) external { _onlyDeputyGuardian(); - bytes memory data = abi.encodeCall(OptimismPortal2.setRespectedGameType, (_gameType)); + bytes memory data = abi.encodeCall(IOptimismPortal2.setRespectedGameType, (_gameType)); (bool success, bytes memory returnData) = SAFE.execTransactionFromModuleReturnData(address(_portal), 0, data, Enum.Operation.Call); if (!success) { diff --git a/packages/contracts-bedrock/src/dispute/AnchorStateRegistry.sol b/packages/contracts-bedrock/src/dispute/AnchorStateRegistry.sol index 9ac81302991a..3425ec2e394b 100644 --- a/packages/contracts-bedrock/src/dispute/AnchorStateRegistry.sol +++ b/packages/contracts-bedrock/src/dispute/AnchorStateRegistry.sol @@ -8,7 +8,7 @@ import { IAnchorStateRegistry } from "src/dispute/interfaces/IAnchorStateRegistr 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 { SuperchainConfig } from "src/L1/SuperchainConfig.sol"; +import { ISuperchainConfig } from "src/L1/interfaces/ISuperchainConfig.sol"; import "src/dispute/lib/Types.sol"; import { Unauthorized } from "src/libraries/errors/CommonErrors.sol"; @@ -38,7 +38,7 @@ contract AnchorStateRegistry is Initializable, IAnchorStateRegistry, ISemver { mapping(GameType => OutputRoot) public anchors; /// @notice Address of the SuperchainConfig contract. - SuperchainConfig public superchainConfig; + ISuperchainConfig public superchainConfig; /// @param _disputeGameFactory DisputeGameFactory address. constructor(IDisputeGameFactory _disputeGameFactory) { @@ -51,7 +51,7 @@ contract AnchorStateRegistry is Initializable, IAnchorStateRegistry, ISemver { /// @param _superchainConfig The address of the SuperchainConfig contract. function initialize( StartingAnchorRoot[] memory _startingAnchorRoots, - SuperchainConfig _superchainConfig + ISuperchainConfig _superchainConfig ) public initializer diff --git a/packages/contracts-bedrock/src/dispute/weth/DelayedWETH.sol b/packages/contracts-bedrock/src/dispute/weth/DelayedWETH.sol index 144d8d451798..7945c7f51d5d 100644 --- a/packages/contracts-bedrock/src/dispute/weth/DelayedWETH.sol +++ b/packages/contracts-bedrock/src/dispute/weth/DelayedWETH.sol @@ -8,7 +8,7 @@ import { IDelayedWETH } from "src/dispute/interfaces/IDelayedWETH.sol"; import { IWETH } from "src/dispute/interfaces/IWETH.sol"; import { WETH98 } from "src/dispute/weth/WETH98.sol"; -import { SuperchainConfig } from "src/L1/SuperchainConfig.sol"; +import { ISuperchainConfig } from "src/L1/interfaces/ISuperchainConfig.sol"; /// @custom:proxied true /// @title DelayedWETH @@ -32,18 +32,18 @@ contract DelayedWETH is OwnableUpgradeable, WETH98, IDelayedWETH, ISemver { uint256 internal immutable DELAY_SECONDS; /// @notice Address of the SuperchainConfig contract. - SuperchainConfig public config; + ISuperchainConfig public config; /// @param _delay The delay for withdrawals in seconds. constructor(uint256 _delay) { DELAY_SECONDS = _delay; - initialize({ _owner: address(0), _config: SuperchainConfig(address(0)) }); + initialize({ _owner: address(0), _config: ISuperchainConfig(address(0)) }); } /// @notice Initializes the contract. /// @param _owner The address of the owner. /// @param _config Address of the SuperchainConfig contract. - function initialize(address _owner, SuperchainConfig _config) public initializer { + function initialize(address _owner, ISuperchainConfig _config) public initializer { __Ownable_init(); _transferOwnership(_owner); config = _config; diff --git a/packages/contracts-bedrock/src/libraries/Constants.sol b/packages/contracts-bedrock/src/libraries/Constants.sol index e86010421d34..1cbd61d21a5e 100644 --- a/packages/contracts-bedrock/src/libraries/Constants.sol +++ b/packages/contracts-bedrock/src/libraries/Constants.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; -import { ResourceMetering } from "src/L1/ResourceMetering.sol"; +import { IResourceMetering } from "src/L1/interfaces/IResourceMetering.sol"; /// @title Constants /// @notice Constants is a library for storing constants. Simple! Don't put everything in here, just @@ -39,8 +39,8 @@ library Constants { /// @notice Returns the default values for the ResourceConfig. These are the recommended values /// for a production network. - function DEFAULT_RESOURCE_CONFIG() internal pure returns (ResourceMetering.ResourceConfig memory) { - ResourceMetering.ResourceConfig memory config = ResourceMetering.ResourceConfig({ + function DEFAULT_RESOURCE_CONFIG() internal pure returns (IResourceMetering.ResourceConfig memory) { + IResourceMetering.ResourceConfig memory config = IResourceMetering.ResourceConfig({ maxResourceLimit: 20_000_000, elasticityMultiplier: 10, baseFeeMaxChangeDenominator: 8, diff --git a/packages/contracts-bedrock/src/universal/ERC721Bridge.sol b/packages/contracts-bedrock/src/universal/ERC721Bridge.sol index 9c5c325f7184..52217fab713c 100644 --- a/packages/contracts-bedrock/src/universal/ERC721Bridge.sol +++ b/packages/contracts-bedrock/src/universal/ERC721Bridge.sol @@ -1,8 +1,7 @@ // SPDX-License-Identifier: MIT pragma solidity 0.8.15; -import { CrossDomainMessenger } from "src/universal/CrossDomainMessenger.sol"; -import { SuperchainConfig } from "src/L1/SuperchainConfig.sol"; +import { ICrossDomainMessenger } from "src/universal/interfaces/ICrossDomainMessenger.sol"; import { Address } from "@openzeppelin/contracts/utils/Address.sol"; import { Initializable } from "@openzeppelin/contracts/proxy/utils/Initializable.sol"; @@ -15,7 +14,7 @@ abstract contract ERC721Bridge is Initializable { /// @notice Messenger contract on this domain. /// @custom:network-specific - CrossDomainMessenger public messenger; + ICrossDomainMessenger public messenger; /// @notice Contract of the bridge on the other network. /// @custom:network-specific @@ -69,7 +68,7 @@ abstract contract ERC721Bridge is Initializable { /// @param _messenger Contract of the CrossDomainMessenger on this network. /// @param _otherBridge Contract of the ERC721 bridge on the other network. function __ERC721Bridge_init( - CrossDomainMessenger _messenger, + ICrossDomainMessenger _messenger, ERC721Bridge _otherBridge ) internal @@ -83,7 +82,7 @@ abstract contract ERC721Bridge is Initializable { /// Public getter is legacy and will be removed in the future. Use `messenger` instead. /// @return Messenger contract on this domain. /// @custom:legacy - function MESSENGER() external view returns (CrossDomainMessenger) { + function MESSENGER() external view returns (ICrossDomainMessenger) { return messenger; } diff --git a/packages/contracts-bedrock/src/universal/StandardBridge.sol b/packages/contracts-bedrock/src/universal/StandardBridge.sol index 92440fdbad38..476d3ba54c93 100644 --- a/packages/contracts-bedrock/src/universal/StandardBridge.sol +++ b/packages/contracts-bedrock/src/universal/StandardBridge.sol @@ -7,7 +7,7 @@ import { Address } from "@openzeppelin/contracts/utils/Address.sol"; import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import { SafeCall } from "src/libraries/SafeCall.sol"; import { IOptimismMintableERC20, ILegacyMintableERC20 } from "src/universal/interfaces/IOptimismMintableERC20.sol"; -import { CrossDomainMessenger } from "src/universal/CrossDomainMessenger.sol"; +import { ICrossDomainMessenger } from "src/universal/interfaces/ICrossDomainMessenger.sol"; import { OptimismMintableERC20 } from "src/universal/OptimismMintableERC20.sol"; import { Initializable } from "@openzeppelin/contracts/proxy/utils/Initializable.sol"; import { Constants } from "src/libraries/Constants.sol"; @@ -38,7 +38,7 @@ abstract contract StandardBridge is Initializable { /// @notice Messenger contract on this domain. /// @custom:network-specific - CrossDomainMessenger public messenger; + ICrossDomainMessenger public messenger; /// @notice Corresponding bridge on the other domain. /// @custom:network-specific @@ -116,7 +116,7 @@ abstract contract StandardBridge is Initializable { /// @param _messenger Contract for CrossDomainMessenger on this network. /// @param _otherBridge Contract for the other StandardBridge contract. function __StandardBridge_init( - CrossDomainMessenger _messenger, + ICrossDomainMessenger _messenger, StandardBridge _otherBridge ) internal @@ -143,7 +143,7 @@ abstract contract StandardBridge is Initializable { /// Public getter is legacy and will be removed in the future. Use `messenger` instead. /// @return Contract of the messenger on this domain. /// @custom:legacy - function MESSENGER() external view returns (CrossDomainMessenger) { + function MESSENGER() external view returns (ICrossDomainMessenger) { return messenger; } diff --git a/packages/contracts-bedrock/src/universal/interfaces/ICrossDomainMessenger.sol b/packages/contracts-bedrock/src/universal/interfaces/ICrossDomainMessenger.sol new file mode 100644 index 000000000000..ed2fb20ea453 --- /dev/null +++ b/packages/contracts-bedrock/src/universal/interfaces/ICrossDomainMessenger.sol @@ -0,0 +1,38 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +interface ICrossDomainMessenger { + event FailedRelayedMessage(bytes32 indexed msgHash); + event Initialized(uint8 version); + event RelayedMessage(bytes32 indexed msgHash); + event SentMessage(address indexed target, address sender, bytes message, uint256 messageNonce, uint256 gasLimit); + event SentMessageExtension1(address indexed sender, uint256 value); + + function MESSAGE_VERSION() external view returns (uint16); + function MIN_GAS_CALLDATA_OVERHEAD() external view returns (uint64); + function MIN_GAS_DYNAMIC_OVERHEAD_DENOMINATOR() external view returns (uint64); + function MIN_GAS_DYNAMIC_OVERHEAD_NUMERATOR() external view returns (uint64); + function OTHER_MESSENGER() external view returns (ICrossDomainMessenger); + function RELAY_CALL_OVERHEAD() external view returns (uint64); + function RELAY_CONSTANT_OVERHEAD() external view returns (uint64); + function RELAY_GAS_CHECK_BUFFER() external view returns (uint64); + function RELAY_RESERVED_GAS() external view returns (uint64); + function baseGas(bytes memory _message, uint32 _minGasLimit) external pure returns (uint64); + function failedMessages(bytes32) external view returns (bool); + function messageNonce() external view returns (uint256); + function otherMessenger() external view returns (ICrossDomainMessenger); + function paused() external view returns (bool); + function relayMessage( + uint256 _nonce, + address _sender, + address _target, + uint256 _value, + uint256 _minGasLimit, + bytes memory _message + ) + external + payable; + function sendMessage(address _target, bytes memory _message, uint32 _minGasLimit) external payable; + function successfulMessages(bytes32) external view returns (bool); + function xDomainMessageSender() external view returns (address); +} diff --git a/packages/contracts-bedrock/test/BenchmarkTest.t.sol b/packages/contracts-bedrock/test/BenchmarkTest.t.sol index 060ceddcc136..063ed6944946 100644 --- a/packages/contracts-bedrock/test/BenchmarkTest.t.sol +++ b/packages/contracts-bedrock/test/BenchmarkTest.t.sol @@ -1,18 +1,21 @@ // SPDX-License-Identifier: MIT pragma solidity 0.8.15; -// Testing utilities +// Testing import { Test } from "forge-std/Test.sol"; import { Vm } from "forge-std/Vm.sol"; import { CommonTest } from "test/setup/CommonTest.sol"; import { Bridge_Initializer } from "test/setup/Bridge_Initializer.sol"; -import { CrossDomainMessenger } from "src/universal/CrossDomainMessenger.sol"; -import { ResourceMetering } from "src/L1/ResourceMetering.sol"; + +// Libraries import { Types } from "src/libraries/Types.sol"; import { SafeCall } from "src/libraries/SafeCall.sol"; import { L1BlockIsthmus } from "src/L2/L1BlockIsthmus.sol"; import { Encoding } from "src/libraries/Encoding.sol"; +// Interfaces +import { ICrossDomainMessenger } from "src/universal/interfaces/ICrossDomainMessenger.sol"; + // Free function for setting the prevBaseFee param in the OptimismPortal. function setPrevBaseFee(Vm _vm, address _op, uint128 _prevBaseFee) { _vm.store(address(_op), bytes32(uint256(1)), bytes32((block.number << 192) | _prevBaseFee)); @@ -182,7 +185,7 @@ contract GasBenchMark_L1StandardBridge_Finalize is Bridge_Initializer { deal(address(L1Token), address(l1StandardBridge), 100, true); vm.mockCall( address(l1StandardBridge.messenger()), - abi.encodeWithSelector(CrossDomainMessenger.xDomainMessageSender.selector), + abi.encodeWithSelector(ICrossDomainMessenger.xDomainMessageSender.selector), abi.encode(address(l1StandardBridge.OTHER_BRIDGE())) ); vm.startPrank(address(l1StandardBridge.messenger())); diff --git a/packages/contracts-bedrock/test/ExtendedPause.t.sol b/packages/contracts-bedrock/test/ExtendedPause.t.sol index 93e207ac6e9d..df6e9d39132b 100644 --- a/packages/contracts-bedrock/test/ExtendedPause.t.sol +++ b/packages/contracts-bedrock/test/ExtendedPause.t.sol @@ -2,7 +2,6 @@ pragma solidity 0.8.15; import { CommonTest } from "test/setup/CommonTest.sol"; -import { SuperchainConfig } from "src/L1/SuperchainConfig.sol"; /// @dev These tests are somewhat redundant with tests in the SuperchainConfig and other pausable contracts, however /// it is worthwhile to pull them into one location to ensure that the behavior is consistent. diff --git a/packages/contracts-bedrock/test/L1/DataAvailabilityChallenge.t.sol b/packages/contracts-bedrock/test/L1/DataAvailabilityChallenge.t.sol index fd8e82c9320f..584a28d7a189 100644 --- a/packages/contracts-bedrock/test/L1/DataAvailabilityChallenge.t.sol +++ b/packages/contracts-bedrock/test/L1/DataAvailabilityChallenge.t.sol @@ -2,12 +2,12 @@ pragma solidity 0.8.15; import { - DataAvailabilityChallenge, + IDataAvailabilityChallenge, ChallengeStatus, Challenge, - CommitmentType, - computeCommitmentKeccak256 -} from "src/L1/DataAvailabilityChallenge.sol"; + CommitmentType +} from "src/L1/interfaces/IDataAvailabilityChallenge.sol"; +import { computeCommitmentKeccak256 } from "src/L1/DataAvailabilityChallenge.sol"; import { Proxy } from "src/universal/Proxy.sol"; import { CommonTest } from "test/setup/CommonTest.sol"; @@ -145,7 +145,9 @@ contract DataAvailabilityChallengeTest is CommonTest { uint256 actualBond = requiredBond - 1; dataAvailabilityChallenge.deposit{ value: actualBond }(); - vm.expectRevert(abi.encodeWithSelector(DataAvailabilityChallenge.BondTooLow.selector, actualBond, requiredBond)); + vm.expectRevert( + abi.encodeWithSelector(IDataAvailabilityChallenge.BondTooLow.selector, actualBond, requiredBond) + ); dataAvailabilityChallenge.challenge(0, computeCommitmentKeccak256("some hash")); } @@ -160,7 +162,7 @@ contract DataAvailabilityChallengeTest is CommonTest { // Second challenge of the same hash/blockNumber fails dataAvailabilityChallenge.deposit{ value: dataAvailabilityChallenge.bondSize() }(); - vm.expectRevert(abi.encodeWithSelector(DataAvailabilityChallenge.ChallengeExists.selector)); + vm.expectRevert(abi.encodeWithSelector(IDataAvailabilityChallenge.ChallengeExists.selector)); dataAvailabilityChallenge.challenge(0, challengedCommitment); // Challenge succeed if the challenged block number is different @@ -181,7 +183,7 @@ contract DataAvailabilityChallengeTest is CommonTest { // Challenge fails because the current block number must be after the challenged block dataAvailabilityChallenge.deposit{ value: dataAvailabilityChallenge.bondSize() }(); - vm.expectRevert(abi.encodeWithSelector(DataAvailabilityChallenge.ChallengeWindowNotOpen.selector)); + vm.expectRevert(abi.encodeWithSelector(IDataAvailabilityChallenge.ChallengeWindowNotOpen.selector)); dataAvailabilityChallenge.challenge(challengedBlockNumber, challengedCommitment); } @@ -194,7 +196,7 @@ contract DataAvailabilityChallengeTest is CommonTest { // Challenge fails because the block number is after the challenge window dataAvailabilityChallenge.deposit{ value: dataAvailabilityChallenge.bondSize() }(); - vm.expectRevert(abi.encodeWithSelector(DataAvailabilityChallenge.ChallengeWindowNotOpen.selector)); + vm.expectRevert(abi.encodeWithSelector(IDataAvailabilityChallenge.ChallengeWindowNotOpen.selector)); dataAvailabilityChallenge.challenge(challengedBlockNumber, challengedCommitment); } @@ -287,7 +289,7 @@ contract DataAvailabilityChallengeTest is CommonTest { vm.roll(challengedBlockNumber + 1); // Resolving a non-existent challenge fails - vm.expectRevert(abi.encodeWithSelector(DataAvailabilityChallenge.ChallengeNotActive.selector)); + vm.expectRevert(abi.encodeWithSelector(IDataAvailabilityChallenge.ChallengeNotActive.selector)); dataAvailabilityChallenge.resolve(challengedBlockNumber, computeCommitmentKeccak256(preImage), preImage); } @@ -307,7 +309,7 @@ contract DataAvailabilityChallengeTest is CommonTest { dataAvailabilityChallenge.resolve(challengedBlockNumber, challengedCommitment, preImage); // Resolving an already resolved challenge fails - vm.expectRevert(abi.encodeWithSelector(DataAvailabilityChallenge.ChallengeNotActive.selector)); + vm.expectRevert(abi.encodeWithSelector(IDataAvailabilityChallenge.ChallengeNotActive.selector)); dataAvailabilityChallenge.resolve(challengedBlockNumber, challengedCommitment, preImage); } @@ -327,7 +329,7 @@ contract DataAvailabilityChallengeTest is CommonTest { vm.roll(block.number + dataAvailabilityChallenge.resolveWindow() + 1); // Resolving an expired challenge fails - vm.expectRevert(abi.encodeWithSelector(DataAvailabilityChallenge.ChallengeNotActive.selector)); + vm.expectRevert(abi.encodeWithSelector(IDataAvailabilityChallenge.ChallengeNotActive.selector)); dataAvailabilityChallenge.resolve(challengedBlockNumber, challengedCommitment, preImage); } @@ -347,7 +349,7 @@ contract DataAvailabilityChallengeTest is CommonTest { vm.roll(block.number + dataAvailabilityChallenge.resolveWindow() + 1); // Resolve the challenge - vm.expectRevert(abi.encodeWithSelector(DataAvailabilityChallenge.ChallengeNotActive.selector)); + vm.expectRevert(abi.encodeWithSelector(IDataAvailabilityChallenge.ChallengeNotActive.selector)); dataAvailabilityChallenge.resolve(challengedBlockNumber, challengedCommitment, preImage); } @@ -405,7 +407,7 @@ contract DataAvailabilityChallengeTest is CommonTest { vm.roll(challengedBlockNumber + 1); // Unlock a bond of a non-existent challenge fails - vm.expectRevert(abi.encodeWithSelector(DataAvailabilityChallenge.ChallengeNotExpired.selector)); + vm.expectRevert(abi.encodeWithSelector(IDataAvailabilityChallenge.ChallengeNotExpired.selector)); dataAvailabilityChallenge.unlockBond(challengedBlockNumber, challengedCommitment); } @@ -425,7 +427,7 @@ contract DataAvailabilityChallengeTest is CommonTest { dataAvailabilityChallenge.resolve(challengedBlockNumber, challengedCommitment, preImage); // Attempting to unlock a bond of a resolved challenge fails - vm.expectRevert(abi.encodeWithSelector(DataAvailabilityChallenge.ChallengeNotExpired.selector)); + vm.expectRevert(abi.encodeWithSelector(IDataAvailabilityChallenge.ChallengeNotExpired.selector)); dataAvailabilityChallenge.unlockBond(challengedBlockNumber, challengedCommitment); } @@ -469,7 +471,7 @@ contract DataAvailabilityChallengeTest is CommonTest { vm.roll(block.number + dataAvailabilityChallenge.resolveWindow() - 1); // Expiring the challenge before the resolve window closes fails - vm.expectRevert(abi.encodeWithSelector(DataAvailabilityChallenge.ChallengeNotExpired.selector)); + vm.expectRevert(abi.encodeWithSelector(IDataAvailabilityChallenge.ChallengeNotExpired.selector)); dataAvailabilityChallenge.unlockBond(challengedBlockNumber, challengedCommitment); } @@ -480,7 +482,9 @@ contract DataAvailabilityChallengeTest is CommonTest { // Expect the challenge to fail because the bond is too low bytes memory challengedCommitment = computeCommitmentKeccak256("some hash"); - vm.expectRevert(abi.encodeWithSelector(DataAvailabilityChallenge.BondTooLow.selector, actualBond, requiredBond)); + vm.expectRevert( + abi.encodeWithSelector(IDataAvailabilityChallenge.BondTooLow.selector, actualBond, requiredBond) + ); dataAvailabilityChallenge.challenge(0, challengedCommitment); // Reduce the required bond @@ -500,7 +504,9 @@ contract DataAvailabilityChallengeTest is CommonTest { function testSetResolverRefundPercentageFail() public { address owner = dataAvailabilityChallenge.owner(); - vm.expectRevert(abi.encodeWithSelector(DataAvailabilityChallenge.InvalidResolverRefundPercentage.selector, 101)); + vm.expectRevert( + abi.encodeWithSelector(IDataAvailabilityChallenge.InvalidResolverRefundPercentage.selector, 101) + ); vm.prank(owner); dataAvailabilityChallenge.setResolverRefundPercentage(101); } @@ -520,13 +526,13 @@ contract DataAvailabilityChallengeTest is CommonTest { dataAvailabilityChallenge.validateCommitment(validCommitment); // Should revert if the commitment type is unknown - vm.expectRevert(abi.encodeWithSelector(DataAvailabilityChallenge.UnknownCommitmentType.selector, uint8(1))); + vm.expectRevert(abi.encodeWithSelector(IDataAvailabilityChallenge.UnknownCommitmentType.selector, uint8(1))); bytes memory unknownType = abi.encodePacked(uint8(1), keccak256("test")); dataAvailabilityChallenge.validateCommitment(unknownType); // Should revert if the commitment length does not match vm.expectRevert( - abi.encodeWithSelector(DataAvailabilityChallenge.InvalidCommitmentLength.selector, uint8(0), 33, 34) + abi.encodeWithSelector(IDataAvailabilityChallenge.InvalidCommitmentLength.selector, uint8(0), 33, 34) ); bytes memory invalidLength = abi.encodePacked(CommitmentType.Keccak256, keccak256("test"), "x"); dataAvailabilityChallenge.validateCommitment(invalidLength); diff --git a/packages/contracts-bedrock/test/L1/DelayedVetoable.t.sol b/packages/contracts-bedrock/test/L1/DelayedVetoable.t.sol index 5e67a7ba5cf9..8c35ced064d5 100644 --- a/packages/contracts-bedrock/test/L1/DelayedVetoable.t.sol +++ b/packages/contracts-bedrock/test/L1/DelayedVetoable.t.sol @@ -3,6 +3,7 @@ pragma solidity 0.8.15; import { Test } from "forge-std/Test.sol"; import { DelayedVetoable } from "src/L1/DelayedVetoable.sol"; +import { IDelayedVetoable } from "src/L1/interfaces/IDelayedVetoable.sol"; contract DelayedVetoable_Init is Test { error Unauthorized(address expected, address actual); @@ -16,7 +17,7 @@ contract DelayedVetoable_Init is Test { address initiator; address vetoer; uint256 operatingDelay = 14 days; - DelayedVetoable delayedVetoable; + IDelayedVetoable delayedVetoable; function setUp() public { initiator = makeAddr("initiator"); @@ -25,12 +26,16 @@ contract DelayedVetoable_Init is Test { vm.deal(initiator, 10000 ether); vm.deal(vetoer, 10000 ether); - delayedVetoable = new DelayedVetoable({ - initiator_: initiator, - vetoer_: vetoer, - target_: address(target), - operatingDelay_: operatingDelay - }); + delayedVetoable = IDelayedVetoable( + address( + new DelayedVetoable({ + initiator_: initiator, + vetoer_: vetoer, + target_: address(target), + operatingDelay_: operatingDelay + }) + ) + ); // Most tests will use the operating delay, so we call as the initiator with null data // to set the delay. For tests that need to use the initial zero delay, we'll modify the diff --git a/packages/contracts-bedrock/test/L1/L1CrossDomainMessenger.t.sol b/packages/contracts-bedrock/test/L1/L1CrossDomainMessenger.t.sol index 3f585f795762..8740c09d38ca 100644 --- a/packages/contracts-bedrock/test/L1/L1CrossDomainMessenger.t.sol +++ b/packages/contracts-bedrock/test/L1/L1CrossDomainMessenger.t.sol @@ -13,10 +13,10 @@ import { Encoding } from "src/libraries/Encoding.sol"; import { Constants } from "src/libraries/Constants.sol"; // Target contract dependencies -import { L1CrossDomainMessenger } from "src/L1/L1CrossDomainMessenger.sol"; -import { OptimismPortal } from "src/L1/OptimismPortal.sol"; -import { SuperchainConfig } from "src/L1/SuperchainConfig.sol"; -import { SystemConfig } from "src/L1/SystemConfig.sol"; +import { IL1CrossDomainMessenger } from "src/L1/interfaces/IL1CrossDomainMessenger.sol"; +import { IOptimismPortal } from "src/L1/interfaces/IOptimismPortal.sol"; +import { ISuperchainConfig } from "src/L1/interfaces/ISuperchainConfig.sol"; +import { ISystemConfig } from "src/L1/interfaces/ISystemConfig.sol"; contract L1CrossDomainMessenger_Test is Bridge_Initializer { /// @dev The receiver address @@ -29,7 +29,7 @@ contract L1CrossDomainMessenger_Test is Bridge_Initializer { /// @notice Marked virtual to be overridden in /// test/kontrol/deployment/DeploymentSummary.t.sol function test_constructor_succeeds() external virtual { - L1CrossDomainMessenger impl = L1CrossDomainMessenger(deploy.mustGetAddress("L1CrossDomainMessenger")); + IL1CrossDomainMessenger impl = IL1CrossDomainMessenger(deploy.mustGetAddress("L1CrossDomainMessenger")); assertEq(address(impl.superchainConfig()), address(0)); assertEq(address(impl.PORTAL()), address(0)); assertEq(address(impl.portal()), address(0)); @@ -60,7 +60,7 @@ contract L1CrossDomainMessenger_Test is Bridge_Initializer { vm.expectCall( address(optimismPortal), abi.encodeWithSelector( - OptimismPortal.depositTransaction.selector, + IOptimismPortal.depositTransaction.selector, Predeploys.L2_CROSS_DOMAIN_MESSENGER, 0, l1CrossDomainMessenger.baseGas(hex"ff", 100), @@ -605,7 +605,7 @@ contract L1CrossDomainMessenger_Test is Bridge_Initializer { /// @dev Tests that the superchain config is called by the messengers paused function function test_pause_callsSuperchainConfig_succeeds() external { - vm.expectCall(address(superchainConfig), abi.encodeWithSelector(SuperchainConfig.paused.selector)); + vm.expectCall(address(superchainConfig), abi.encodeWithSelector(ISuperchainConfig.paused.selector)); l1CrossDomainMessenger.paused(); } @@ -632,7 +632,7 @@ contract L1CrossDomainMessenger_Test is Bridge_Initializer { vm.expectCall( address(optimismPortal), abi.encodeWithSelector( - OptimismPortal.depositTransaction.selector, + IOptimismPortal.depositTransaction.selector, Predeploys.L2_CROSS_DOMAIN_MESSENGER, 0, l1CrossDomainMessenger.baseGas(hex"ff", 100), @@ -770,7 +770,7 @@ contract L1CrossDomainMessenger_ReinitReentryTest is Bridge_Initializer { // call the initializer function l1CrossDomainMessenger.initialize( - SuperchainConfig(superchainConfig), OptimismPortal(optimismPortal), SystemConfig(systemConfig) + ISuperchainConfig(superchainConfig), IOptimismPortal(optimismPortal), ISystemConfig(systemConfig) ); // attempt to re-replay the withdrawal diff --git a/packages/contracts-bedrock/test/L1/L1ERC721Bridge.t.sol b/packages/contracts-bedrock/test/L1/L1ERC721Bridge.t.sol index 3c8abcb4843d..ce3d949e333e 100644 --- a/packages/contracts-bedrock/test/L1/L1ERC721Bridge.t.sol +++ b/packages/contracts-bedrock/test/L1/L1ERC721Bridge.t.sol @@ -8,8 +8,8 @@ import { ERC721 } from "@openzeppelin/contracts/token/ERC721/ERC721.sol"; // Target contract dependencies import { L2ERC721Bridge } from "src/L2/L2ERC721Bridge.sol"; import { Predeploys } from "src/libraries/Predeploys.sol"; -import { SuperchainConfig } from "src/L1/SuperchainConfig.sol"; -import { CrossDomainMessenger } from "src/universal/CrossDomainMessenger.sol"; +import { ISuperchainConfig } from "src/L1/interfaces/ISuperchainConfig.sol"; +import { ICrossDomainMessenger } from "src/universal/interfaces/ICrossDomainMessenger.sol"; // Target contract import { L1ERC721Bridge } from "src/L1/L1ERC721Bridge.sol"; @@ -323,7 +323,7 @@ contract L1ERC721Bridge_Pause_Test is Bridge_Initializer { /// @dev Ensures that the `paused` function of the bridge contract actually calls the `paused` function of the /// `superchainConfig`. function test_pause_callsSuperchainConfig_succeeds() external { - vm.expectCall(address(superchainConfig), abi.encodeWithSelector(SuperchainConfig.paused.selector)); + vm.expectCall(address(superchainConfig), abi.encodeWithSelector(ISuperchainConfig.paused.selector)); l1ERC721Bridge.paused(); } @@ -352,7 +352,7 @@ contract L1ERC721Bridge_Pause_TestFail is Bridge_Initializer { vm.mockCall( address(l1ERC721Bridge.messenger()), - abi.encodeWithSelector(CrossDomainMessenger.xDomainMessageSender.selector), + abi.encodeWithSelector(ICrossDomainMessenger.xDomainMessageSender.selector), abi.encode(address(l1ERC721Bridge.otherBridge())) ); } diff --git a/packages/contracts-bedrock/test/L1/L1StandardBridge.t.sol b/packages/contracts-bedrock/test/L1/L1StandardBridge.t.sol index d01fb1c26048..bcba92adf6ba 100644 --- a/packages/contracts-bedrock/test/L1/L1StandardBridge.t.sol +++ b/packages/contracts-bedrock/test/L1/L1StandardBridge.t.sol @@ -14,20 +14,20 @@ import { Constants } from "src/libraries/Constants.sol"; import { StandardBridge } from "src/universal/StandardBridge.sol"; import { L1StandardBridge } from "src/L1/L1StandardBridge.sol"; import { L2StandardBridge } from "src/L2/L2StandardBridge.sol"; -import { CrossDomainMessenger } from "src/universal/CrossDomainMessenger.sol"; -import { SuperchainConfig } from "src/L1/SuperchainConfig.sol"; +import { ICrossDomainMessenger } from "src/universal/interfaces/ICrossDomainMessenger.sol"; +import { ISuperchainConfig } from "src/L1/interfaces/ISuperchainConfig.sol"; import { AddressAliasHelper } from "src/vendor/AddressAliasHelper.sol"; // Target contract -import { OptimismPortal } from "src/L1/OptimismPortal.sol"; +import { IOptimismPortal } from "src/L1/interfaces/IOptimismPortal.sol"; contract L1StandardBridge_Getter_Test is Bridge_Initializer { /// @dev Test that the accessors return the correct initialized values. function test_getters_succeeds() external view { assert(l1StandardBridge.l2TokenBridge() == address(l2StandardBridge)); assert(l1StandardBridge.OTHER_BRIDGE() == l2StandardBridge); - assert(l1StandardBridge.messenger() == l1CrossDomainMessenger); - assert(l1StandardBridge.MESSENGER() == l1CrossDomainMessenger); + assert(address(l1StandardBridge.messenger()) == address(l1CrossDomainMessenger)); + assert(address(l1StandardBridge.MESSENGER()) == address(l1CrossDomainMessenger)); assert(l1StandardBridge.superchainConfig() == superchainConfig); assert(l1StandardBridge.systemConfig() == systemConfig); } @@ -70,7 +70,7 @@ contract L1StandardBridge_Pause_Test is Bridge_Initializer { /// @dev Ensures that the `paused` function of the bridge contract actually calls the `paused` function of the /// `superchainConfig`. function test_pause_callsSuperchainConfig_succeeds() external { - vm.expectCall(address(superchainConfig), abi.encodeWithSelector(SuperchainConfig.paused.selector)); + vm.expectCall(address(superchainConfig), abi.encodeWithSelector(ISuperchainConfig.paused.selector)); l1StandardBridge.paused(); } @@ -101,7 +101,7 @@ contract L1StandardBridge_Pause_TestFail is Bridge_Initializer { vm.mockCall( address(l1StandardBridge.messenger()), - abi.encodeWithSelector(CrossDomainMessenger.xDomainMessageSender.selector), + abi.encodeWithSelector(ICrossDomainMessenger.xDomainMessageSender.selector), abi.encode(address(l1StandardBridge.otherBridge())) ); } @@ -176,7 +176,7 @@ contract L1StandardBridge_Receive_Test is Bridge_Initializer { vm.expectCall( address(l1CrossDomainMessenger), abi.encodeWithSelector( - CrossDomainMessenger.sendMessage.selector, + ICrossDomainMessenger.sendMessage.selector, address(l2StandardBridge), abi.encodeWithSelector(StandardBridge.finalizeBridgeETH.selector, alice, alice, 100, hex""), 200_000 @@ -235,11 +235,13 @@ contract PreBridgeETH is Bridge_Initializer { vm.expectCall( address(l1CrossDomainMessenger), value, - abi.encodeWithSelector(CrossDomainMessenger.sendMessage.selector, address(l2StandardBridge), message, 50000) + abi.encodeWithSelector( + ICrossDomainMessenger.sendMessage.selector, address(l2StandardBridge), message, 50000 + ) ); bytes memory innerMessage = abi.encodeWithSelector( - CrossDomainMessenger.relayMessage.selector, + ICrossDomainMessenger.relayMessage.selector, nonce, address(l1StandardBridge), address(l2StandardBridge), @@ -253,7 +255,7 @@ contract PreBridgeETH is Bridge_Initializer { address(optimismPortal), value, abi.encodeWithSelector( - OptimismPortal.depositTransaction.selector, + IOptimismPortal.depositTransaction.selector, address(l2CrossDomainMessenger), value, baseGas, @@ -375,11 +377,13 @@ contract PreBridgeETHTo is Bridge_Initializer { // L1CrossDomainMessenger.sendMessage vm.expectCall( address(l1CrossDomainMessenger), - abi.encodeWithSelector(CrossDomainMessenger.sendMessage.selector, address(l2StandardBridge), message, 60000) + abi.encodeWithSelector( + ICrossDomainMessenger.sendMessage.selector, address(l2StandardBridge), message, 60000 + ) ); bytes memory innerMessage = abi.encodeWithSelector( - CrossDomainMessenger.relayMessage.selector, + ICrossDomainMessenger.relayMessage.selector, nonce, address(l1StandardBridge), address(l2StandardBridge), @@ -392,7 +396,7 @@ contract PreBridgeETHTo is Bridge_Initializer { vm.expectCall( address(optimismPortal), abi.encodeWithSelector( - OptimismPortal.depositTransaction.selector, + IOptimismPortal.depositTransaction.selector, address(l2CrossDomainMessenger), value, baseGas, @@ -527,11 +531,13 @@ contract L1StandardBridge_DepositERC20_Test is Bridge_Initializer { // the L1 bridge should call L1CrossDomainMessenger.sendMessage vm.expectCall( address(l1CrossDomainMessenger), - abi.encodeWithSelector(CrossDomainMessenger.sendMessage.selector, address(l2StandardBridge), message, 10000) + abi.encodeWithSelector( + ICrossDomainMessenger.sendMessage.selector, address(l2StandardBridge), message, 10000 + ) ); bytes memory innerMessage = abi.encodeWithSelector( - CrossDomainMessenger.relayMessage.selector, + ICrossDomainMessenger.relayMessage.selector, nonce, address(l1StandardBridge), address(l2StandardBridge), @@ -544,7 +550,7 @@ contract L1StandardBridge_DepositERC20_Test is Bridge_Initializer { vm.expectCall( address(optimismPortal), abi.encodeWithSelector( - OptimismPortal.depositTransaction.selector, + IOptimismPortal.depositTransaction.selector, address(l2CrossDomainMessenger), 0, baseGas, @@ -610,7 +616,7 @@ contract L1StandardBridge_DepositERC20To_Test is Bridge_Initializer { ); bytes memory innerMessage = abi.encodeWithSelector( - CrossDomainMessenger.relayMessage.selector, + ICrossDomainMessenger.relayMessage.selector, nonce, address(l1StandardBridge), address(l2StandardBridge), @@ -649,13 +655,15 @@ contract L1StandardBridge_DepositERC20To_Test is Bridge_Initializer { // the L1 bridge should call L1CrossDomainMessenger.sendMessage vm.expectCall( address(l1CrossDomainMessenger), - abi.encodeWithSelector(CrossDomainMessenger.sendMessage.selector, address(l2StandardBridge), message, 10000) + abi.encodeWithSelector( + ICrossDomainMessenger.sendMessage.selector, address(l2StandardBridge), message, 10000 + ) ); // The L1 XDM should call OptimismPortal.depositTransaction vm.expectCall( address(optimismPortal), abi.encodeWithSelector( - OptimismPortal.depositTransaction.selector, + IOptimismPortal.depositTransaction.selector, address(l2CrossDomainMessenger), 0, baseGas, @@ -694,7 +702,7 @@ contract L1StandardBridge_FinalizeETHWithdrawal_Test is Bridge_Initializer { vm.mockCall( address(l1StandardBridge.messenger()), - abi.encodeWithSelector(CrossDomainMessenger.xDomainMessageSender.selector), + abi.encodeWithSelector(ICrossDomainMessenger.xDomainMessageSender.selector), abi.encode(address(l1StandardBridge.OTHER_BRIDGE())) ); // ensure that the messenger has ETH to call with @@ -720,7 +728,7 @@ contract L1StandardBridge_FinalizeETHWithdrawal_TestFail is Bridge_Initializer { ); vm.mockCall( address(l1StandardBridge.messenger()), - abi.encodeWithSelector(CrossDomainMessenger.xDomainMessageSender.selector), + abi.encodeWithSelector(ICrossDomainMessenger.xDomainMessageSender.selector), abi.encode(address(l1StandardBridge.OTHER_BRIDGE())) ); vm.deal(address(l1StandardBridge.messenger()), _value); @@ -759,7 +767,7 @@ contract L1StandardBridge_FinalizeERC20Withdrawal_Test is Bridge_Initializer { vm.mockCall( address(l1StandardBridge.messenger()), - abi.encodeWithSelector(CrossDomainMessenger.xDomainMessageSender.selector), + abi.encodeWithSelector(ICrossDomainMessenger.xDomainMessageSender.selector), abi.encode(address(l1StandardBridge.OTHER_BRIDGE())) ); vm.prank(address(l1StandardBridge.messenger())); @@ -775,7 +783,7 @@ contract L1StandardBridge_FinalizeERC20Withdrawal_TestFail is Bridge_Initializer function test_finalizeERC20Withdrawal_notMessenger_reverts() external { vm.mockCall( address(l1StandardBridge.messenger()), - abi.encodeWithSelector(CrossDomainMessenger.xDomainMessageSender.selector), + abi.encodeWithSelector(ICrossDomainMessenger.xDomainMessageSender.selector), abi.encode(address(l1StandardBridge.OTHER_BRIDGE())) ); vm.prank(address(28)); @@ -787,7 +795,7 @@ contract L1StandardBridge_FinalizeERC20Withdrawal_TestFail is Bridge_Initializer function test_finalizeERC20Withdrawal_notOtherBridge_reverts() external { vm.mockCall( address(l1StandardBridge.messenger()), - abi.encodeWithSelector(CrossDomainMessenger.xDomainMessageSender.selector), + abi.encodeWithSelector(ICrossDomainMessenger.xDomainMessageSender.selector), abi.encode(address(address(0))) ); vm.prank(address(l1StandardBridge.messenger())); @@ -802,7 +810,7 @@ contract L1StandardBridge_FinalizeBridgeETH_Test is Bridge_Initializer { address messenger = address(l1StandardBridge.messenger()); vm.mockCall( messenger, - abi.encodeWithSelector(CrossDomainMessenger.xDomainMessageSender.selector), + abi.encodeWithSelector(ICrossDomainMessenger.xDomainMessageSender.selector), abi.encode(address(l1StandardBridge.OTHER_BRIDGE())) ); vm.deal(messenger, 100); @@ -820,7 +828,7 @@ contract L1StandardBridge_FinalizeBridgeETH_TestFail is Bridge_Initializer { function testFuzz_finalizeBridgeETH_customGasToken_reverts(uint256 _value, bytes calldata _extraData) external { vm.mockCall( address(l1StandardBridge.messenger()), - abi.encodeWithSelector(CrossDomainMessenger.xDomainMessageSender.selector), + abi.encodeWithSelector(ICrossDomainMessenger.xDomainMessageSender.selector), abi.encode(address(l1StandardBridge.OTHER_BRIDGE())) ); vm.deal(address(l1CrossDomainMessenger), _value); @@ -838,7 +846,7 @@ contract L1StandardBridge_FinalizeBridgeETH_TestFail is Bridge_Initializer { address messenger = address(l1StandardBridge.messenger()); vm.mockCall( messenger, - abi.encodeWithSelector(CrossDomainMessenger.xDomainMessageSender.selector), + abi.encodeWithSelector(ICrossDomainMessenger.xDomainMessageSender.selector), abi.encode(address(l1StandardBridge.OTHER_BRIDGE())) ); vm.deal(messenger, 100); @@ -852,7 +860,7 @@ contract L1StandardBridge_FinalizeBridgeETH_TestFail is Bridge_Initializer { address messenger = address(l1StandardBridge.messenger()); vm.mockCall( messenger, - abi.encodeWithSelector(CrossDomainMessenger.xDomainMessageSender.selector), + abi.encodeWithSelector(ICrossDomainMessenger.xDomainMessageSender.selector), abi.encode(address(l1StandardBridge.OTHER_BRIDGE())) ); vm.deal(messenger, 100); @@ -866,7 +874,7 @@ contract L1StandardBridge_FinalizeBridgeETH_TestFail is Bridge_Initializer { address messenger = address(l1StandardBridge.messenger()); vm.mockCall( messenger, - abi.encodeWithSelector(CrossDomainMessenger.xDomainMessageSender.selector), + abi.encodeWithSelector(ICrossDomainMessenger.xDomainMessageSender.selector), abi.encode(address(l1StandardBridge.OTHER_BRIDGE())) ); vm.deal(messenger, 100); diff --git a/packages/contracts-bedrock/test/L1/OptimismPortal.t.sol b/packages/contracts-bedrock/test/L1/OptimismPortal.t.sol index b47bad8e4173..35c9d0fb4ee5 100644 --- a/packages/contracts-bedrock/test/L1/OptimismPortal.t.sol +++ b/packages/contracts-bedrock/test/L1/OptimismPortal.t.sol @@ -16,14 +16,13 @@ import { Constants } from "src/libraries/Constants.sol"; // Target contract dependencies import { Proxy } from "src/universal/Proxy.sol"; -import { ResourceMetering } from "src/L1/ResourceMetering.sol"; +import { IResourceMetering } from "src/L1/interfaces/IResourceMetering.sol"; import { AddressAliasHelper } from "src/vendor/AddressAliasHelper.sol"; import { IL2OutputOracle } from "src/L1/interfaces/IL2OutputOracle.sol"; -import { SystemConfig } from "src/L1/SystemConfig.sol"; import { SuperchainConfig } from "src/L1/SuperchainConfig.sol"; import { L1Block } from "src/L2/L1Block.sol"; import { Predeploys } from "src/libraries/Predeploys.sol"; -import { OptimismPortal } from "src/L1/OptimismPortal.sol"; +import { IOptimismPortal } from "src/L1/interfaces/IOptimismPortal.sol"; import { GasPayingToken } from "src/libraries/GasPayingToken.sol"; import { MockERC20 } from "solmate/test/utils/mocks/MockERC20.sol"; import { AddressAliasHelper } from "src/vendor/AddressAliasHelper.sol"; @@ -43,7 +42,7 @@ contract OptimismPortal_Test is CommonTest { /// @notice Marked virtual to be overridden in /// test/kontrol/deployment/DeploymentSummary.t.sol function test_constructor_succeeds() external virtual { - OptimismPortal opImpl = OptimismPortal(payable(deploy.mustGetAddress("OptimismPortal"))); + IOptimismPortal opImpl = IOptimismPortal(payable(deploy.mustGetAddress("OptimismPortal"))); assertEq(address(opImpl.l2Oracle()), address(0)); assertEq(address(opImpl.systemConfig()), address(0)); assertEq(address(opImpl.superchainConfig()), address(0)); @@ -170,7 +169,7 @@ contract OptimismPortal_Test is CommonTest { _to = address(0); } vm.assume(_data.length <= 120_000); - ResourceMetering.ResourceConfig memory rcfg = systemConfig.resourceConfig(); + IResourceMetering.ResourceConfig memory rcfg = systemConfig.resourceConfig(); _gasLimit = uint64(bound(_gasLimit, optimismPortal.minimumGasLimit(uint64(_data.length)), rcfg.maxResourceLimit)); @@ -1156,7 +1155,7 @@ contract OptimismPortalUpgradeable_Test is CommonTest { /// @dev Tests that the proxy is initialized correctly. function test_params_initValuesOnProxy_succeeds() external view { (uint128 prevBaseFee, uint64 prevBoughtGas, uint64 prevBlockNum) = optimismPortal.params(); - ResourceMetering.ResourceConfig memory rcfg = systemConfig.resourceConfig(); + IResourceMetering.ResourceConfig memory rcfg = systemConfig.resourceConfig(); assertEq(prevBaseFee, rcfg.minimumBaseFee); assertEq(prevBoughtGas, 0); @@ -1240,7 +1239,7 @@ contract OptimismPortalResourceFuzz_Test is CommonTest { vm.roll(uint256(keccak256(abi.encode(_blockDiff))) % uint256(type(uint16).max) + uint256(_blockDiff)); // Create a resource config to mock the call to the system config with - ResourceMetering.ResourceConfig memory rcfg = ResourceMetering.ResourceConfig({ + IResourceMetering.ResourceConfig memory rcfg = IResourceMetering.ResourceConfig({ maxResourceLimit: _maxResourceLimit, elasticityMultiplier: _elasticityMultiplier, baseFeeMaxChangeDenominator: _baseFeeMaxChangeDenominator, @@ -1299,7 +1298,7 @@ contract OptimismPortalWithMockERC20_Test is OptimismPortal_FinalizeWithdrawal_T _to = address(0); } vm.assume(_data.length <= 120_000); - ResourceMetering.ResourceConfig memory rcfg = systemConfig.resourceConfig(); + IResourceMetering.ResourceConfig memory rcfg = systemConfig.resourceConfig(); _gasLimit = uint64(bound(_gasLimit, optimismPortal.minimumGasLimit(uint64(_data.length)), rcfg.maxResourceLimit)); @@ -1514,7 +1513,7 @@ contract OptimismPortalWithMockERC20_Test is OptimismPortal_FinalizeWithdrawal_T _to = address(0); } vm.assume(_data.length <= 120_000); - ResourceMetering.ResourceConfig memory rcfg = systemConfig.resourceConfig(); + IResourceMetering.ResourceConfig memory rcfg = systemConfig.resourceConfig(); _gasLimit = uint64(bound(_gasLimit, optimismPortal.minimumGasLimit(uint64(_data.length)), rcfg.maxResourceLimit)); diff --git a/packages/contracts-bedrock/test/L1/OptimismPortal2.t.sol b/packages/contracts-bedrock/test/L1/OptimismPortal2.t.sol index 91ea566dfce0..c0423ff2806e 100644 --- a/packages/contracts-bedrock/test/L1/OptimismPortal2.t.sol +++ b/packages/contracts-bedrock/test/L1/OptimismPortal2.t.sol @@ -17,12 +17,11 @@ import { Predeploys } from "src/libraries/Predeploys.sol"; // Target contract dependencies import { Proxy } from "src/universal/Proxy.sol"; -import { ResourceMetering } from "src/L1/ResourceMetering.sol"; +import { IResourceMetering } from "src/L1/interfaces/IResourceMetering.sol"; import { AddressAliasHelper } from "src/vendor/AddressAliasHelper.sol"; -import { SystemConfig } from "src/L1/SystemConfig.sol"; import { L1Block } from "src/L2/L1Block.sol"; import { SuperchainConfig } from "src/L1/SuperchainConfig.sol"; -import { OptimismPortal2 } from "src/L1/OptimismPortal2.sol"; +import { IOptimismPortal2 } from "src/L1/interfaces/IOptimismPortal2.sol"; import { GasPayingToken } from "src/libraries/GasPayingToken.sol"; import { MockERC20 } from "solmate/test/utils/mocks/MockERC20.sol"; @@ -50,7 +49,7 @@ contract OptimismPortal2_Test is CommonTest { /// @notice Marked virtual to be overridden in /// test/kontrol/deployment/DeploymentSummary.t.sol function test_constructor_succeeds() external virtual { - OptimismPortal2 opImpl = OptimismPortal2(payable(deploy.mustGetAddress("OptimismPortal2"))); + IOptimismPortal2 opImpl = IOptimismPortal2(payable(deploy.mustGetAddress("OptimismPortal2"))); assertEq(address(opImpl.disputeGameFactory()), address(0)); assertEq(address(opImpl.systemConfig()), address(0)); assertEq(address(opImpl.superchainConfig()), address(0)); @@ -1404,7 +1403,7 @@ contract OptimismPortal2_Upgradeable_Test is CommonTest { /// @dev Tests that the proxy is initialized correctly. function test_params_initValuesOnProxy_succeeds() external view { (uint128 prevBaseFee, uint64 prevBoughtGas, uint64 prevBlockNum) = optimismPortal2.params(); - ResourceMetering.ResourceConfig memory rcfg = systemConfig.resourceConfig(); + IResourceMetering.ResourceConfig memory rcfg = systemConfig.resourceConfig(); assertEq(prevBaseFee, rcfg.minimumBaseFee); assertEq(prevBoughtGas, 0); @@ -1494,7 +1493,7 @@ contract OptimismPortal2_ResourceFuzz_Test is CommonTest { vm.roll(uint256(keccak256(abi.encode(_blockDiff))) % uint256(type(uint16).max) + uint256(_blockDiff)); // Create a resource config to mock the call to the system config with - ResourceMetering.ResourceConfig memory rcfg = ResourceMetering.ResourceConfig({ + IResourceMetering.ResourceConfig memory rcfg = IResourceMetering.ResourceConfig({ maxResourceLimit: _maxResourceLimit, elasticityMultiplier: _elasticityMultiplier, baseFeeMaxChangeDenominator: _baseFeeMaxChangeDenominator, @@ -1553,7 +1552,7 @@ contract OptimismPortal2WithMockERC20_Test is OptimismPortal2_FinalizeWithdrawal _to = address(0); } vm.assume(_data.length <= 120_000); - ResourceMetering.ResourceConfig memory rcfg = systemConfig.resourceConfig(); + IResourceMetering.ResourceConfig memory rcfg = systemConfig.resourceConfig(); _gasLimit = uint64(bound(_gasLimit, optimismPortal2.minimumGasLimit(uint64(_data.length)), rcfg.maxResourceLimit)); @@ -1777,7 +1776,7 @@ contract OptimismPortal2WithMockERC20_Test is OptimismPortal2_FinalizeWithdrawal _to = address(0); } vm.assume(_data.length <= 120_000); - ResourceMetering.ResourceConfig memory rcfg = systemConfig.resourceConfig(); + IResourceMetering.ResourceConfig memory rcfg = systemConfig.resourceConfig(); _gasLimit = uint64(bound(_gasLimit, optimismPortal2.minimumGasLimit(uint64(_data.length)), rcfg.maxResourceLimit)); diff --git a/packages/contracts-bedrock/test/L1/OptimismPortalInterop.t.sol b/packages/contracts-bedrock/test/L1/OptimismPortalInterop.t.sol index 6fb9a1aab6ed..6e0235774df6 100644 --- a/packages/contracts-bedrock/test/L1/OptimismPortalInterop.t.sol +++ b/packages/contracts-bedrock/test/L1/OptimismPortalInterop.t.sol @@ -7,12 +7,16 @@ import { CommonTest } from "test/setup/CommonTest.sol"; // Libraries import { Constants } from "src/libraries/Constants.sol"; import { Predeploys } from "src/libraries/Predeploys.sol"; +import "src/libraries/PortalErrors.sol"; // Target contract dependencies import "src/libraries/PortalErrors.sol"; import { OptimismPortalInterop } from "src/L1/OptimismPortalInterop.sol"; import { L1BlockIsthmus, ConfigType } from "src/L2/L1BlockIsthmus.sol"; +// Interfaces +import { IOptimismPortalInterop } from "src/L1/interfaces/IOptimismPortalInterop.sol"; + contract OptimismPortalInterop_Test is CommonTest { /// @notice Marked virtual to be overridden in /// test/kontrol/deployment/DeploymentSummary.t.sol @@ -91,7 +95,7 @@ contract OptimismPortalInterop_Test is CommonTest { } /// @dev Returns the OptimismPortalInterop instance. - function _optimismPortalInterop() internal view returns (OptimismPortalInterop) { - return OptimismPortalInterop(payable(address(optimismPortal))); + function _optimismPortalInterop() internal view returns (IOptimismPortalInterop) { + return IOptimismPortalInterop(payable(address(optimismPortal))); } } diff --git a/packages/contracts-bedrock/test/L1/ResourceMetering.t.sol b/packages/contracts-bedrock/test/L1/ResourceMetering.t.sol index f4bca39ea418..f315b5212fd6 100644 --- a/packages/contracts-bedrock/test/L1/ResourceMetering.t.sol +++ b/packages/contracts-bedrock/test/L1/ResourceMetering.t.sol @@ -12,13 +12,22 @@ import { Proxy } from "src/universal/Proxy.sol"; // Target contract import { ResourceMetering } from "src/L1/ResourceMetering.sol"; +import { IResourceMetering } from "src/L1/interfaces/IResourceMetering.sol"; contract MeterUser is ResourceMetering { ResourceMetering.ResourceConfig public innerConfig; constructor() { initialize(); - innerConfig = Constants.DEFAULT_RESOURCE_CONFIG(); + IResourceMetering.ResourceConfig memory rcfg = Constants.DEFAULT_RESOURCE_CONFIG(); + innerConfig = ResourceMetering.ResourceConfig({ + maxResourceLimit: rcfg.maxResourceLimit, + elasticityMultiplier: rcfg.elasticityMultiplier, + baseFeeMaxChangeDenominator: rcfg.baseFeeMaxChangeDenominator, + minimumBaseFee: rcfg.minimumBaseFee, + systemTxMaxGas: rcfg.systemTxMaxGas, + maximumBaseFee: rcfg.maximumBaseFee + }); } function initialize() public initializer { @@ -231,7 +240,15 @@ contract CustomMeterUser is ResourceMetering { } function _resourceConfig() internal pure override returns (ResourceMetering.ResourceConfig memory) { - return Constants.DEFAULT_RESOURCE_CONFIG(); + IResourceMetering.ResourceConfig memory rcfg = Constants.DEFAULT_RESOURCE_CONFIG(); + return ResourceMetering.ResourceConfig({ + maxResourceLimit: rcfg.maxResourceLimit, + elasticityMultiplier: rcfg.elasticityMultiplier, + baseFeeMaxChangeDenominator: rcfg.baseFeeMaxChangeDenominator, + minimumBaseFee: rcfg.minimumBaseFee, + systemTxMaxGas: rcfg.systemTxMaxGas, + maximumBaseFee: rcfg.maximumBaseFee + }); } function use(uint64 _amount) public returns (uint256) { diff --git a/packages/contracts-bedrock/test/L1/SuperchainConfig.t.sol b/packages/contracts-bedrock/test/L1/SuperchainConfig.t.sol index 97b25f3f611a..409bb0003941 100644 --- a/packages/contracts-bedrock/test/L1/SuperchainConfig.t.sol +++ b/packages/contracts-bedrock/test/L1/SuperchainConfig.t.sol @@ -12,6 +12,7 @@ import { Proxy } from "src/universal/Proxy.sol"; // Target contract import { SuperchainConfig } from "src/L1/SuperchainConfig.sol"; +import { ISuperchainConfig } from "src/L1/interfaces/ISuperchainConfig.sol"; contract SuperchainConfig_Init_Test is CommonTest { /// @dev Tests that initialization sets the correct values. These are defined in CommonTest.sol. @@ -23,16 +24,16 @@ contract SuperchainConfig_Init_Test is CommonTest { /// @dev Tests that it can be intialized as paused. function test_initialize_paused_succeeds() external { Proxy newProxy = new Proxy(alice); - SuperchainConfig newImpl = new SuperchainConfig(); + ISuperchainConfig newImpl = ISuperchainConfig(address(new SuperchainConfig())); vm.startPrank(alice); newProxy.upgradeToAndCall( address(newImpl), - abi.encodeWithSelector(SuperchainConfig.initialize.selector, deploy.cfg().superchainConfigGuardian(), true) + abi.encodeWithSelector(ISuperchainConfig.initialize.selector, deploy.cfg().superchainConfigGuardian(), true) ); - assertTrue(SuperchainConfig(address(newProxy)).paused()); - assertEq(SuperchainConfig(address(newProxy)).guardian(), deploy.cfg().superchainConfigGuardian()); + assertTrue(ISuperchainConfig(address(newProxy)).paused()); + assertEq(ISuperchainConfig(address(newProxy)).guardian(), deploy.cfg().superchainConfigGuardian()); } } diff --git a/packages/contracts-bedrock/test/L1/SystemConfig.t.sol b/packages/contracts-bedrock/test/L1/SystemConfig.t.sol index 9b48f354d248..8b21fbcf3646 100644 --- a/packages/contracts-bedrock/test/L1/SystemConfig.t.sol +++ b/packages/contracts-bedrock/test/L1/SystemConfig.t.sol @@ -11,16 +11,16 @@ import { EIP1967Helper } from "test/mocks/EIP1967Helper.sol"; import { Predeploys } from "src/libraries/Predeploys.sol"; // Target contract dependencies -import { ResourceMetering } from "src/L1/ResourceMetering.sol"; +import { IResourceMetering } from "src/L1/interfaces/IResourceMetering.sol"; import { Proxy } from "src/universal/Proxy.sol"; import { L1Block } from "src/L2/L1Block.sol"; import { GasPayingToken } from "src/libraries/GasPayingToken.sol"; // Target contract -import { SystemConfig } from "src/L1/SystemConfig.sol"; +import { ISystemConfig } from "src/L1/interfaces/ISystemConfig.sol"; contract SystemConfig_Init is CommonTest { - event ConfigUpdate(uint256 indexed version, SystemConfig.UpdateType indexed updateType, bytes data); + event ConfigUpdate(uint256 indexed version, ISystemConfig.UpdateType indexed updateType, bytes data); } contract SystemConfig_Initialize_Test is SystemConfig_Init { @@ -49,7 +49,7 @@ contract SystemConfig_Initialize_Test is SystemConfig_Init { /// @dev Tests that constructor sets the correct values. function test_constructor_succeeds() external view { - SystemConfig impl = SystemConfig(systemConfigImpl); + ISystemConfig impl = ISystemConfig(systemConfigImpl); assertEq(impl.owner(), address(0xdEaD)); assertEq(impl.overhead(), 0); assertEq(impl.scalar(), uint256(0x01) << 248); @@ -58,7 +58,7 @@ contract SystemConfig_Initialize_Test is SystemConfig_Init { assertEq(impl.unsafeBlockSigner(), address(0)); assertEq(impl.basefeeScalar(), 0); assertEq(impl.blobbasefeeScalar(), 0); - ResourceMetering.ResourceConfig memory actual = impl.resourceConfig(); + IResourceMetering.ResourceConfig memory actual = impl.resourceConfig(); assertEq(actual.maxResourceLimit, 1); assertEq(actual.elasticityMultiplier, 1); assertEq(actual.baseFeeMaxChangeDenominator, 2); @@ -91,8 +91,8 @@ contract SystemConfig_Initialize_Test is SystemConfig_Init { assertEq(systemConfig.basefeeScalar(), basefeeScalar); assertEq(systemConfig.blobbasefeeScalar(), blobbasefeeScalar); // Depends on `initialize` being called with defaults - ResourceMetering.ResourceConfig memory rcfg = Constants.DEFAULT_RESOURCE_CONFIG(); - ResourceMetering.ResourceConfig memory actual = systemConfig.resourceConfig(); + IResourceMetering.ResourceConfig memory rcfg = Constants.DEFAULT_RESOURCE_CONFIG(); + IResourceMetering.ResourceConfig memory actual = systemConfig.resourceConfig(); assertEq(actual.maxResourceLimit, rcfg.maxResourceLimit); assertEq(actual.elasticityMultiplier, rcfg.elasticityMultiplier); assertEq(actual.baseFeeMaxChangeDenominator, rcfg.baseFeeMaxChangeDenominator); @@ -138,7 +138,7 @@ contract SystemConfig_Initialize_TestFail is SystemConfig_Initialize_Test { _unsafeBlockSigner: address(1), _config: Constants.DEFAULT_RESOURCE_CONFIG(), _batchInbox: address(0), - _addresses: SystemConfig.Addresses({ + _addresses: ISystemConfig.Addresses({ l1CrossDomainMessenger: address(0), l1ERC721Bridge: address(0), l1StandardBridge: address(0), @@ -168,7 +168,7 @@ contract SystemConfig_Initialize_TestFail is SystemConfig_Initialize_Test { _unsafeBlockSigner: address(1), _config: Constants.DEFAULT_RESOURCE_CONFIG(), _batchInbox: address(0), - _addresses: SystemConfig.Addresses({ + _addresses: ISystemConfig.Addresses({ l1CrossDomainMessenger: address(0), l1ERC721Bridge: address(0), l1StandardBridge: address(0), @@ -199,7 +199,7 @@ contract SystemConfig_Initialize_TestFail is SystemConfig_Initialize_Test { _unsafeBlockSigner: address(1), _config: Constants.DEFAULT_RESOURCE_CONFIG(), _batchInbox: address(0), - _addresses: SystemConfig.Addresses({ + _addresses: ISystemConfig.Addresses({ l1CrossDomainMessenger: address(0), l1ERC721Bridge: address(0), l1StandardBridge: address(0), @@ -217,7 +217,7 @@ contract SystemConfig_Init_ResourceConfig is SystemConfig_Init { /// @dev Tests that `setResourceConfig` reverts if the min base fee /// is greater than the maximum allowed base fee. function test_setResourceConfig_badMinMax_reverts() external { - ResourceMetering.ResourceConfig memory config = ResourceMetering.ResourceConfig({ + IResourceMetering.ResourceConfig memory config = IResourceMetering.ResourceConfig({ maxResourceLimit: 20_000_000, elasticityMultiplier: 10, baseFeeMaxChangeDenominator: 8, @@ -231,7 +231,7 @@ contract SystemConfig_Init_ResourceConfig is SystemConfig_Init { /// @dev Tests that `setResourceConfig` reverts if the baseFeeMaxChangeDenominator /// is zero. function test_setResourceConfig_zeroDenominator_reverts() external { - ResourceMetering.ResourceConfig memory config = ResourceMetering.ResourceConfig({ + IResourceMetering.ResourceConfig memory config = IResourceMetering.ResourceConfig({ maxResourceLimit: 20_000_000, elasticityMultiplier: 10, baseFeeMaxChangeDenominator: 0, @@ -246,7 +246,7 @@ contract SystemConfig_Init_ResourceConfig is SystemConfig_Init { function test_setResourceConfig_lowGasLimit_reverts() external { uint64 gasLimit = systemConfig.gasLimit(); - ResourceMetering.ResourceConfig memory config = ResourceMetering.ResourceConfig({ + IResourceMetering.ResourceConfig memory config = IResourceMetering.ResourceConfig({ maxResourceLimit: uint32(gasLimit), elasticityMultiplier: 10, baseFeeMaxChangeDenominator: 8, @@ -260,7 +260,7 @@ contract SystemConfig_Init_ResourceConfig is SystemConfig_Init { /// @dev Tests that `setResourceConfig` reverts if the elasticity multiplier /// and max resource limit are configured such that there is a loss of precision. function test_setResourceConfig_badPrecision_reverts() external { - ResourceMetering.ResourceConfig memory config = ResourceMetering.ResourceConfig({ + IResourceMetering.ResourceConfig memory config = IResourceMetering.ResourceConfig({ maxResourceLimit: 20_000_000, elasticityMultiplier: 11, baseFeeMaxChangeDenominator: 8, @@ -274,7 +274,7 @@ contract SystemConfig_Init_ResourceConfig is SystemConfig_Init { /// @dev Helper to initialize the system config with a resource config and default values, and expect a revert /// with the given message. function _initializeWithResourceConfig( - ResourceMetering.ResourceConfig memory config, + IResourceMetering.ResourceConfig memory config, string memory revertMessage ) internal @@ -294,7 +294,7 @@ contract SystemConfig_Init_ResourceConfig is SystemConfig_Init { _unsafeBlockSigner: address(0), _config: config, _batchInbox: address(0), - _addresses: SystemConfig.Addresses({ + _addresses: ISystemConfig.Addresses({ l1CrossDomainMessenger: address(0), l1ERC721Bridge: address(0), l1StandardBridge: address(0), @@ -332,7 +332,7 @@ contract SystemConfig_Init_CustomGasToken is SystemConfig_Init { _unsafeBlockSigner: address(1), _config: Constants.DEFAULT_RESOURCE_CONFIG(), _batchInbox: address(0), - _addresses: SystemConfig.Addresses({ + _addresses: ISystemConfig.Addresses({ l1CrossDomainMessenger: address(0), l1ERC721Bridge: address(0), disputeGameFactory: address(0), @@ -533,7 +533,7 @@ contract SystemConfig_Setters_Test is SystemConfig_Init { /// @dev Tests that `setBatcherHash` updates the batcher hash successfully. function testFuzz_setBatcherHash_succeeds(bytes32 newBatcherHash) external { vm.expectEmit(address(systemConfig)); - emit ConfigUpdate(0, SystemConfig.UpdateType.BATCHER, abi.encode(newBatcherHash)); + emit ConfigUpdate(0, ISystemConfig.UpdateType.BATCHER, abi.encode(newBatcherHash)); vm.prank(systemConfig.owner()); systemConfig.setBatcherHash(newBatcherHash); @@ -545,7 +545,7 @@ contract SystemConfig_Setters_Test is SystemConfig_Init { // always zero out most significant byte newScalar = (newScalar << 16) >> 16; vm.expectEmit(address(systemConfig)); - emit ConfigUpdate(0, SystemConfig.UpdateType.GAS_CONFIG, abi.encode(newOverhead, newScalar)); + emit ConfigUpdate(0, ISystemConfig.UpdateType.GAS_CONFIG, abi.encode(newOverhead, newScalar)); vm.prank(systemConfig.owner()); systemConfig.setGasConfig(newOverhead, newScalar); @@ -558,7 +558,7 @@ contract SystemConfig_Setters_Test is SystemConfig_Init { ffi.encodeScalarEcotone({ _basefeeScalar: _basefeeScalar, _blobbasefeeScalar: _blobbasefeeScalar }); vm.expectEmit(address(systemConfig)); - emit ConfigUpdate(0, SystemConfig.UpdateType.GAS_CONFIG, abi.encode(systemConfig.overhead(), encoded)); + emit ConfigUpdate(0, ISystemConfig.UpdateType.GAS_CONFIG, abi.encode(systemConfig.overhead(), encoded)); vm.prank(systemConfig.owner()); systemConfig.setGasConfigEcotone({ _basefeeScalar: _basefeeScalar, _blobbasefeeScalar: _blobbasefeeScalar }); @@ -578,7 +578,7 @@ contract SystemConfig_Setters_Test is SystemConfig_Init { newGasLimit = uint64(bound(uint256(newGasLimit), uint256(minimumGasLimit), uint256(maximumGasLimit))); vm.expectEmit(address(systemConfig)); - emit ConfigUpdate(0, SystemConfig.UpdateType.GAS_LIMIT, abi.encode(newGasLimit)); + emit ConfigUpdate(0, ISystemConfig.UpdateType.GAS_LIMIT, abi.encode(newGasLimit)); vm.prank(systemConfig.owner()); systemConfig.setGasLimit(newGasLimit); @@ -588,7 +588,7 @@ contract SystemConfig_Setters_Test is SystemConfig_Init { /// @dev Tests that `setUnsafeBlockSigner` updates the block signer successfully. function testFuzz_setUnsafeBlockSigner_succeeds(address newUnsafeSigner) external { vm.expectEmit(address(systemConfig)); - emit ConfigUpdate(0, SystemConfig.UpdateType.UNSAFE_BLOCK_SIGNER, abi.encode(newUnsafeSigner)); + emit ConfigUpdate(0, ISystemConfig.UpdateType.UNSAFE_BLOCK_SIGNER, abi.encode(newUnsafeSigner)); vm.prank(systemConfig.owner()); systemConfig.setUnsafeBlockSigner(newUnsafeSigner); diff --git a/packages/contracts-bedrock/test/L1/SystemConfigInterop.t.sol b/packages/contracts-bedrock/test/L1/SystemConfigInterop.t.sol index c861331b1387..191949e29f6f 100644 --- a/packages/contracts-bedrock/test/L1/SystemConfigInterop.t.sol +++ b/packages/contracts-bedrock/test/L1/SystemConfigInterop.t.sol @@ -10,9 +10,9 @@ import { StaticConfig } from "src/libraries/StaticConfig.sol"; import { GasPayingToken } from "src/libraries/GasPayingToken.sol"; // Target contract dependencies -import { SystemConfig } from "src/L1/SystemConfig.sol"; +import { ISystemConfig } from "src/L1/interfaces/ISystemConfig.sol"; import { SystemConfigInterop } from "src/L1/SystemConfigInterop.sol"; -import { OptimismPortalInterop } from "src/L1/OptimismPortalInterop.sol"; +import { IOptimismPortalInterop } from "src/L1/interfaces/IOptimismPortalInterop.sol"; import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import { ConfigType } from "src/L2/L1BlockIsthmus.sol"; @@ -46,7 +46,7 @@ contract SystemConfigInterop_Test is CommonTest { vm.expectCall( address(optimismPortal), abi.encodeCall( - OptimismPortalInterop.setConfig, + IOptimismPortalInterop.setConfig, ( ConfigType.SET_GAS_PAYING_TOKEN, StaticConfig.encodeSetGasPayingToken({ @@ -67,7 +67,8 @@ contract SystemConfigInterop_Test is CommonTest { vm.expectCall( address(optimismPortal), abi.encodeCall( - OptimismPortalInterop.setConfig, (ConfigType.ADD_DEPENDENCY, StaticConfig.encodeAddDependency(_chainId)) + IOptimismPortalInterop.setConfig, + (ConfigType.ADD_DEPENDENCY, StaticConfig.encodeAddDependency(_chainId)) ) ); @@ -86,7 +87,7 @@ contract SystemConfigInterop_Test is CommonTest { vm.expectCall( address(optimismPortal), abi.encodeCall( - OptimismPortalInterop.setConfig, + IOptimismPortalInterop.setConfig, (ConfigType.REMOVE_DEPENDENCY, StaticConfig.encodeRemoveDependency(_chainId)) ) ); @@ -118,7 +119,7 @@ contract SystemConfigInterop_Test is CommonTest { _unsafeBlockSigner: address(1), _config: Constants.DEFAULT_RESOURCE_CONFIG(), _batchInbox: address(0), - _addresses: SystemConfig.Addresses({ + _addresses: ISystemConfig.Addresses({ l1CrossDomainMessenger: address(0), l1ERC721Bridge: address(0), disputeGameFactory: address(0), diff --git a/packages/contracts-bedrock/test/L2/L2CrossDomainMessenger.t.sol b/packages/contracts-bedrock/test/L2/L2CrossDomainMessenger.t.sol index c3805b991261..9892ba51cb3e 100644 --- a/packages/contracts-bedrock/test/L2/L2CrossDomainMessenger.t.sol +++ b/packages/contracts-bedrock/test/L2/L2CrossDomainMessenger.t.sol @@ -16,7 +16,6 @@ import { Constants } from "src/libraries/Constants.sol"; import { L2CrossDomainMessenger } from "src/L2/L2CrossDomainMessenger.sol"; import { L2ToL1MessagePasser } from "src/L2/L2ToL1MessagePasser.sol"; import { AddressAliasHelper } from "src/vendor/AddressAliasHelper.sol"; -import { OptimismPortal } from "src/L1/OptimismPortal.sol"; contract L2CrossDomainMessenger_Test is Bridge_Initializer { /// @dev Receiver address for testing diff --git a/packages/contracts-bedrock/test/L2/L2StandardBridge.t.sol b/packages/contracts-bedrock/test/L2/L2StandardBridge.t.sol index e07fc0086bd8..6f794c175a25 100644 --- a/packages/contracts-bedrock/test/L2/L2StandardBridge.t.sol +++ b/packages/contracts-bedrock/test/L2/L2StandardBridge.t.sol @@ -7,7 +7,7 @@ import { EIP1967Helper } from "test/mocks/EIP1967Helper.sol"; // Target contract is imported by the `Bridge_Initializer` import { Bridge_Initializer } from "test/setup/Bridge_Initializer.sol"; import { stdStorage, StdStorage } from "forge-std/Test.sol"; -import { CrossDomainMessenger } from "src/universal/CrossDomainMessenger.sol"; +import { ICrossDomainMessenger } from "src/universal/interfaces/ICrossDomainMessenger.sol"; import { L2ToL1MessagePasser } from "src/L2/L2ToL1MessagePasser.sol"; import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; @@ -60,7 +60,7 @@ contract L2StandardBridge_Test is Bridge_Initializer { abi.encodeWithSelector(StandardBridge.finalizeBridgeETH.selector, alice, alice, 100, hex""); uint64 baseGas = l2CrossDomainMessenger.baseGas(message, 200_000); bytes memory withdrawalData = abi.encodeWithSelector( - CrossDomainMessenger.relayMessage.selector, + ICrossDomainMessenger.relayMessage.selector, nonce, address(l2StandardBridge), address(l1StandardBridge), @@ -108,7 +108,7 @@ contract L2StandardBridge_Test is Bridge_Initializer { vm.expectCall( address(l2CrossDomainMessenger), abi.encodeWithSelector( - CrossDomainMessenger.sendMessage.selector, + ICrossDomainMessenger.sendMessage.selector, address(l1StandardBridge), message, 200_000 // StandardBridge's RECEIVE_DEFAULT_GAS_LIMIT @@ -282,7 +282,7 @@ contract PreBridgeERC20 is Bridge_Initializer { ); uint64 baseGas = l2CrossDomainMessenger.baseGas(message, 1000); bytes memory withdrawalData = abi.encodeWithSelector( - CrossDomainMessenger.relayMessage.selector, + ICrossDomainMessenger.relayMessage.selector, nonce, address(l2StandardBridge), address(l1StandardBridge), @@ -317,7 +317,7 @@ contract PreBridgeERC20 is Bridge_Initializer { vm.expectCall( address(l2CrossDomainMessenger), - abi.encodeWithSelector(CrossDomainMessenger.sendMessage.selector, address(l1StandardBridge), message, 1000) + abi.encodeWithSelector(ICrossDomainMessenger.sendMessage.selector, address(l1StandardBridge), message, 1000) ); vm.expectCall( @@ -420,7 +420,7 @@ contract PreBridgeERC20To is Bridge_Initializer { ); uint64 baseGas = l2CrossDomainMessenger.baseGas(message, 1000); bytes memory withdrawalData = abi.encodeWithSelector( - CrossDomainMessenger.relayMessage.selector, + ICrossDomainMessenger.relayMessage.selector, nonce, address(l2StandardBridge), address(l1StandardBridge), @@ -480,7 +480,7 @@ contract PreBridgeERC20To is Bridge_Initializer { vm.expectCall( address(l2CrossDomainMessenger), - abi.encodeWithSelector(CrossDomainMessenger.sendMessage.selector, address(l1StandardBridge), message, 1000) + abi.encodeWithSelector(ICrossDomainMessenger.sendMessage.selector, address(l1StandardBridge), message, 1000) ); vm.expectCall( @@ -524,7 +524,7 @@ contract L2StandardBridge_Bridge_Test is Bridge_Initializer { function test_finalizeBridgeETH_sendToSelf_reverts() external { vm.mockCall( address(l2StandardBridge.messenger()), - abi.encodeWithSelector(CrossDomainMessenger.xDomainMessageSender.selector), + abi.encodeWithSelector(ICrossDomainMessenger.xDomainMessageSender.selector), abi.encode(address(l2StandardBridge.OTHER_BRIDGE())) ); vm.deal(address(l2CrossDomainMessenger), 100); @@ -537,7 +537,7 @@ contract L2StandardBridge_Bridge_Test is Bridge_Initializer { function test_finalizeBridgeETH_sendToMessenger_reverts() external { vm.mockCall( address(l2StandardBridge.messenger()), - abi.encodeWithSelector(CrossDomainMessenger.xDomainMessageSender.selector), + abi.encodeWithSelector(ICrossDomainMessenger.xDomainMessageSender.selector), abi.encode(address(l2StandardBridge.OTHER_BRIDGE())) ); vm.deal(address(l2CrossDomainMessenger), 100); @@ -563,7 +563,7 @@ contract L2StandardBridge_Bridge_Test is Bridge_Initializer { address(l2CrossDomainMessenger), _value, abi.encodeWithSelector( - CrossDomainMessenger.sendMessage.selector, address(l1StandardBridge), message, _minGasLimit + ICrossDomainMessenger.sendMessage.selector, address(l1StandardBridge), message, _minGasLimit ) ); @@ -611,7 +611,7 @@ contract L2StandardBridge_Bridge_Test is Bridge_Initializer { vm.expectCall( address(l2CrossDomainMessenger), abi.encodeWithSelector( - CrossDomainMessenger.sendMessage.selector, address(l1StandardBridge), message, _minGasLimit + ICrossDomainMessenger.sendMessage.selector, address(l1StandardBridge), message, _minGasLimit ) ); @@ -654,7 +654,7 @@ contract L2StandardBridge_FinalizeBridgeETH_Test is Bridge_Initializer { address messenger = address(l2StandardBridge.messenger()); vm.mockCall( messenger, - abi.encodeWithSelector(CrossDomainMessenger.xDomainMessageSender.selector), + abi.encodeWithSelector(ICrossDomainMessenger.xDomainMessageSender.selector), abi.encode(address(l2StandardBridge.OTHER_BRIDGE())) ); vm.deal(messenger, 100); @@ -674,7 +674,7 @@ contract L2StandardBridge_FinalizeBridgeETH_Test is Bridge_Initializer { address messenger = address(l2StandardBridge.messenger()); vm.mockCall( messenger, - abi.encodeWithSelector(CrossDomainMessenger.xDomainMessageSender.selector), + abi.encodeWithSelector(ICrossDomainMessenger.xDomainMessageSender.selector), abi.encode(address(l2StandardBridge.OTHER_BRIDGE())) ); vm.deal(address(l2CrossDomainMessenger), 1); diff --git a/packages/contracts-bedrock/test/Safe/DeployOwnership.t.sol b/packages/contracts-bedrock/test/Safe/DeployOwnership.t.sol index b3a856e68a40..516c8443f035 100644 --- a/packages/contracts-bedrock/test/Safe/DeployOwnership.t.sol +++ b/packages/contracts-bedrock/test/Safe/DeployOwnership.t.sol @@ -18,7 +18,6 @@ import { GuardManager } from "safe-contracts/base/GuardManager.sol"; import { LivenessGuard } from "src/Safe/LivenessGuard.sol"; import { LivenessModule } from "src/Safe/LivenessModule.sol"; import { DeputyGuardianModule } from "src/Safe/DeputyGuardianModule.sol"; -import { SuperchainConfig } from "src/L1/SuperchainConfig.sol"; contract DeployOwnershipTest is Test, DeployOwnership { address internal constant SENTINEL_MODULES = address(0x1); diff --git a/packages/contracts-bedrock/test/Safe/DeputyGuardianModule.t.sol b/packages/contracts-bedrock/test/Safe/DeputyGuardianModule.t.sol index 5470fe33a5e2..4bc5879bbf64 100644 --- a/packages/contracts-bedrock/test/Safe/DeputyGuardianModule.t.sol +++ b/packages/contracts-bedrock/test/Safe/DeputyGuardianModule.t.sol @@ -278,10 +278,12 @@ contract DeputyGuardianModule_NoPortalCollisions_Test is DeputyGuardianModule_Te /// @dev tests that no function selectors in the L1 contracts collide with the OptimismPortal2 functions called by /// the DeputyGuardianModule. function test_noPortalCollisions_succeeds() external { - string[] memory excludes = new string[](3); - excludes[0] = "src/L1/OptimismPortal2.sol"; - excludes[1] = "src/dispute/lib/*"; + string[] memory excludes = new string[](5); + excludes[0] = "src/dispute/lib/*"; + excludes[1] = "src/L1/OptimismPortal2.sol"; excludes[2] = "src/L1/OptimismPortalInterop.sol"; + excludes[3] = "src/L1/interfaces/IOptimismPortal2.sol"; + excludes[4] = "src/L1/interfaces/IOptimismPortalInterop.sol"; Abi[] memory abis = ForgeArtifacts.getContractFunctionAbis("src/{L1,dispute,universal}", excludes); for (uint256 i; i < abis.length; i++) { for (uint256 j; j < abis[i].entries.length; j++) { diff --git a/packages/contracts-bedrock/test/Specs.t.sol b/packages/contracts-bedrock/test/Specs.t.sol index f9d6a0145bb3..d8b918acf8bc 100644 --- a/packages/contracts-bedrock/test/Specs.t.sol +++ b/packages/contracts-bedrock/test/Specs.t.sol @@ -1,16 +1,24 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.15; +// Testing import { CommonTest } from "test/setup/CommonTest.sol"; import { console2 as console } from "forge-std/console2.sol"; + +// Scripts +import { Executables } from "scripts/libraries/Executables.sol"; +import { ForgeArtifacts, Abi, AbiEntry } from "scripts/libraries/ForgeArtifacts.sol"; + +// Contracts import { ProtocolVersions } from "src/L1/ProtocolVersions.sol"; -import { OptimismPortal } from "src/L1/OptimismPortal.sol"; -import { OptimismPortalInterop } from "src/L1/OptimismPortalInterop.sol"; -import { OptimismPortal2 } from "src/L1/OptimismPortal2.sol"; -import { SystemConfig } from "src/L1/SystemConfig.sol"; -import { DataAvailabilityChallenge } from "src/L1/DataAvailabilityChallenge.sol"; import { OPStackManager } from "src/L1/OPStackManager.sol"; -import { ForgeArtifacts, Abi, AbiEntry } from "scripts/libraries/ForgeArtifacts.sol"; + +// Interfaces +import { IOptimismPortal } from "src/L1/interfaces/IOptimismPortal.sol"; +import { IOptimismPortal2 } from "src/L1/interfaces/IOptimismPortal2.sol"; +import { IOptimismPortalInterop } from "src/L1/interfaces/IOptimismPortalInterop.sol"; +import { ISystemConfig } from "src/L1/interfaces/ISystemConfig.sol"; +import { IDataAvailabilityChallenge } from "src/L1/interfaces/IDataAvailabilityChallenge.sol"; /// @title Specification_Test /// @dev Specifies common security properties of entrypoints to L1 contracts, including authorization and @@ -79,25 +87,25 @@ contract Specification_Test is CommonTest { _addSpec({ _name: "DataAvailabilityChallenge", _sel: _getSel("resolveWindow()") }); _addSpec({ _name: "DataAvailabilityChallenge", _sel: _getSel("resolverRefundPercentage()") }); _addSpec({ _name: "DataAvailabilityChallenge", _sel: _getSel("balances(address)") }); - _addSpec({ _name: "DataAvailabilityChallenge", _sel: DataAvailabilityChallenge.initialize.selector }); + _addSpec({ _name: "DataAvailabilityChallenge", _sel: IDataAvailabilityChallenge.initialize.selector }); _addSpec({ _name: "DataAvailabilityChallenge", - _sel: DataAvailabilityChallenge.setBondSize.selector, + _sel: IDataAvailabilityChallenge.setBondSize.selector, _auth: Role.DATAAVAILABILITYCHALLENGEOWNER }); _addSpec({ _name: "DataAvailabilityChallenge", - _sel: DataAvailabilityChallenge.setResolverRefundPercentage.selector, + _sel: IDataAvailabilityChallenge.setResolverRefundPercentage.selector, _auth: Role.DATAAVAILABILITYCHALLENGEOWNER }); - _addSpec({ _name: "DataAvailabilityChallenge", _sel: DataAvailabilityChallenge.deposit.selector }); - _addSpec({ _name: "DataAvailabilityChallenge", _sel: DataAvailabilityChallenge.withdraw.selector }); - _addSpec({ _name: "DataAvailabilityChallenge", _sel: DataAvailabilityChallenge.getChallenge.selector }); - _addSpec({ _name: "DataAvailabilityChallenge", _sel: DataAvailabilityChallenge.getChallengeStatus.selector }); - _addSpec({ _name: "DataAvailabilityChallenge", _sel: DataAvailabilityChallenge.validateCommitment.selector }); - _addSpec({ _name: "DataAvailabilityChallenge", _sel: DataAvailabilityChallenge.challenge.selector }); - _addSpec({ _name: "DataAvailabilityChallenge", _sel: DataAvailabilityChallenge.resolve.selector }); - _addSpec({ _name: "DataAvailabilityChallenge", _sel: DataAvailabilityChallenge.unlockBond.selector }); + _addSpec({ _name: "DataAvailabilityChallenge", _sel: IDataAvailabilityChallenge.deposit.selector }); + _addSpec({ _name: "DataAvailabilityChallenge", _sel: IDataAvailabilityChallenge.withdraw.selector }); + _addSpec({ _name: "DataAvailabilityChallenge", _sel: IDataAvailabilityChallenge.getChallenge.selector }); + _addSpec({ _name: "DataAvailabilityChallenge", _sel: IDataAvailabilityChallenge.getChallengeStatus.selector }); + _addSpec({ _name: "DataAvailabilityChallenge", _sel: IDataAvailabilityChallenge.validateCommitment.selector }); + _addSpec({ _name: "DataAvailabilityChallenge", _sel: IDataAvailabilityChallenge.challenge.selector }); + _addSpec({ _name: "DataAvailabilityChallenge", _sel: IDataAvailabilityChallenge.resolve.selector }); + _addSpec({ _name: "DataAvailabilityChallenge", _sel: IDataAvailabilityChallenge.unlockBond.selector }); // DelayedVetoable _addSpec({ _name: "DelayedVetoable", _sel: _getSel("delay()") }); @@ -247,7 +255,7 @@ contract Specification_Test is CommonTest { _addSpec({ _name: "OptimismPortal", _sel: _getSel("donateETH()") }); _addSpec({ _name: "OptimismPortal", - _sel: OptimismPortal.finalizeWithdrawalTransaction.selector, + _sel: IOptimismPortal.finalizeWithdrawalTransaction.selector, _pausable: true }); _addSpec({ _name: "OptimismPortal", _sel: _getSel("finalizedWithdrawals(bytes32)") }); @@ -259,7 +267,7 @@ contract Specification_Test is CommonTest { _addSpec({ _name: "OptimismPortal", _sel: _getSel("minimumGasLimit(uint64)") }); _addSpec({ _name: "OptimismPortal", _sel: _getSel("params()") }); _addSpec({ _name: "OptimismPortal", _sel: _getSel("paused()") }); - _addSpec({ _name: "OptimismPortal", _sel: OptimismPortal.proveWithdrawalTransaction.selector, _pausable: true }); + _addSpec({ _name: "OptimismPortal", _sel: IOptimismPortal.proveWithdrawalTransaction.selector, _pausable: true }); _addSpec({ _name: "OptimismPortal", _sel: _getSel("provenWithdrawals(bytes32)") }); _addSpec({ _name: "OptimismPortal", _sel: _getSel("superchainConfig()") }); _addSpec({ _name: "OptimismPortal", _sel: _getSel("systemConfig()") }); @@ -279,12 +287,12 @@ contract Specification_Test is CommonTest { _addSpec({ _name: "OptimismPortalInterop", _sel: _getSel("donateETH()") }); _addSpec({ _name: "OptimismPortalInterop", - _sel: OptimismPortal2.finalizeWithdrawalTransaction.selector, + _sel: IOptimismPortal2.finalizeWithdrawalTransaction.selector, _pausable: true }); _addSpec({ _name: "OptimismPortalInterop", - _sel: OptimismPortal2.finalizeWithdrawalTransactionExternalProof.selector, + _sel: IOptimismPortal2.finalizeWithdrawalTransactionExternalProof.selector, _pausable: true }); _addSpec({ _name: "OptimismPortalInterop", _sel: _getSel("finalizedWithdrawals(bytes32)") }); @@ -296,7 +304,7 @@ contract Specification_Test is CommonTest { _addSpec({ _name: "OptimismPortalInterop", _sel: _getSel("paused()") }); _addSpec({ _name: "OptimismPortalInterop", - _sel: OptimismPortal2.proveWithdrawalTransaction.selector, + _sel: IOptimismPortal2.proveWithdrawalTransaction.selector, _pausable: true }); _addSpec({ _name: "OptimismPortalInterop", _sel: _getSel("provenWithdrawals(bytes32,address)") }); @@ -331,7 +339,7 @@ contract Specification_Test is CommonTest { _addSpec({ _name: "OptimismPortalInterop", _sel: _getSel("setGasPayingToken(address,uint8,bytes32,bytes32)") }); _addSpec({ _name: "OptimismPortalInterop", - _sel: OptimismPortalInterop.setConfig.selector, + _sel: IOptimismPortalInterop.setConfig.selector, _auth: Role.SYSTEMCONFIGOWNER }); @@ -340,12 +348,12 @@ contract Specification_Test is CommonTest { _addSpec({ _name: "OptimismPortal2", _sel: _getSel("donateETH()") }); _addSpec({ _name: "OptimismPortal2", - _sel: OptimismPortal2.finalizeWithdrawalTransaction.selector, + _sel: IOptimismPortal2.finalizeWithdrawalTransaction.selector, _pausable: true }); _addSpec({ _name: "OptimismPortal2", - _sel: OptimismPortal2.finalizeWithdrawalTransactionExternalProof.selector, + _sel: IOptimismPortal2.finalizeWithdrawalTransactionExternalProof.selector, _pausable: true }); _addSpec({ _name: "OptimismPortal2", _sel: _getSel("finalizedWithdrawals(bytes32)") }); @@ -355,7 +363,11 @@ contract Specification_Test is CommonTest { _addSpec({ _name: "OptimismPortal2", _sel: _getSel("minimumGasLimit(uint64)") }); _addSpec({ _name: "OptimismPortal2", _sel: _getSel("params()") }); _addSpec({ _name: "OptimismPortal2", _sel: _getSel("paused()") }); - _addSpec({ _name: "OptimismPortal2", _sel: OptimismPortal2.proveWithdrawalTransaction.selector, _pausable: true }); + _addSpec({ + _name: "OptimismPortal2", + _sel: IOptimismPortal2.proveWithdrawalTransaction.selector, + _pausable: true + }); _addSpec({ _name: "OptimismPortal2", _sel: _getSel("provenWithdrawals(bytes32,address)") }); _addSpec({ _name: "OptimismPortal2", _sel: _getSel("superchainConfig()") }); _addSpec({ _name: "OptimismPortal2", _sel: _getSel("systemConfig()") }); @@ -419,23 +431,23 @@ contract Specification_Test is CommonTest { _addSpec({ _name: "SystemConfig", _sel: _getSel("VERSION()") }); _addSpec({ _name: "SystemConfig", _sel: _getSel("batcherHash()") }); _addSpec({ _name: "SystemConfig", _sel: _getSel("gasLimit()") }); - _addSpec({ _name: "SystemConfig", _sel: SystemConfig.initialize.selector }); - _addSpec({ _name: "SystemConfig", _sel: SystemConfig.minimumGasLimit.selector }); + _addSpec({ _name: "SystemConfig", _sel: ISystemConfig.initialize.selector }); + _addSpec({ _name: "SystemConfig", _sel: ISystemConfig.minimumGasLimit.selector }); _addSpec({ _name: "SystemConfig", _sel: _getSel("overhead()") }); _addSpec({ _name: "SystemConfig", _sel: _getSel("owner()") }); _addSpec({ _name: "SystemConfig", _sel: _getSel("renounceOwnership()"), _auth: Role.SYSTEMCONFIGOWNER }); - _addSpec({ _name: "SystemConfig", _sel: SystemConfig.resourceConfig.selector }); + _addSpec({ _name: "SystemConfig", _sel: ISystemConfig.resourceConfig.selector }); _addSpec({ _name: "SystemConfig", _sel: _getSel("scalar()") }); - _addSpec({ _name: "SystemConfig", _sel: SystemConfig.setBatcherHash.selector, _auth: Role.SYSTEMCONFIGOWNER }); - _addSpec({ _name: "SystemConfig", _sel: SystemConfig.setGasConfig.selector, _auth: Role.SYSTEMCONFIGOWNER }); - _addSpec({ _name: "SystemConfig", _sel: SystemConfig.setGasLimit.selector, _auth: Role.SYSTEMCONFIGOWNER }); + _addSpec({ _name: "SystemConfig", _sel: ISystemConfig.setBatcherHash.selector, _auth: Role.SYSTEMCONFIGOWNER }); + _addSpec({ _name: "SystemConfig", _sel: ISystemConfig.setGasConfig.selector, _auth: Role.SYSTEMCONFIGOWNER }); + _addSpec({ _name: "SystemConfig", _sel: ISystemConfig.setGasLimit.selector, _auth: Role.SYSTEMCONFIGOWNER }); _addSpec({ _name: "SystemConfig", - _sel: SystemConfig.setUnsafeBlockSigner.selector, + _sel: ISystemConfig.setUnsafeBlockSigner.selector, _auth: Role.SYSTEMCONFIGOWNER }); _addSpec({ _name: "SystemConfig", _sel: _getSel("transferOwnership(address)"), _auth: Role.SYSTEMCONFIGOWNER }); - _addSpec({ _name: "SystemConfig", _sel: SystemConfig.unsafeBlockSigner.selector }); + _addSpec({ _name: "SystemConfig", _sel: ISystemConfig.unsafeBlockSigner.selector }); _addSpec({ _name: "SystemConfig", _sel: _getSel("version()") }); _addSpec({ _name: "SystemConfig", _sel: _getSel("l1CrossDomainMessenger()") }); _addSpec({ _name: "SystemConfig", _sel: _getSel("l1ERC721Bridge()") }); @@ -471,27 +483,31 @@ contract Specification_Test is CommonTest { _addSpec({ _name: "SystemConfigInterop", _sel: _getSel("VERSION()") }); _addSpec({ _name: "SystemConfigInterop", _sel: _getSel("batcherHash()") }); _addSpec({ _name: "SystemConfigInterop", _sel: _getSel("gasLimit()") }); - _addSpec({ _name: "SystemConfigInterop", _sel: SystemConfig.initialize.selector }); - _addSpec({ _name: "SystemConfigInterop", _sel: SystemConfig.minimumGasLimit.selector }); + _addSpec({ _name: "SystemConfigInterop", _sel: ISystemConfig.initialize.selector }); + _addSpec({ _name: "SystemConfigInterop", _sel: ISystemConfig.minimumGasLimit.selector }); _addSpec({ _name: "SystemConfigInterop", _sel: _getSel("overhead()") }); _addSpec({ _name: "SystemConfigInterop", _sel: _getSel("owner()") }); _addSpec({ _name: "SystemConfigInterop", _sel: _getSel("renounceOwnership()"), _auth: Role.SYSTEMCONFIGOWNER }); - _addSpec({ _name: "SystemConfigInterop", _sel: SystemConfig.resourceConfig.selector }); + _addSpec({ _name: "SystemConfigInterop", _sel: ISystemConfig.resourceConfig.selector }); _addSpec({ _name: "SystemConfigInterop", _sel: _getSel("scalar()") }); _addSpec({ _name: "SystemConfigInterop", - _sel: SystemConfig.setBatcherHash.selector, + _sel: ISystemConfig.setBatcherHash.selector, + _auth: Role.SYSTEMCONFIGOWNER + }); + _addSpec({ + _name: "SystemConfigInterop", + _sel: ISystemConfig.setGasConfig.selector, _auth: Role.SYSTEMCONFIGOWNER }); _addSpec({ _name: "SystemConfigInterop", - _sel: SystemConfig.setGasConfig.selector, + _sel: ISystemConfig.setGasLimit.selector, _auth: Role.SYSTEMCONFIGOWNER }); - _addSpec({ _name: "SystemConfigInterop", _sel: SystemConfig.setGasLimit.selector, _auth: Role.SYSTEMCONFIGOWNER }); _addSpec({ _name: "SystemConfigInterop", - _sel: SystemConfig.setUnsafeBlockSigner.selector, + _sel: ISystemConfig.setUnsafeBlockSigner.selector, _auth: Role.SYSTEMCONFIGOWNER }); _addSpec({ @@ -499,7 +515,7 @@ contract Specification_Test is CommonTest { _sel: _getSel("transferOwnership(address)"), _auth: Role.SYSTEMCONFIGOWNER }); - _addSpec({ _name: "SystemConfigInterop", _sel: SystemConfig.unsafeBlockSigner.selector }); + _addSpec({ _name: "SystemConfigInterop", _sel: ISystemConfig.unsafeBlockSigner.selector }); _addSpec({ _name: "SystemConfigInterop", _sel: _getSel("version()") }); _addSpec({ _name: "SystemConfigInterop", _sel: _getSel("l1CrossDomainMessenger()") }); _addSpec({ _name: "SystemConfigInterop", _sel: _getSel("l1ERC721Bridge()") }); diff --git a/packages/contracts-bedrock/test/invariants/CrossDomainMessenger.t.sol b/packages/contracts-bedrock/test/invariants/CrossDomainMessenger.t.sol index b0b64253493b..08a0c0027763 100644 --- a/packages/contracts-bedrock/test/invariants/CrossDomainMessenger.t.sol +++ b/packages/contracts-bedrock/test/invariants/CrossDomainMessenger.t.sol @@ -3,8 +3,8 @@ pragma solidity 0.8.15; import { StdUtils } from "forge-std/StdUtils.sol"; import { Vm } from "forge-std/Vm.sol"; -import { OptimismPortal } from "src/L1/OptimismPortal.sol"; -import { L1CrossDomainMessenger } from "src/L1/L1CrossDomainMessenger.sol"; +import { IOptimismPortal } from "src/L1/interfaces/IOptimismPortal.sol"; +import { IL1CrossDomainMessenger } from "src/L1/interfaces/IL1CrossDomainMessenger.sol"; import { Bridge_Initializer } from "test/setup/Bridge_Initializer.sol"; import { Predeploys } from "src/libraries/Predeploys.sol"; import { Constants } from "src/libraries/Constants.sol"; @@ -20,12 +20,12 @@ contract RelayActor is StdUtils { bytes32[] public hashes; bool public reverted = false; - OptimismPortal op; - L1CrossDomainMessenger xdm; + IOptimismPortal op; + IL1CrossDomainMessenger xdm; Vm vm; bool doFail; - constructor(OptimismPortal _op, L1CrossDomainMessenger _xdm, Vm _vm, bool _doFail) { + constructor(IOptimismPortal _op, IL1CrossDomainMessenger _xdm, Vm _vm, bool _doFail) { op = _op; xdm = _xdm; vm = _vm; diff --git a/packages/contracts-bedrock/test/invariants/OptimismPortal.t.sol b/packages/contracts-bedrock/test/invariants/OptimismPortal.t.sol index 0dc020f9d7fa..8e5319d9aeb6 100644 --- a/packages/contracts-bedrock/test/invariants/OptimismPortal.t.sol +++ b/packages/contracts-bedrock/test/invariants/OptimismPortal.t.sol @@ -4,8 +4,9 @@ pragma solidity 0.8.15; import { StdUtils } from "forge-std/Test.sol"; import { Vm } from "forge-std/Vm.sol"; -import { OptimismPortal } from "src/L1/OptimismPortal.sol"; +import { IOptimismPortal } from "src/L1/interfaces/IOptimismPortal.sol"; 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"; @@ -14,10 +15,10 @@ import { Types } from "src/libraries/Types.sol"; contract OptimismPortal_Depositor is StdUtils, ResourceMetering { Vm internal vm; - OptimismPortal internal portal; + IOptimismPortal internal portal; bool public failedToComplete; - constructor(Vm _vm, OptimismPortal _portal) { + constructor(Vm _vm, IOptimismPortal _portal) { vm = _vm; portal = _portal; initialize(); @@ -31,9 +32,11 @@ contract OptimismPortal_Depositor is StdUtils, ResourceMetering { return _resourceConfig(); } - function _resourceConfig() internal pure override returns (ResourceMetering.ResourceConfig memory) { - ResourceMetering.ResourceConfig memory rcfg = Constants.DEFAULT_RESOURCE_CONFIG(); - return rcfg; + function _resourceConfig() internal pure override returns (ResourceMetering.ResourceConfig memory config_) { + IResourceMetering.ResourceConfig memory rcfg = Constants.DEFAULT_RESOURCE_CONFIG(); + assembly ("memory-safe") { + config_ := rcfg + } } // A test intended to identify any unexpected halting conditions diff --git a/packages/contracts-bedrock/test/invariants/OptimismPortal2.t.sol b/packages/contracts-bedrock/test/invariants/OptimismPortal2.t.sol index 56c2c1849feb..ef96f3eb5c4f 100644 --- a/packages/contracts-bedrock/test/invariants/OptimismPortal2.t.sol +++ b/packages/contracts-bedrock/test/invariants/OptimismPortal2.t.sol @@ -4,10 +4,10 @@ pragma solidity 0.8.15; import { StdUtils } from "forge-std/Test.sol"; import { Vm } from "forge-std/Vm.sol"; -import { OptimismPortal2 } from "src/L1/OptimismPortal2.sol"; +import { IOptimismPortal2 } from "src/L1/interfaces/IOptimismPortal2.sol"; import { AddressAliasHelper } from "src/vendor/AddressAliasHelper.sol"; -import { SystemConfig } from "src/L1/SystemConfig.sol"; 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"; @@ -20,10 +20,10 @@ import "src/libraries/PortalErrors.sol"; contract OptimismPortal2_Depositor is StdUtils, ResourceMetering { Vm internal vm; - OptimismPortal2 internal portal; + IOptimismPortal2 internal portal; bool public failedToComplete; - constructor(Vm _vm, OptimismPortal2 _portal) { + constructor(Vm _vm, IOptimismPortal2 _portal) { vm = _vm; portal = _portal; initialize(); @@ -37,9 +37,11 @@ contract OptimismPortal2_Depositor is StdUtils, ResourceMetering { return _resourceConfig(); } - function _resourceConfig() internal pure override returns (ResourceMetering.ResourceConfig memory) { - ResourceMetering.ResourceConfig memory rcfg = Constants.DEFAULT_RESOURCE_CONFIG(); - return rcfg; + function _resourceConfig() internal pure override returns (ResourceMetering.ResourceConfig memory config_) { + IResourceMetering.ResourceConfig memory rcfg = Constants.DEFAULT_RESOURCE_CONFIG(); + assembly ("memory-safe") { + config_ := rcfg + } } // A test intended to identify any unexpected halting conditions diff --git a/packages/contracts-bedrock/test/invariants/ResourceMetering.t.sol b/packages/contracts-bedrock/test/invariants/ResourceMetering.t.sol index 39e54590efbb..4652f9b9e36e 100644 --- a/packages/contracts-bedrock/test/invariants/ResourceMetering.t.sol +++ b/packages/contracts-bedrock/test/invariants/ResourceMetering.t.sol @@ -8,6 +8,7 @@ import { StdInvariant } from "forge-std/StdInvariant.sol"; import { Arithmetic } from "src/libraries/Arithmetic.sol"; import { ResourceMetering } from "src/L1/ResourceMetering.sol"; +import { IResourceMetering } from "src/L1/interfaces/IResourceMetering.sol"; import { Constants } from "src/libraries/Constants.sol"; import { InvariantTest } from "test/invariants/InvariantTest.sol"; @@ -35,9 +36,11 @@ contract ResourceMetering_User is StdUtils, ResourceMetering { return _resourceConfig(); } - function _resourceConfig() internal pure override returns (ResourceMetering.ResourceConfig memory) { - ResourceMetering.ResourceConfig memory rcfg = Constants.DEFAULT_RESOURCE_CONFIG(); - return rcfg; + function _resourceConfig() internal pure override returns (ResourceMetering.ResourceConfig memory config_) { + IResourceMetering.ResourceConfig memory rcfg = Constants.DEFAULT_RESOURCE_CONFIG(); + assembly ("memory-safe") { + config_ := rcfg + } } /// @notice Takes the necessary parameters to allow us to burn arbitrary amounts of gas to test diff --git a/packages/contracts-bedrock/test/invariants/SystemConfig.t.sol b/packages/contracts-bedrock/test/invariants/SystemConfig.t.sol index 8419113917f4..1321499462b7 100644 --- a/packages/contracts-bedrock/test/invariants/SystemConfig.t.sol +++ b/packages/contracts-bedrock/test/invariants/SystemConfig.t.sol @@ -3,15 +3,16 @@ pragma solidity 0.8.15; import { Test } from "forge-std/Test.sol"; import { SystemConfig } from "src/L1/SystemConfig.sol"; +import { ISystemConfig } from "src/L1/interfaces/ISystemConfig.sol"; import { Proxy } from "src/universal/Proxy.sol"; import { Constants } from "src/libraries/Constants.sol"; contract SystemConfig_GasLimitBoundaries_Invariant is Test { - SystemConfig public config; + ISystemConfig public config; function setUp() external { Proxy proxy = new Proxy(msg.sender); - SystemConfig configImpl = new SystemConfig(); + ISystemConfig configImpl = ISystemConfig(address(new SystemConfig())); vm.prank(msg.sender); proxy.upgradeToAndCall( @@ -27,7 +28,7 @@ contract SystemConfig_GasLimitBoundaries_Invariant is Test { address(1), // unsafe block signer Constants.DEFAULT_RESOURCE_CONFIG(), address(0), // _batchInbox - SystemConfig.Addresses({ // _addrs + ISystemConfig.Addresses({ // _addrs l1CrossDomainMessenger: address(0), l1ERC721Bridge: address(0), l1StandardBridge: address(0), @@ -40,7 +41,7 @@ contract SystemConfig_GasLimitBoundaries_Invariant is Test { ) ); - config = SystemConfig(address(proxy)); + config = ISystemConfig(address(proxy)); // Set the target contract to the `config` targetContract(address(config)); diff --git a/packages/contracts-bedrock/test/setup/Setup.sol b/packages/contracts-bedrock/test/setup/Setup.sol index a39c996d7bfe..0d8db00009cb 100644 --- a/packages/contracts-bedrock/test/setup/Setup.sol +++ b/packages/contracts-bedrock/test/setup/Setup.sol @@ -1,9 +1,19 @@ // SPDX-License-Identifier: MIT pragma solidity 0.8.15; +// Testing import { console2 as console } from "forge-std/console2.sol"; -import { Predeploys } from "src/libraries/Predeploys.sol"; -import { Preinstalls } from "src/libraries/Preinstalls.sol"; +import { Vm } from "forge-std/Vm.sol"; + +// Scripts +import { DeployConfig } from "scripts/deploy/DeployConfig.s.sol"; +import { Deploy } from "scripts/deploy/Deploy.s.sol"; +import { Fork, LATEST_FORK } from "scripts/libraries/Config.sol"; +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 { L2CrossDomainMessenger } from "src/L2/L2CrossDomainMessenger.sol"; import { L2StandardBridgeInterop } from "src/L2/L2StandardBridgeInterop.sol"; import { L2ToL1MessagePasser } from "src/L2/L2ToL1MessagePasser.sol"; @@ -18,31 +28,30 @@ import { GovernanceToken } from "src/governance/GovernanceToken.sol"; import { OptimismMintableERC20Factory } from "src/universal/OptimismMintableERC20Factory.sol"; import { StandardBridge } from "src/universal/StandardBridge.sol"; import { FeeVault } from "src/universal/FeeVault.sol"; -import { OptimismPortal } from "src/L1/OptimismPortal.sol"; -import { OptimismPortal2 } from "src/L1/OptimismPortal2.sol"; import { DisputeGameFactory } from "src/dispute/DisputeGameFactory.sol"; import { DelayedWETH } from "src/dispute/weth/DelayedWETH.sol"; import { AnchorStateRegistry } from "src/dispute/AnchorStateRegistry.sol"; -import { L1CrossDomainMessenger } from "src/L1/L1CrossDomainMessenger.sol"; -import { DeployConfig } from "scripts/deploy/DeployConfig.s.sol"; -import { Deploy } from "scripts/deploy/Deploy.s.sol"; -import { Fork, LATEST_FORK } from "scripts/libraries/Config.sol"; -import { L2Genesis, L1Dependencies } from "scripts/L2Genesis.s.sol"; -import { OutputMode, Fork, ForkUtils } from "scripts/libraries/Config.sol"; -import { IL2OutputOracle } from "src/L1/interfaces/IL2OutputOracle.sol"; import { ProtocolVersions } from "src/L1/ProtocolVersions.sol"; -import { SystemConfig } from "src/L1/SystemConfig.sol"; import { L1StandardBridge } from "src/L1/L1StandardBridge.sol"; import { AddressManager } from "src/legacy/AddressManager.sol"; -import { L1ERC721Bridge } from "src/L1/L1ERC721Bridge.sol"; -import { AddressAliasHelper } from "src/vendor/AddressAliasHelper.sol"; -import { Executables } from "scripts/libraries/Executables.sol"; -import { Vm } from "forge-std/Vm.sol"; -import { SuperchainConfig } from "src/L1/SuperchainConfig.sol"; -import { DataAvailabilityChallenge } from "src/L1/DataAvailabilityChallenge.sol"; import { WETH } from "src/L2/WETH.sol"; import { SuperchainWETH } from "src/L2/SuperchainWETH.sol"; import { ETHLiquidity } from "src/L2/ETHLiquidity.sol"; +import { L1ERC721Bridge } from "src/L1/L1ERC721Bridge.sol"; + +// Libraries +import { Predeploys } from "src/libraries/Predeploys.sol"; +import { Preinstalls } from "src/libraries/Preinstalls.sol"; +import { AddressAliasHelper } from "src/vendor/AddressAliasHelper.sol"; + +// Interfaces +import { IOptimismPortal } from "src/L1/interfaces/IOptimismPortal.sol"; +import { IOptimismPortal2 } from "src/L1/interfaces/IOptimismPortal2.sol"; +import { IL1CrossDomainMessenger } from "src/L1/interfaces/IL1CrossDomainMessenger.sol"; +import { IL2OutputOracle } from "src/L1/interfaces/IL2OutputOracle.sol"; +import { ISystemConfig } from "src/L1/interfaces/ISystemConfig.sol"; +import { ISuperchainConfig } from "src/L1/interfaces/ISuperchainConfig.sol"; +import { IDataAvailabilityChallenge } from "src/L1/interfaces/IDataAvailabilityChallenge.sol"; /// @title Setup /// @dev This contact is responsible for setting up the contracts in state. It currently @@ -65,20 +74,20 @@ contract Setup { // @notice Allows users of Setup to override what L2 genesis is being created. Fork l2Fork = LATEST_FORK; - OptimismPortal optimismPortal; - OptimismPortal2 optimismPortal2; + IOptimismPortal optimismPortal; + IOptimismPortal2 optimismPortal2; DisputeGameFactory disputeGameFactory; DelayedWETH delayedWeth; IL2OutputOracle l2OutputOracle; - SystemConfig systemConfig; + ISystemConfig systemConfig; L1StandardBridge l1StandardBridge; - L1CrossDomainMessenger l1CrossDomainMessenger; + IL1CrossDomainMessenger l1CrossDomainMessenger; AddressManager addressManager; L1ERC721Bridge l1ERC721Bridge; OptimismMintableERC20Factory l1OptimismMintableERC20Factory; ProtocolVersions protocolVersions; - SuperchainConfig superchainConfig; - DataAvailabilityChallenge dataAvailabilityChallenge; + ISuperchainConfig superchainConfig; + IDataAvailabilityChallenge dataAvailabilityChallenge; AnchorStateRegistry anchorStateRegistry; L2CrossDomainMessenger l2CrossDomainMessenger = @@ -131,20 +140,20 @@ contract Setup { deploy.run(); console.log("Setup: completed L1 deployment, registering addresses now"); - optimismPortal = OptimismPortal(deploy.mustGetAddress("OptimismPortalProxy")); - optimismPortal2 = OptimismPortal2(deploy.mustGetAddress("OptimismPortalProxy")); + optimismPortal = IOptimismPortal(deploy.mustGetAddress("OptimismPortalProxy")); + optimismPortal2 = IOptimismPortal2(deploy.mustGetAddress("OptimismPortalProxy")); disputeGameFactory = DisputeGameFactory(deploy.mustGetAddress("DisputeGameFactoryProxy")); delayedWeth = DelayedWETH(deploy.mustGetAddress("DelayedWETHProxy")); l2OutputOracle = IL2OutputOracle(deploy.mustGetAddress("L2OutputOracleProxy")); - systemConfig = SystemConfig(deploy.mustGetAddress("SystemConfigProxy")); + systemConfig = ISystemConfig(deploy.mustGetAddress("SystemConfigProxy")); l1StandardBridge = L1StandardBridge(deploy.mustGetAddress("L1StandardBridgeProxy")); - l1CrossDomainMessenger = L1CrossDomainMessenger(deploy.mustGetAddress("L1CrossDomainMessengerProxy")); + l1CrossDomainMessenger = IL1CrossDomainMessenger(deploy.mustGetAddress("L1CrossDomainMessengerProxy")); addressManager = AddressManager(deploy.mustGetAddress("AddressManager")); l1ERC721Bridge = L1ERC721Bridge(deploy.mustGetAddress("L1ERC721BridgeProxy")); l1OptimismMintableERC20Factory = OptimismMintableERC20Factory(deploy.mustGetAddress("OptimismMintableERC20FactoryProxy")); protocolVersions = ProtocolVersions(deploy.mustGetAddress("ProtocolVersionsProxy")); - superchainConfig = SuperchainConfig(deploy.mustGetAddress("SuperchainConfigProxy")); + superchainConfig = ISuperchainConfig(deploy.mustGetAddress("SuperchainConfigProxy")); anchorStateRegistry = AnchorStateRegistry(deploy.mustGetAddress("AnchorStateRegistryProxy")); vm.label(address(l2OutputOracle), "L2OutputOracle"); @@ -174,7 +183,7 @@ contract Setup { if (deploy.cfg().useAltDA()) { dataAvailabilityChallenge = - DataAvailabilityChallenge(deploy.mustGetAddress("DataAvailabilityChallengeProxy")); + IDataAvailabilityChallenge(deploy.mustGetAddress("DataAvailabilityChallengeProxy")); vm.label(address(dataAvailabilityChallenge), "DataAvailabilityChallengeProxy"); vm.label(deploy.mustGetAddress("DataAvailabilityChallenge"), "DataAvailabilityChallenge"); } diff --git a/packages/contracts-bedrock/test/universal/CrossDomainMessenger.t.sol b/packages/contracts-bedrock/test/universal/CrossDomainMessenger.t.sol index f2a9a8d43d85..1fab9c6db1ce 100644 --- a/packages/contracts-bedrock/test/universal/CrossDomainMessenger.t.sol +++ b/packages/contracts-bedrock/test/universal/CrossDomainMessenger.t.sol @@ -11,7 +11,7 @@ import { Predeploys } from "src/libraries/Predeploys.sol"; import { Hashing } from "src/libraries/Hashing.sol"; import { Encoding } from "src/libraries/Encoding.sol"; -import { L1CrossDomainMessenger } from "src/L1/L1CrossDomainMessenger.sol"; +import { IL1CrossDomainMessenger } from "src/L1/interfaces/IL1CrossDomainMessenger.sol"; // CrossDomainMessenger_Test is for testing functionality which is common to both the L1 and L2 // CrossDomainMessenger contracts. For simplicity, we use the L1 Messenger as the test contract. @@ -45,11 +45,11 @@ contract CrossDomainMessenger_BaseGas_Test is Bridge_Initializer { contract ExternalRelay is Test { address internal op; address internal fuzzedSender; - L1CrossDomainMessenger internal l1CrossDomainMessenger; + IL1CrossDomainMessenger internal l1CrossDomainMessenger; event FailedRelayedMessage(bytes32 indexed msgHash); - constructor(L1CrossDomainMessenger _l1Messenger, address _op) { + constructor(IL1CrossDomainMessenger _l1Messenger, address _op) { l1CrossDomainMessenger = _l1Messenger; op = _op; } diff --git a/packages/contracts-bedrock/test/vendor/Initializable.t.sol b/packages/contracts-bedrock/test/vendor/Initializable.t.sol index 1f3ab1951ae3..52566f95ec1b 100644 --- a/packages/contracts-bedrock/test/vendor/Initializable.t.sol +++ b/packages/contracts-bedrock/test/vendor/Initializable.t.sol @@ -6,11 +6,11 @@ import { Bridge_Initializer } from "test/setup/Bridge_Initializer.sol"; import { Executables } from "scripts/libraries/Executables.sol"; import { Constants } from "src/libraries/Constants.sol"; import { CrossDomainMessenger } from "src/universal/CrossDomainMessenger.sol"; -import { SystemConfig } from "src/L1/SystemConfig.sol"; +import { ICrossDomainMessenger } from "src/universal/interfaces/ICrossDomainMessenger.sol"; +import { ISystemConfig } from "src/L1/interfaces/ISystemConfig.sol"; +import { IResourceMetering } from "src/L1/interfaces/IResourceMetering.sol"; import { SystemConfigInterop } from "src/L1/SystemConfigInterop.sol"; -import { SuperchainConfig } from "src/L1/SuperchainConfig.sol"; -import { ResourceMetering } from "src/L1/ResourceMetering.sol"; -import { OptimismPortal } from "src/L1/OptimismPortal.sol"; +import { ISuperchainConfig } from "src/L1/interfaces/ISuperchainConfig.sol"; import { AnchorStateRegistry } from "src/dispute/AnchorStateRegistry.sol"; import { FaultDisputeGame } from "src/dispute/FaultDisputeGame.sol"; import { PermissionedDisputeGame } from "src/dispute/PermissionedDisputeGame.sol"; @@ -108,7 +108,7 @@ contract Initializer_Test is Bridge_Initializer { InitializeableContract({ name: "DelayedWETH", target: deploy.mustGetAddress("DelayedWETH"), - initCalldata: abi.encodeCall(delayedWeth.initialize, (address(0), SuperchainConfig(address(0)))) + initCalldata: abi.encodeCall(delayedWeth.initialize, (address(0), ISuperchainConfig(address(0)))) }) ); // DelayedWETHProxy @@ -116,7 +116,7 @@ contract Initializer_Test is Bridge_Initializer { InitializeableContract({ name: "DelayedWETHProxy", target: address(delayedWeth), - initCalldata: abi.encodeCall(delayedWeth.initialize, (address(0), SuperchainConfig(address(0)))) + initCalldata: abi.encodeCall(delayedWeth.initialize, (address(0), ISuperchainConfig(address(0)))) }) ); // L2OutputOracleImpl @@ -181,7 +181,7 @@ contract Initializer_Test is Bridge_Initializer { bytes32(0), 1, address(0), - ResourceMetering.ResourceConfig({ + IResourceMetering.ResourceConfig({ maxResourceLimit: 1, elasticityMultiplier: 1, baseFeeMaxChangeDenominator: 2, @@ -190,7 +190,7 @@ contract Initializer_Test is Bridge_Initializer { maximumBaseFee: 0 }), address(0), - SystemConfig.Addresses({ + ISystemConfig.Addresses({ l1CrossDomainMessenger: address(0), l1ERC721Bridge: address(0), l1StandardBridge: address(0), @@ -217,7 +217,7 @@ contract Initializer_Test is Bridge_Initializer { bytes32(0), 1, address(0), - ResourceMetering.ResourceConfig({ + IResourceMetering.ResourceConfig({ maxResourceLimit: 1, elasticityMultiplier: 1, baseFeeMaxChangeDenominator: 2, @@ -226,7 +226,7 @@ contract Initializer_Test is Bridge_Initializer { maximumBaseFee: 0 }), address(0), - SystemConfig.Addresses({ + ISystemConfig.Addresses({ l1CrossDomainMessenger: address(0), l1ERC721Bridge: address(0), l1StandardBridge: address(0), @@ -264,7 +264,9 @@ contract Initializer_Test is Bridge_Initializer { InitializeableContract({ name: "L2CrossDomainMessenger", target: address(l2CrossDomainMessenger), - initCalldata: abi.encodeCall(l2CrossDomainMessenger.initialize, (l1CrossDomainMessenger)) + initCalldata: abi.encodeCall( + l2CrossDomainMessenger.initialize, (CrossDomainMessenger(address(l1CrossDomainMessenger))) + ) }) ); // L1StandardBridgeImpl @@ -273,7 +275,8 @@ contract Initializer_Test is Bridge_Initializer { name: "L1StandardBridge", target: deploy.mustGetAddress("L1StandardBridge"), initCalldata: abi.encodeCall( - l1StandardBridge.initialize, (l1CrossDomainMessenger, superchainConfig, systemConfig) + l1StandardBridge.initialize, + (ICrossDomainMessenger(address(l1CrossDomainMessenger)), superchainConfig, systemConfig) ) }) ); @@ -283,7 +286,8 @@ contract Initializer_Test is Bridge_Initializer { name: "L1StandardBridgeProxy", target: address(l1StandardBridge), initCalldata: abi.encodeCall( - l1StandardBridge.initialize, (l1CrossDomainMessenger, superchainConfig, systemConfig) + l1StandardBridge.initialize, + (ICrossDomainMessenger(address(l1CrossDomainMessenger)), superchainConfig, systemConfig) ) }) ); @@ -308,7 +312,9 @@ contract Initializer_Test is Bridge_Initializer { InitializeableContract({ name: "L1ERC721Bridge", target: deploy.mustGetAddress("L1ERC721Bridge"), - initCalldata: abi.encodeCall(l1ERC721Bridge.initialize, (l1CrossDomainMessenger, superchainConfig)) + initCalldata: abi.encodeCall( + l1ERC721Bridge.initialize, (ICrossDomainMessenger(address(l1CrossDomainMessenger)), superchainConfig) + ) }) ); // L1ERC721BridgeProxy @@ -316,7 +322,9 @@ contract Initializer_Test is Bridge_Initializer { InitializeableContract({ name: "L1ERC721BridgeProxy", target: address(l1ERC721Bridge), - initCalldata: abi.encodeCall(l1ERC721Bridge.initialize, (l1CrossDomainMessenger, superchainConfig)) + initCalldata: abi.encodeCall( + l1ERC721Bridge.initialize, (ICrossDomainMessenger(address(l1CrossDomainMessenger)), superchainConfig) + ) }) ); // L2ERC721Bridge @@ -366,7 +374,7 @@ contract Initializer_Test is Bridge_Initializer { target: address(anchorStateRegistry), initCalldata: abi.encodeCall( anchorStateRegistry.initialize, - (new AnchorStateRegistry.StartingAnchorRoot[](1), SuperchainConfig(address(0))) + (new AnchorStateRegistry.StartingAnchorRoot[](1), ISuperchainConfig(address(0))) ) }) ); @@ -377,7 +385,7 @@ contract Initializer_Test is Bridge_Initializer { target: address(anchorStateRegistry), initCalldata: abi.encodeCall( anchorStateRegistry.initialize, - (new AnchorStateRegistry.StartingAnchorRoot[](1), SuperchainConfig(address(0))) + (new AnchorStateRegistry.StartingAnchorRoot[](1), ISuperchainConfig(address(0))) ) }) );