Sitelet https://github.com/ethereum-optimism/optimism/commit/cba37e86e44a6bc4fb414da62f2bb1d5b906502a
Skip to content

Commit cba37e8

Browse files
authored
contracts-bedrock: Bind the SystemConfig chain ID in the standard validator (#22366)
1 parent 6456cd0 commit cba37e8

3 files changed

Lines changed: 18 additions & 8 deletions

File tree

‎packages/contracts-bedrock/snapshots/semver-lock.json‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
"sourceCodeHash": "0x0ef8461e8bc55314e61e60924465574db17bdf30bbbfe9739b52cac623bba2db"
2121
},
2222
"src/L1/OPContractsManagerStandardValidator.sol:OPContractsManagerStandardValidator": {
23-
"initCodeHash": "0x111eb6926457a4721d2d43920043370322963e590f3df56b57084073809e8dba",
24-
"sourceCodeHash": "0x37f01de7f914c716e6752024f704ee2bf82aa8515ac8fa0aaca8f35bd40dfdd8"
23+
"initCodeHash": "0xec4baf21016f8ac2723dc8b4731a7673f843c9e80a7b6d02ac87a306974132d9",
24+
"sourceCodeHash": "0x659df71f1e1e054d149b3f3a7f757ab5a4bf6bb59b6626f81749091008c5a47b"
2525
},
2626
"src/L1/OptimismPortal2.sol:OptimismPortal2": {
2727
"initCodeHash": "0x67bbf6c9b344870cdbd7b041ddad6fb69057a4b48ec6dd96876af55d14fc1943",

‎packages/contracts-bedrock/src/L1/OPContractsManagerStandardValidator.sol‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ import { IBigStepper } from "interfaces/dispute/IBigStepper.sol";
4646
/// before and after an upgrade.
4747
contract OPContractsManagerStandardValidator is ISemver {
4848
/// @notice The semantic version of the OPContractsManagerStandardValidator contract.
49-
/// @custom:semver 3.0.0
50-
string public constant version = "3.0.0";
49+
/// @custom:semver 3.1.0
50+
string public constant version = "3.1.0";
5151

5252
/// @notice The SuperchainConfig contract.
5353
ISuperchainConfig public superchainConfig;
@@ -280,7 +280,8 @@ contract OPContractsManagerStandardValidator is ISemver {
280280
function assertValidSystemConfig(
281281
string memory _errors,
282282
ISystemConfig _sysCfg,
283-
IProxyAdmin _admin
283+
IProxyAdmin _admin,
284+
uint256 _l2ChainID
284285
)
285286
internal
286287
view
@@ -305,6 +306,7 @@ contract OPContractsManagerStandardValidator is ISemver {
305306
_errors = internalRequire(_sysCfg.operatorFeeScalar() == 0, "SYSCON-110", _errors);
306307
_errors = internalRequire(_sysCfg.operatorFeeConstant() == 0, "SYSCON-120", _errors);
307308
_errors = internalRequire(_sysCfg.superchainConfig() == superchainConfig, "SYSCON-130", _errors);
309+
_errors = internalRequire(_sysCfg.l2ChainId() == _l2ChainID, "SYSCON-140", _errors);
308310
return _errors;
309311
}
310312

@@ -896,7 +898,7 @@ contract OPContractsManagerStandardValidator is ISemver {
896898

897899
_errors = assertValidSuperchainConfig(_errors);
898900
_errors = assertValidProxyAdmin(_errors, _proxyAdmin, _overrides);
899-
_errors = assertValidSystemConfig(_errors, _input.sysCfg, _proxyAdmin);
901+
_errors = assertValidSystemConfig(_errors, _input.sysCfg, _proxyAdmin, _input.l2ChainID);
900902
_errors = assertValidL1CrossDomainMessenger(_errors, _input.sysCfg, _proxyAdmin);
901903
_errors = assertValidL1StandardBridge(_errors, _input.sysCfg, _proxyAdmin);
902904
_errors = assertValidOptimismMintableERC20Factory(_errors, _input.sysCfg, _proxyAdmin);

‎packages/contracts-bedrock/test/L1/OPContractsManagerStandardValidator.t.sol‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1719,11 +1719,12 @@ abstract contract OPContractsManagerStandardValidator_SuperMode_TestInit is Supe
17191719
dgf = IDisputeGameFactory(artifacts.mustGetAddress("DisputeGameFactoryProxy"));
17201720
standardValidator = opcmV2.opcmStandardValidator();
17211721

1722-
l2ChainId = deploy.cfg().l2ChainID();
17231722
cannonPrestate = Claim.wrap(bytes32(deploy.cfg().faultGameAbsolutePrestate()));
17241723
if (isL1ForkTest()) {
1724+
l2ChainId = uint256(uint160(address(artifacts.mustGetAddress("L2ChainId"))));
17251725
proposer = DisputeGames.permissionedGameProposer(dgf);
17261726
} else {
1727+
l2ChainId = deploy.cfg().l2ChainID();
17271728
proposer = deploy.cfg().l2OutputOracleProposer();
17281729
}
17291730

@@ -1841,6 +1842,13 @@ contract OPContractsManagerStandardValidator_SuperModeCoreValidation_Test is
18411842
string memory errors = _validate(false);
18421843
assertEq(errors, "");
18431844
}
1845+
1846+
/// @notice Tests that the validate function returns SYSCON-140 when the SystemConfig l2ChainId
1847+
/// does not match the expected chain ID.
1848+
function test_validate_systemConfigInvalidL2ChainId_succeeds() public {
1849+
vm.mockCall(address(systemConfig), abi.encodeCall(ISystemConfig.l2ChainId, ()), abi.encode(l2ChainId + 1));
1850+
assertEq("SYSCON-140", _validate(true));
1851+
}
18441852
}
18451853

18461854
/// @title OPContractsManagerStandardValidator_SuperRootDisputeGames_Test
@@ -2115,7 +2123,7 @@ abstract contract OPContractsManagerStandardValidator_ZKMode_TestInit is CommonT
21152123
LibGameArgs.decode(dgf.gameArgs(permissionlessGameType));
21162124
cannonKonaPrestate = Claim.wrap(permissionlessGameArgs.absolutePrestate);
21172125
cannonPrestate = cannonKonaPrestate;
2118-
l2ChainId = permissionlessGameArgs.l2ChainId;
2126+
l2ChainId = uint256(uint160(address(artifacts.mustGetAddress("L2ChainId"))));
21192127
proposer = DisputeGames.permissionedGameProposer(dgf);
21202128

21212129
// ZK game is not deployed on mainnet. Mock it using the same ASR and WETH as the active

0 commit comments

Comments
 (0)