Commit 8eada51c authored by Maurelian's avatar Maurelian Committed by GitHub

Add error codes to ChainAssertions (#12279)

* feat: Add reasons to checkOptimismPortal2

* feat: log if impl of proxy add more functions

* feat: More ChainAssertions reason strings

* feat: checkDisputeGameFactory for isProxy

* feat: Final checkAssertions error codes
parent 35426c1f
...@@ -67,8 +67,12 @@ library ChainAssertions { ...@@ -67,8 +67,12 @@ library ChainAssertions {
/// @notice Asserts that the SystemConfig is setup correctly /// @notice Asserts that the SystemConfig is setup correctly
function checkSystemConfig(Types.ContractSet memory _contracts, DeployConfig _cfg, bool _isProxy) internal view { function checkSystemConfig(Types.ContractSet memory _contracts, DeployConfig _cfg, bool _isProxy) internal view {
console.log("Running chain assertions on the SystemConfig");
ISystemConfig config = ISystemConfig(_contracts.SystemConfig); ISystemConfig config = ISystemConfig(_contracts.SystemConfig);
console.log(
"Running chain assertions on the SystemConfig %s at %s",
_isProxy ? "proxy" : "implementation",
address(config)
);
// Check that the contract is initialized // Check that the contract is initialized
assertSlotValueIsOne({ _contractAddress: address(config), _slot: 0, _offset: 0 }); assertSlotValueIsOne({ _contractAddress: address(config), _slot: 0, _offset: 0 });
...@@ -76,116 +80,139 @@ library ChainAssertions { ...@@ -76,116 +80,139 @@ library ChainAssertions {
IResourceMetering.ResourceConfig memory resourceConfig = config.resourceConfig(); IResourceMetering.ResourceConfig memory resourceConfig = config.resourceConfig();
if (_isProxy) { if (_isProxy) {
require(config.owner() == _cfg.finalSystemOwner()); require(config.owner() == _cfg.finalSystemOwner(), "CHECK-SCFG-10");
require(config.basefeeScalar() == _cfg.basefeeScalar()); require(config.basefeeScalar() == _cfg.basefeeScalar(), "CHECK-SCFG-20");
require(config.blobbasefeeScalar() == _cfg.blobbasefeeScalar()); require(config.blobbasefeeScalar() == _cfg.blobbasefeeScalar(), "CHECK-SCFG-30");
require(config.batcherHash() == bytes32(uint256(uint160(_cfg.batchSenderAddress())))); require(config.batcherHash() == bytes32(uint256(uint160(_cfg.batchSenderAddress()))), "CHECK-SCFG-40");
require(config.gasLimit() == uint64(_cfg.l2GenesisBlockGasLimit())); require(config.gasLimit() == uint64(_cfg.l2GenesisBlockGasLimit()), "CHECK-SCFG-50");
require(config.unsafeBlockSigner() == _cfg.p2pSequencerAddress()); require(config.unsafeBlockSigner() == _cfg.p2pSequencerAddress(), "CHECK-SCFG-60");
require(config.scalar() >> 248 == 1); require(config.scalar() >> 248 == 1, "CHECK-SCFG-70");
// Check _config // Check _config
IResourceMetering.ResourceConfig memory rconfig = Constants.DEFAULT_RESOURCE_CONFIG(); IResourceMetering.ResourceConfig memory rconfig = Constants.DEFAULT_RESOURCE_CONFIG();
require(resourceConfig.maxResourceLimit == rconfig.maxResourceLimit); require(resourceConfig.maxResourceLimit == rconfig.maxResourceLimit, "CHECK-SCFG-80");
require(resourceConfig.elasticityMultiplier == rconfig.elasticityMultiplier); require(resourceConfig.elasticityMultiplier == rconfig.elasticityMultiplier, "CHECK-SCFG-90");
require(resourceConfig.baseFeeMaxChangeDenominator == rconfig.baseFeeMaxChangeDenominator); require(resourceConfig.baseFeeMaxChangeDenominator == rconfig.baseFeeMaxChangeDenominator, "CHECK-SCFG-100");
require(resourceConfig.systemTxMaxGas == rconfig.systemTxMaxGas); require(resourceConfig.systemTxMaxGas == rconfig.systemTxMaxGas, "CHECK-SCFG-110");
require(resourceConfig.minimumBaseFee == rconfig.minimumBaseFee); require(resourceConfig.minimumBaseFee == rconfig.minimumBaseFee, "CHECK-SCFG-120");
require(resourceConfig.maximumBaseFee == rconfig.maximumBaseFee); require(resourceConfig.maximumBaseFee == rconfig.maximumBaseFee, "CHECK-SCFG-130");
// Depends on start block being set to 0 in `initialize` // Depends on start block being set to 0 in `initialize`
uint256 cfgStartBlock = _cfg.systemConfigStartBlock(); uint256 cfgStartBlock = _cfg.systemConfigStartBlock();
require(config.startBlock() == (cfgStartBlock == 0 ? block.number : cfgStartBlock)); require(config.startBlock() == (cfgStartBlock == 0 ? block.number : cfgStartBlock), "CHECK-SCFG-140");
require(config.batchInbox() == _cfg.batchInboxAddress()); require(config.batchInbox() == _cfg.batchInboxAddress(), "CHECK-SCFG-150");
// Check _addresses // Check _addresses
require(config.l1CrossDomainMessenger() == _contracts.L1CrossDomainMessenger); require(config.l1CrossDomainMessenger() == _contracts.L1CrossDomainMessenger, "CHECK-SCFG-160");
require(config.l1ERC721Bridge() == _contracts.L1ERC721Bridge); require(config.l1ERC721Bridge() == _contracts.L1ERC721Bridge, "CHECK-SCFG-170");
require(config.l1StandardBridge() == _contracts.L1StandardBridge); require(config.l1StandardBridge() == _contracts.L1StandardBridge, "CHECK-SCFG-180");
require(config.disputeGameFactory() == _contracts.DisputeGameFactory); require(config.disputeGameFactory() == _contracts.DisputeGameFactory, "CHECK-SCFG-190");
require(config.optimismPortal() == _contracts.OptimismPortal); require(config.optimismPortal() == _contracts.OptimismPortal, "CHECK-SCFG-200");
require(config.optimismMintableERC20Factory() == _contracts.OptimismMintableERC20Factory); require(config.optimismMintableERC20Factory() == _contracts.OptimismMintableERC20Factory, "CHECK-SCFG-210");
} else { } else {
require(config.owner() == address(0xdead)); require(config.owner() == address(0xdead), "CHECK-SCFG-220");
require(config.overhead() == 0); require(config.overhead() == 0, "CHECK-SCFG-230");
require(config.scalar() == uint256(0x01) << 248); // version 1 require(config.scalar() == uint256(0x01) << 248, "CHECK-SCFG-240"); // version 1
require(config.basefeeScalar() == 0); require(config.basefeeScalar() == 0, "CHECK-SCFG-250");
require(config.blobbasefeeScalar() == 0); require(config.blobbasefeeScalar() == 0, "CHECK-SCFG-260");
require(config.batcherHash() == bytes32(0)); require(config.batcherHash() == bytes32(0), "CHECK-SCFG-270");
require(config.gasLimit() == 1); require(config.gasLimit() == 1, "CHECK-SCFG-280");
require(config.unsafeBlockSigner() == address(0)); require(config.unsafeBlockSigner() == address(0), "CHECK-SCFG-290");
// Check _config // Check _config
require(resourceConfig.maxResourceLimit == 1); require(resourceConfig.maxResourceLimit == 1, "CHECK-SCFG-300");
require(resourceConfig.elasticityMultiplier == 1); require(resourceConfig.elasticityMultiplier == 1, "CHECK-SCFG-310");
require(resourceConfig.baseFeeMaxChangeDenominator == 2); require(resourceConfig.baseFeeMaxChangeDenominator == 2, "CHECK-SCFG-320");
require(resourceConfig.systemTxMaxGas == 0); require(resourceConfig.systemTxMaxGas == 0, "CHECK-SCFG-330");
require(resourceConfig.minimumBaseFee == 0); require(resourceConfig.minimumBaseFee == 0, "CHECK-SCFG-340");
require(resourceConfig.maximumBaseFee == 0); require(resourceConfig.maximumBaseFee == 0, "CHECK-SCFG-350");
// Check _addresses // Check _addresses
require(config.startBlock() == type(uint256).max); require(config.startBlock() == type(uint256).max, "CHECK-SCFG-360");
require(config.batchInbox() == address(0)); require(config.batchInbox() == address(0), "CHECK-SCFG-370");
require(config.l1CrossDomainMessenger() == address(0)); require(config.l1CrossDomainMessenger() == address(0), "CHECK-SCFG-380");
require(config.l1ERC721Bridge() == address(0)); require(config.l1ERC721Bridge() == address(0), "CHECK-SCFG-390");
require(config.l1StandardBridge() == address(0)); require(config.l1StandardBridge() == address(0), "CHECK-SCFG-400");
require(config.disputeGameFactory() == address(0)); require(config.disputeGameFactory() == address(0), "CHECK-SCFG-410");
require(config.optimismPortal() == address(0)); require(config.optimismPortal() == address(0), "CHECK-SCFG-420");
require(config.optimismMintableERC20Factory() == address(0)); require(config.optimismMintableERC20Factory() == address(0), "CHECK-SCFG-430");
} }
} }
/// @notice Asserts that the L1CrossDomainMessenger is setup correctly /// @notice Asserts that the L1CrossDomainMessenger is setup correctly
function checkL1CrossDomainMessenger(Types.ContractSet memory _contracts, Vm _vm, bool _isProxy) internal view { function checkL1CrossDomainMessenger(Types.ContractSet memory _contracts, Vm _vm, bool _isProxy) internal view {
console.log("Running chain assertions on the L1CrossDomainMessenger");
IL1CrossDomainMessenger messenger = IL1CrossDomainMessenger(_contracts.L1CrossDomainMessenger); IL1CrossDomainMessenger messenger = IL1CrossDomainMessenger(_contracts.L1CrossDomainMessenger);
console.log(
"Running chain assertions on the L1CrossDomainMessenger %s at %s",
_isProxy ? "proxy" : "implementation",
address(messenger)
);
require(address(messenger) != address(0), "CHECK-L1XDM-10");
// Check that the contract is initialized // Check that the contract is initialized
assertSlotValueIsOne({ _contractAddress: address(messenger), _slot: 0, _offset: 20 }); assertSlotValueIsOne({ _contractAddress: address(messenger), _slot: 0, _offset: 20 });
require(address(messenger.OTHER_MESSENGER()) == Predeploys.L2_CROSS_DOMAIN_MESSENGER); require(address(messenger.OTHER_MESSENGER()) == Predeploys.L2_CROSS_DOMAIN_MESSENGER, "CHECK-L1XDM-20");
require(address(messenger.otherMessenger()) == Predeploys.L2_CROSS_DOMAIN_MESSENGER); require(address(messenger.otherMessenger()) == Predeploys.L2_CROSS_DOMAIN_MESSENGER, "CHECK-L1XDM-30");
if (_isProxy) { if (_isProxy) {
require(address(messenger.PORTAL()) == _contracts.OptimismPortal); require(address(messenger.PORTAL()) == _contracts.OptimismPortal, "CHECK-L1XDM-40");
require(address(messenger.portal()) == _contracts.OptimismPortal); require(address(messenger.portal()) == _contracts.OptimismPortal, "CHECK-L1XDM-50");
require(address(messenger.superchainConfig()) == _contracts.SuperchainConfig); require(address(messenger.superchainConfig()) == _contracts.SuperchainConfig, "CHECK-L1XDM-60");
bytes32 xdmSenderSlot = _vm.load(address(messenger), bytes32(uint256(204))); bytes32 xdmSenderSlot = _vm.load(address(messenger), bytes32(uint256(204)));
require(address(uint160(uint256(xdmSenderSlot))) == Constants.DEFAULT_L2_SENDER); require(address(uint160(uint256(xdmSenderSlot))) == Constants.DEFAULT_L2_SENDER, "CHECK-L1XDM-70");
} else { } else {
require(address(messenger.PORTAL()) == address(0)); require(address(messenger.PORTAL()) == address(0), "CHECK-L1XDM-80");
require(address(messenger.portal()) == address(0)); require(address(messenger.portal()) == address(0), "CHECK-L1XDM-90");
require(address(messenger.superchainConfig()) == address(0)); require(address(messenger.superchainConfig()) == address(0), "CHECK-L1XDM-100");
} }
} }
/// @notice Asserts that the L1StandardBridge is setup correctly /// @notice Asserts that the L1StandardBridge is setup correctly
function checkL1StandardBridge(Types.ContractSet memory _contracts, bool _isProxy) internal view { function checkL1StandardBridge(Types.ContractSet memory _contracts, bool _isProxy) internal view {
console.log("Running chain assertions on the L1StandardBridge");
IL1StandardBridge bridge = IL1StandardBridge(payable(_contracts.L1StandardBridge)); IL1StandardBridge bridge = IL1StandardBridge(payable(_contracts.L1StandardBridge));
console.log(
"Running chain assertions on the L1StandardBridge %s at %s",
_isProxy ? "proxy" : "implementation",
address(bridge)
);
require(address(bridge) != address(0), "CHECK-L1SB-10");
// Check that the contract is initialized // Check that the contract is initialized
assertSlotValueIsOne({ _contractAddress: address(bridge), _slot: 0, _offset: 0 }); assertSlotValueIsOne({ _contractAddress: address(bridge), _slot: 0, _offset: 0 });
if (_isProxy) { if (_isProxy) {
require(address(bridge.MESSENGER()) == _contracts.L1CrossDomainMessenger); require(address(bridge.MESSENGER()) == _contracts.L1CrossDomainMessenger, "CHECK-L1SB-20");
require(address(bridge.messenger()) == _contracts.L1CrossDomainMessenger); require(address(bridge.messenger()) == _contracts.L1CrossDomainMessenger, "CHECK-L1SB-30");
require(address(bridge.OTHER_BRIDGE()) == Predeploys.L2_STANDARD_BRIDGE); require(address(bridge.OTHER_BRIDGE()) == Predeploys.L2_STANDARD_BRIDGE, "CHECK-L1SB-40");
require(address(bridge.otherBridge()) == Predeploys.L2_STANDARD_BRIDGE); require(address(bridge.otherBridge()) == Predeploys.L2_STANDARD_BRIDGE, "CHECK-L1SB-50");
require(address(bridge.superchainConfig()) == _contracts.SuperchainConfig); require(address(bridge.superchainConfig()) == _contracts.SuperchainConfig, "CHECK-L1SB-60");
} else { } else {
require(address(bridge.MESSENGER()) == address(0)); require(address(bridge.MESSENGER()) == address(0), "CHECK-L1SB-70");
require(address(bridge.messenger()) == address(0)); require(address(bridge.messenger()) == address(0), "CHECK-L1SB-80");
require(address(bridge.OTHER_BRIDGE()) == Predeploys.L2_STANDARD_BRIDGE); require(address(bridge.OTHER_BRIDGE()) == Predeploys.L2_STANDARD_BRIDGE, "CHECK-L1SB-90");
require(address(bridge.otherBridge()) == Predeploys.L2_STANDARD_BRIDGE); require(address(bridge.otherBridge()) == Predeploys.L2_STANDARD_BRIDGE, "CHECK-L1SB-100");
require(address(bridge.superchainConfig()) == address(0)); require(address(bridge.superchainConfig()) == address(0), "CHECK-L1SB-110");
} }
} }
/// @notice Asserts that the DisputeGameFactory is setup correctly /// @notice Asserts that the DisputeGameFactory is setup correctly
function checkDisputeGameFactory(Types.ContractSet memory _contracts, address _expectedOwner) internal view { function checkDisputeGameFactory(
console.log("Running chain assertions on the DisputeGameFactory"); Types.ContractSet memory _contracts,
address _expectedOwner,
bool _isProxy
)
internal
view
{
IDisputeGameFactory factory = IDisputeGameFactory(_contracts.DisputeGameFactory); IDisputeGameFactory factory = IDisputeGameFactory(_contracts.DisputeGameFactory);
console.log(
"Running chain assertions on the DisputeGameFactory %s at %s",
_isProxy ? "proxy" : "implementation",
address(factory)
);
require(address(factory) != address(0), "CHECK-DG-10");
// Check that the contract is initialized // Check that the contract is initialized
assertSlotValueIsOne({ _contractAddress: address(factory), _slot: 0, _offset: 0 }); assertSlotValueIsOne({ _contractAddress: address(factory), _slot: 0, _offset: 0 });
require(factory.owner() == _expectedOwner); // The same check is made for both proxy and implementation
require(factory.owner() == _expectedOwner, "CHECK-DG-20");
} }
/// @notice Asserts that the DelayedWETH is setup correctly /// @notice Asserts that the DelayedWETH is setup correctly
...@@ -198,19 +225,22 @@ library ChainAssertions { ...@@ -198,19 +225,22 @@ library ChainAssertions {
internal internal
view view
{ {
console.log("Running chain assertions on the DelayedWETH");
IDelayedWETH weth = IDelayedWETH(payable(_contracts.DelayedWETH)); IDelayedWETH weth = IDelayedWETH(payable(_contracts.DelayedWETH));
console.log(
"Running chain assertions on the DelayedWETH %s at %s", _isProxy ? "proxy" : "implementation", address(weth)
);
require(address(weth) != address(0), "CHECK-DWETH-10");
// Check that the contract is initialized // Check that the contract is initialized
assertSlotValueIsOne({ _contractAddress: address(weth), _slot: 0, _offset: 0 }); assertSlotValueIsOne({ _contractAddress: address(weth), _slot: 0, _offset: 0 });
if (_isProxy) { if (_isProxy) {
require(weth.owner() == _expectedOwner); require(weth.owner() == _expectedOwner, "CHECK-DWETH-20");
require(weth.delay() == _cfg.faultGameWithdrawalDelay()); require(weth.delay() == _cfg.faultGameWithdrawalDelay(), "CHECK-DWETH-30");
require(weth.config() == ISuperchainConfig(_contracts.SuperchainConfig)); require(weth.config() == ISuperchainConfig(_contracts.SuperchainConfig), "CHECK-DWETH-40");
} else { } else {
require(weth.owner() == _expectedOwner); require(weth.owner() == _expectedOwner, "CHECK-DWETH-50");
require(weth.delay() == _cfg.faultGameWithdrawalDelay()); require(weth.delay() == _cfg.faultGameWithdrawalDelay(), "CHECK-DWETH-60");
} }
} }
...@@ -224,19 +254,24 @@ library ChainAssertions { ...@@ -224,19 +254,24 @@ library ChainAssertions {
internal internal
view view
{ {
console.log("Running chain assertions on the permissioned DelayedWETH");
IDelayedWETH weth = IDelayedWETH(payable(_contracts.PermissionedDelayedWETH)); IDelayedWETH weth = IDelayedWETH(payable(_contracts.PermissionedDelayedWETH));
console.log(
"Running chain assertions on the PermissionedDelayedWETH %s at %s",
_isProxy ? "proxy" : "implementation",
address(weth)
);
require(address(weth) != address(0), "CHECK-PDWETH-10");
// Check that the contract is initialized // Check that the contract is initialized
assertSlotValueIsOne({ _contractAddress: address(weth), _slot: 0, _offset: 0 }); assertSlotValueIsOne({ _contractAddress: address(weth), _slot: 0, _offset: 0 });
if (_isProxy) { if (_isProxy) {
require(weth.owner() == _expectedOwner); require(weth.owner() == _expectedOwner, "CHECK-PDWETH-20");
require(weth.delay() == _cfg.faultGameWithdrawalDelay()); require(weth.delay() == _cfg.faultGameWithdrawalDelay(), "CHECK-PDWETH-30");
require(weth.config() == ISuperchainConfig(_contracts.SuperchainConfig)); require(weth.config() == ISuperchainConfig(_contracts.SuperchainConfig), "CHECK-PDWETH-40");
} else { } else {
require(weth.owner() == _expectedOwner); require(weth.owner() == _expectedOwner, "CHECK-PDWETH-50");
require(weth.delay() == _cfg.faultGameWithdrawalDelay()); require(weth.delay() == _cfg.faultGameWithdrawalDelay(), "CHECK-PDWETH-60");
} }
} }
...@@ -250,55 +285,65 @@ library ChainAssertions { ...@@ -250,55 +285,65 @@ library ChainAssertions {
internal internal
view view
{ {
console.log("Running chain assertions on the L2OutputOracle");
IL2OutputOracle oracle = IL2OutputOracle(_contracts.L2OutputOracle); IL2OutputOracle oracle = IL2OutputOracle(_contracts.L2OutputOracle);
console.log(
"Running chain assertions on the L2OutputOracle %s at %s",
_isProxy ? "proxy" : "implementation",
address(oracle)
);
require(address(oracle) != address(0), "CHECK-L2OO-10");
// Check that the contract is initialized // Check that the contract is initialized
assertSlotValueIsOne({ _contractAddress: address(oracle), _slot: 0, _offset: 0 }); assertSlotValueIsOne({ _contractAddress: address(oracle), _slot: 0, _offset: 0 });
if (_isProxy) { if (_isProxy) {
require(oracle.SUBMISSION_INTERVAL() == _cfg.l2OutputOracleSubmissionInterval()); require(oracle.SUBMISSION_INTERVAL() == _cfg.l2OutputOracleSubmissionInterval(), "CHECK-L2OO-20");
require(oracle.submissionInterval() == _cfg.l2OutputOracleSubmissionInterval()); require(oracle.submissionInterval() == _cfg.l2OutputOracleSubmissionInterval(), "CHECK-L2OO-30");
require(oracle.L2_BLOCK_TIME() == _cfg.l2BlockTime()); require(oracle.L2_BLOCK_TIME() == _cfg.l2BlockTime(), "CHECK-L2OO-40");
require(oracle.l2BlockTime() == _cfg.l2BlockTime()); require(oracle.l2BlockTime() == _cfg.l2BlockTime(), "CHECK-L2OO-50");
require(oracle.PROPOSER() == _cfg.l2OutputOracleProposer()); require(oracle.PROPOSER() == _cfg.l2OutputOracleProposer(), "CHECK-L2OO-60");
require(oracle.proposer() == _cfg.l2OutputOracleProposer()); require(oracle.proposer() == _cfg.l2OutputOracleProposer(), "CHECK-L2OO-70");
require(oracle.CHALLENGER() == _cfg.l2OutputOracleChallenger()); require(oracle.CHALLENGER() == _cfg.l2OutputOracleChallenger(), "CHECK-L2OO-80");
require(oracle.challenger() == _cfg.l2OutputOracleChallenger()); require(oracle.challenger() == _cfg.l2OutputOracleChallenger(), "CHECK-L2OO-90");
require(oracle.FINALIZATION_PERIOD_SECONDS() == _cfg.finalizationPeriodSeconds()); require(oracle.FINALIZATION_PERIOD_SECONDS() == _cfg.finalizationPeriodSeconds(), "CHECK-L2OO-100");
require(oracle.finalizationPeriodSeconds() == _cfg.finalizationPeriodSeconds()); require(oracle.finalizationPeriodSeconds() == _cfg.finalizationPeriodSeconds(), "CHECK-L2OO-110");
require(oracle.startingBlockNumber() == _cfg.l2OutputOracleStartingBlockNumber()); require(oracle.startingBlockNumber() == _cfg.l2OutputOracleStartingBlockNumber(), "CHECK-L2OO-120");
require(oracle.startingTimestamp() == _l2OutputOracleStartingTimestamp); require(oracle.startingTimestamp() == _l2OutputOracleStartingTimestamp, "CHECK-L2OO-130");
} else { } else {
require(oracle.SUBMISSION_INTERVAL() == 1); require(oracle.SUBMISSION_INTERVAL() == 1, "CHECK-L2OO-140");
require(oracle.submissionInterval() == 1); require(oracle.submissionInterval() == 1, "CHECK-L2OO-150");
require(oracle.L2_BLOCK_TIME() == 1); require(oracle.L2_BLOCK_TIME() == 1, "CHECK-L2OO-160");
require(oracle.l2BlockTime() == 1); require(oracle.l2BlockTime() == 1, "CHECK-L2OO-170");
require(oracle.PROPOSER() == address(0)); require(oracle.PROPOSER() == address(0), "CHECK-L2OO-180");
require(oracle.proposer() == address(0)); require(oracle.proposer() == address(0), "CHECK-L2OO-190");
require(oracle.CHALLENGER() == address(0)); require(oracle.CHALLENGER() == address(0), "CHECK-L2OO-200");
require(oracle.challenger() == address(0)); require(oracle.challenger() == address(0), "CHECK-L2OO-210");
require(oracle.FINALIZATION_PERIOD_SECONDS() == 0); require(oracle.FINALIZATION_PERIOD_SECONDS() == 0, "CHECK-L2OO-220");
require(oracle.finalizationPeriodSeconds() == 0); require(oracle.finalizationPeriodSeconds() == 0, "CHECK-L2OO-230");
require(oracle.startingBlockNumber() == 0); require(oracle.startingBlockNumber() == 0, "CHECK-L2OO-240");
require(oracle.startingTimestamp() == 0); require(oracle.startingTimestamp() == 0, "CHECK-L2OO-250");
} }
} }
/// @notice Asserts that the OptimismMintableERC20Factory is setup correctly /// @notice Asserts that the OptimismMintableERC20Factory is setup correctly
function checkOptimismMintableERC20Factory(Types.ContractSet memory _contracts, bool _isProxy) internal view { function checkOptimismMintableERC20Factory(Types.ContractSet memory _contracts, bool _isProxy) internal view {
console.log("Running chain assertions on the OptimismMintableERC20Factory");
IOptimismMintableERC20Factory factory = IOptimismMintableERC20Factory(_contracts.OptimismMintableERC20Factory); IOptimismMintableERC20Factory factory = IOptimismMintableERC20Factory(_contracts.OptimismMintableERC20Factory);
console.log(
"Running chain assertions on the OptimismMintableERC20Factory %s at %s",
_isProxy ? "proxy" : "implementation",
address(factory)
);
require(address(factory) != address(0), "CHECK-MERC20F-10");
// Check that the contract is initialized // Check that the contract is initialized
assertSlotValueIsOne({ _contractAddress: address(factory), _slot: 0, _offset: 0 }); assertSlotValueIsOne({ _contractAddress: address(factory), _slot: 0, _offset: 0 });
if (_isProxy) { if (_isProxy) {
require(factory.BRIDGE() == _contracts.L1StandardBridge); require(factory.BRIDGE() == _contracts.L1StandardBridge, "CHECK-MERC20F-10");
require(factory.bridge() == _contracts.L1StandardBridge); require(factory.bridge() == _contracts.L1StandardBridge, "CHECK-MERC20F-20");
} else { } else {
require(factory.BRIDGE() == address(0)); require(factory.BRIDGE() == address(0), "CHECK-MERC20F-30");
require(factory.bridge() == address(0)); require(factory.bridge() == address(0), "CHECK-MERC20F-40");
} }
} }
...@@ -306,29 +351,39 @@ library ChainAssertions { ...@@ -306,29 +351,39 @@ library ChainAssertions {
function checkL1ERC721Bridge(Types.ContractSet memory _contracts, bool _isProxy) internal view { function checkL1ERC721Bridge(Types.ContractSet memory _contracts, bool _isProxy) internal view {
console.log("Running chain assertions on the L1ERC721Bridge"); console.log("Running chain assertions on the L1ERC721Bridge");
IL1ERC721Bridge bridge = IL1ERC721Bridge(_contracts.L1ERC721Bridge); IL1ERC721Bridge bridge = IL1ERC721Bridge(_contracts.L1ERC721Bridge);
console.log(
"Running chain assertions on the L1ERC721Bridge %s at %s",
_isProxy ? "proxy" : "implementation",
address(bridge)
);
require(address(bridge) != address(0), "CHECK-L1ERC721B-10");
// Check that the contract is initialized // Check that the contract is initialized
assertSlotValueIsOne({ _contractAddress: address(bridge), _slot: 0, _offset: 0 }); assertSlotValueIsOne({ _contractAddress: address(bridge), _slot: 0, _offset: 0 });
require(address(bridge.OTHER_BRIDGE()) == Predeploys.L2_ERC721_BRIDGE); require(address(bridge.OTHER_BRIDGE()) == Predeploys.L2_ERC721_BRIDGE, "CHECK-L1ERC721B-10");
require(address(bridge.otherBridge()) == Predeploys.L2_ERC721_BRIDGE); require(address(bridge.otherBridge()) == Predeploys.L2_ERC721_BRIDGE, "CHECK-L1ERC721B-20");
if (_isProxy) { if (_isProxy) {
require(address(bridge.MESSENGER()) == _contracts.L1CrossDomainMessenger); require(address(bridge.MESSENGER()) == _contracts.L1CrossDomainMessenger, "CHECK-L1ERC721B-30");
require(address(bridge.messenger()) == _contracts.L1CrossDomainMessenger); require(address(bridge.messenger()) == _contracts.L1CrossDomainMessenger, "CHECK-L1ERC721B-40");
require(address(bridge.superchainConfig()) == _contracts.SuperchainConfig); require(address(bridge.superchainConfig()) == _contracts.SuperchainConfig, "CHECK-L1ERC721B-50");
} else { } else {
require(address(bridge.MESSENGER()) == address(0)); require(address(bridge.MESSENGER()) == address(0), "CHECK-L1ERC721B-60");
require(address(bridge.messenger()) == address(0)); require(address(bridge.messenger()) == address(0), "CHECK-L1ERC721B-70");
require(address(bridge.superchainConfig()) == address(0)); require(address(bridge.superchainConfig()) == address(0), "CHECK-L1ERC721B-80");
} }
} }
/// @notice Asserts the OptimismPortal is setup correctly /// @notice Asserts the OptimismPortal is setup correctly
function checkOptimismPortal(Types.ContractSet memory _contracts, DeployConfig _cfg, bool _isProxy) internal view { function checkOptimismPortal(Types.ContractSet memory _contracts, DeployConfig _cfg, bool _isProxy) internal view {
console.log("Running chain assertions on the OptimismPortal");
IOptimismPortal portal = IOptimismPortal(payable(_contracts.OptimismPortal)); IOptimismPortal portal = IOptimismPortal(payable(_contracts.OptimismPortal));
console.log(
"Running chain assertions on the OptimismPortal %s at %s",
_isProxy ? "proxy" : "implementation",
address(portal)
);
require(address(portal) != address(0), "CHECK-OP-10");
// Check that the contract is initialized // Check that the contract is initialized
assertSlotValueIsOne({ _contractAddress: address(portal), _slot: 0, _offset: 0 }); assertSlotValueIsOne({ _contractAddress: address(portal), _slot: 0, _offset: 0 });
...@@ -339,17 +394,17 @@ library ChainAssertions { ...@@ -339,17 +394,17 @@ library ChainAssertions {
} }
if (_isProxy) { if (_isProxy) {
require(address(portal.l2Oracle()) == _contracts.L2OutputOracle); require(address(portal.l2Oracle()) == _contracts.L2OutputOracle, "CHECK-OP-20");
require(address(portal.systemConfig()) == _contracts.SystemConfig); require(address(portal.systemConfig()) == _contracts.SystemConfig, "CHECK-OP-30");
require(portal.guardian() == guardian); require(portal.guardian() == guardian, "CHECK-OP-40");
require(address(portal.superchainConfig()) == address(_contracts.SuperchainConfig)); require(address(portal.superchainConfig()) == address(_contracts.SuperchainConfig), "CHECK-OP-50");
require(portal.paused() == ISuperchainConfig(_contracts.SuperchainConfig).paused()); require(portal.paused() == ISuperchainConfig(_contracts.SuperchainConfig).paused(), "CHECK-OP-60");
require(portal.l2Sender() == Constants.DEFAULT_L2_SENDER); require(portal.l2Sender() == Constants.DEFAULT_L2_SENDER, "CHECK-OP-70");
} else { } else {
require(address(portal.l2Oracle()) == address(0)); require(address(portal.l2Oracle()) == address(0), "CHECK-OP-80");
require(address(portal.systemConfig()) == address(0)); require(address(portal.systemConfig()) == address(0), "CHECK-OP-90");
require(address(portal.superchainConfig()) == address(0)); require(address(portal.superchainConfig()) == address(0), "CHECK-OP-100");
require(portal.l2Sender() == Constants.DEFAULT_L2_SENDER); require(portal.l2Sender() == Constants.DEFAULT_L2_SENDER, "CHECK-OP-110");
} }
} }
...@@ -362,9 +417,13 @@ library ChainAssertions { ...@@ -362,9 +417,13 @@ library ChainAssertions {
internal internal
view view
{ {
console.log("Running chain assertions on the OptimismPortal2");
IOptimismPortal2 portal = IOptimismPortal2(payable(_contracts.OptimismPortal2)); IOptimismPortal2 portal = IOptimismPortal2(payable(_contracts.OptimismPortal2));
console.log(
"Running chain assertions on the OptimismPortal2 %s at %s",
_isProxy ? "proxy" : "implementation",
address(portal)
);
require(address(portal) != address(0), "CHECK-OP2-10");
// Check that the contract is initialized // Check that the contract is initialized
assertSlotValueIsOne({ _contractAddress: address(portal), _slot: 0, _offset: 0 }); assertSlotValueIsOne({ _contractAddress: address(portal), _slot: 0, _offset: 0 });
...@@ -375,21 +434,21 @@ library ChainAssertions { ...@@ -375,21 +434,21 @@ library ChainAssertions {
} }
if (_isProxy) { if (_isProxy) {
require(address(portal.disputeGameFactory()) == _contracts.DisputeGameFactory); require(address(portal.disputeGameFactory()) == _contracts.DisputeGameFactory, "CHECK-OP2-20");
require(address(portal.systemConfig()) == _contracts.SystemConfig); require(address(portal.systemConfig()) == _contracts.SystemConfig, "CHECK-OP2-30");
require(portal.guardian() == guardian); require(portal.guardian() == guardian, "CHECK-OP2-40");
require(address(portal.superchainConfig()) == address(_contracts.SuperchainConfig)); require(address(portal.superchainConfig()) == address(_contracts.SuperchainConfig), "CHECK-OP2-50");
require(portal.paused() == ISuperchainConfig(_contracts.SuperchainConfig).paused()); require(portal.paused() == ISuperchainConfig(_contracts.SuperchainConfig).paused(), "CHECK-OP2-60");
require(portal.l2Sender() == Constants.DEFAULT_L2_SENDER); require(portal.l2Sender() == Constants.DEFAULT_L2_SENDER, "CHECK-OP2-70");
} else { } else {
require(address(portal.disputeGameFactory()) == address(0)); require(address(portal.disputeGameFactory()) == address(0), "CHECK-OP2-80");
require(address(portal.systemConfig()) == address(0)); require(address(portal.systemConfig()) == address(0), "CHECK-OP2-90");
require(address(portal.superchainConfig()) == address(0)); require(address(portal.superchainConfig()) == address(0), "CHECK-OP2-100");
require(portal.l2Sender() == Constants.DEFAULT_L2_SENDER); require(portal.l2Sender() == Constants.DEFAULT_L2_SENDER, "CHECK-OP2-110");
} }
// This slot is the custom gas token _balance and this check ensures // This slot is the custom gas token _balance and this check ensures
// that it stays unset for forwards compatibility with custom gas token. // that it stays unset for forwards compatibility with custom gas token.
require(vm.load(address(portal), bytes32(uint256(61))) == bytes32(0)); require(vm.load(address(portal), bytes32(uint256(61))) == bytes32(0), "CHECK-OP2-120");
} }
/// @notice Asserts that the ProtocolVersions is setup correctly /// @notice Asserts that the ProtocolVersions is setup correctly
...@@ -401,20 +460,25 @@ library ChainAssertions { ...@@ -401,20 +460,25 @@ library ChainAssertions {
internal internal
view view
{ {
console.log("Running chain assertions on the ProtocolVersions");
IProtocolVersions versions = IProtocolVersions(_contracts.ProtocolVersions); IProtocolVersions versions = IProtocolVersions(_contracts.ProtocolVersions);
console.log(
"Running chain assertions on the ProtocolVersions %s at %s",
_isProxy ? "proxy" : "implementation",
address(versions)
);
require(address(versions) != address(0), "CHECK-PV-10");
// Check that the contract is initialized // Check that the contract is initialized
assertSlotValueIsOne({ _contractAddress: address(versions), _slot: 0, _offset: 0 }); assertSlotValueIsOne({ _contractAddress: address(versions), _slot: 0, _offset: 0 });
if (_isProxy) { if (_isProxy) {
require(versions.owner() == _cfg.finalSystemOwner()); require(versions.owner() == _cfg.finalSystemOwner(), "CHECK-PV-20");
require(ProtocolVersion.unwrap(versions.required()) == _cfg.requiredProtocolVersion()); require(ProtocolVersion.unwrap(versions.required()) == _cfg.requiredProtocolVersion(), "CHECK-PV-30");
require(ProtocolVersion.unwrap(versions.recommended()) == _cfg.recommendedProtocolVersion()); require(ProtocolVersion.unwrap(versions.recommended()) == _cfg.recommendedProtocolVersion(), "CHECK-PV-40");
} else { } else {
require(versions.owner() == address(0xdead)); require(versions.owner() == address(0xdead), "CHECK-PV-50");
require(ProtocolVersion.unwrap(versions.required()) == 0); require(ProtocolVersion.unwrap(versions.required()) == 0, "CHECK-PV-60");
require(ProtocolVersion.unwrap(versions.recommended()) == 0); require(ProtocolVersion.unwrap(versions.recommended()) == 0, "CHECK-PV-70");
} }
} }
...@@ -428,18 +492,23 @@ library ChainAssertions { ...@@ -428,18 +492,23 @@ library ChainAssertions {
internal internal
view view
{ {
console.log("Running chain assertions on the SuperchainConfig");
ISuperchainConfig superchainConfig = ISuperchainConfig(_contracts.SuperchainConfig); ISuperchainConfig superchainConfig = ISuperchainConfig(_contracts.SuperchainConfig);
console.log(
"Running chain assertions on the SuperchainConfig %s at %s",
_isProxy ? "proxy" : "implementation",
address(superchainConfig)
);
require(address(superchainConfig) != address(0), "CHECK-SC-10");
// Check that the contract is initialized // Check that the contract is initialized
assertSlotValueIsOne({ _contractAddress: address(superchainConfig), _slot: 0, _offset: 0 }); assertSlotValueIsOne({ _contractAddress: address(superchainConfig), _slot: 0, _offset: 0 });
if (_isProxy) { if (_isProxy) {
require(superchainConfig.guardian() == _cfg.superchainConfigGuardian()); require(superchainConfig.guardian() == _cfg.superchainConfigGuardian(), "CHECK-SC-20");
require(superchainConfig.paused() == _isPaused); require(superchainConfig.paused() == _isPaused, "CHECK-SC-30");
} else { } else {
require(superchainConfig.guardian() == address(0)); require(superchainConfig.guardian() == address(0), "CHECK-SC-40");
require(superchainConfig.paused() == false); require(superchainConfig.paused() == false, "CHECK-SC-50");
} }
} }
......
...@@ -757,7 +757,7 @@ contract Deploy is Deployer { ...@@ -757,7 +757,7 @@ contract Deploy is Deployer {
// `DisputeGameFactory` implementation alongside dependent contracts, which are always proxies. // `DisputeGameFactory` implementation alongside dependent contracts, which are always proxies.
Types.ContractSet memory contracts = _proxiesUnstrict(); Types.ContractSet memory contracts = _proxiesUnstrict();
contracts.DisputeGameFactory = address(factory); contracts.DisputeGameFactory = address(factory);
ChainAssertions.checkDisputeGameFactory({ _contracts: contracts, _expectedOwner: address(0) }); ChainAssertions.checkDisputeGameFactory({ _contracts: contracts, _expectedOwner: address(0), _isProxy: true });
addr_ = address(factory); addr_ = address(factory);
} }
...@@ -957,7 +957,11 @@ contract Deploy is Deployer { ...@@ -957,7 +957,11 @@ contract Deploy is Deployer {
string memory version = IDisputeGameFactory(disputeGameFactoryProxy).version(); string memory version = IDisputeGameFactory(disputeGameFactoryProxy).version();
console.log("DisputeGameFactory version: %s", version); console.log("DisputeGameFactory version: %s", version);
ChainAssertions.checkDisputeGameFactory({ _contracts: _proxiesUnstrict(), _expectedOwner: msg.sender }); ChainAssertions.checkDisputeGameFactory({
_contracts: _proxiesUnstrict(),
_expectedOwner: msg.sender,
_isProxy: true
});
} }
function initializeDelayedWETH() public broadcast { function initializeDelayedWETH() public broadcast {
...@@ -1345,7 +1349,11 @@ contract Deploy is Deployer { ...@@ -1345,7 +1349,11 @@ contract Deploy is Deployer {
disputeGameFactory.transferOwnership(finalSystemOwner); disputeGameFactory.transferOwnership(finalSystemOwner);
console.log("DisputeGameFactory ownership transferred to final system owner at: %s", finalSystemOwner); console.log("DisputeGameFactory ownership transferred to final system owner at: %s", finalSystemOwner);
} }
ChainAssertions.checkDisputeGameFactory({ _contracts: _proxiesUnstrict(), _expectedOwner: finalSystemOwner }); ChainAssertions.checkDisputeGameFactory({
_contracts: _proxiesUnstrict(),
_expectedOwner: finalSystemOwner,
_isProxy: true
});
} }
/// @notice Transfer ownership of the DelayedWETH contract to the final system owner /// @notice Transfer ownership of the DelayedWETH contract to the final system owner
......
...@@ -172,7 +172,7 @@ contract FPACOPS is Deploy, StdAssertions { ...@@ -172,7 +172,7 @@ contract FPACOPS is Deploy, StdAssertions {
address dgfProxyAddr = mustGetAddress("DisputeGameFactoryProxy"); address dgfProxyAddr = mustGetAddress("DisputeGameFactoryProxy");
IDisputeGameFactory dgfProxy = IDisputeGameFactory(dgfProxyAddr); IDisputeGameFactory dgfProxy = IDisputeGameFactory(dgfProxyAddr);
assertEq(address(uint160(uint256(vm.load(dgfProxyAddr, Constants.PROXY_OWNER_ADDRESS)))), _proxyAdmin); assertEq(address(uint160(uint256(vm.load(dgfProxyAddr, Constants.PROXY_OWNER_ADDRESS)))), _proxyAdmin);
ChainAssertions.checkDisputeGameFactory(contracts, _finalSystemOwner); ChainAssertions.checkDisputeGameFactory(contracts, _finalSystemOwner, true);
address wethProxyAddr = mustGetAddress("DelayedWETHProxy"); address wethProxyAddr = mustGetAddress("DelayedWETHProxy");
assertEq(address(uint160(uint256(vm.load(wethProxyAddr, Constants.PROXY_OWNER_ADDRESS)))), _proxyAdmin); assertEq(address(uint160(uint256(vm.load(wethProxyAddr, Constants.PROXY_OWNER_ADDRESS)))), _proxyAdmin);
ChainAssertions.checkDelayedWETH(contracts, cfg, true, _finalSystemOwner); ChainAssertions.checkDelayedWETH(contracts, cfg, true, _finalSystemOwner);
......
...@@ -224,7 +224,7 @@ contract FPACOPS2 is Deploy, StdAssertions { ...@@ -224,7 +224,7 @@ contract FPACOPS2 is Deploy, StdAssertions {
assertEq(address(uint160(uint256(vm.load(soyWethProxyAddr, Constants.PROXY_OWNER_ADDRESS)))), _proxyAdmin); assertEq(address(uint160(uint256(vm.load(soyWethProxyAddr, Constants.PROXY_OWNER_ADDRESS)))), _proxyAdmin);
// Run standard assertions for DGF and DelayedWETH. // Run standard assertions for DGF and DelayedWETH.
ChainAssertions.checkDisputeGameFactory(contracts, _finalSystemOwner); ChainAssertions.checkDisputeGameFactory(contracts, _finalSystemOwner, true);
ChainAssertions.checkDelayedWETH(contracts, cfg, true, _finalSystemOwner); ChainAssertions.checkDelayedWETH(contracts, cfg, true, _finalSystemOwner);
ChainAssertions.checkPermissionedDelayedWETH(contracts, cfg, true, _finalSystemOwner); ChainAssertions.checkPermissionedDelayedWETH(contracts, cfg, true, _finalSystemOwner);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment