Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix contract tests #235

Merged
merged 5 commits into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions packages/contracts-bedrock/scripts/L2Genesis.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ contract L2Genesis is Deployer {
// 01: legacy, not used in OP-Stack
setDeployerWhitelist(); // 2
// 3,4,5: legacy, not used in OP-Stack.
setWETH(); // 6: WETH (not behind a proxy)
setLegacyERC20ETH(); // 6 (not behind a proxy)
setL2CrossDomainMessenger(_l1Dependencies.l1CrossDomainMessengerProxy); // 7
// 8,9,A,B,C,D,E: legacy, not used in OP-Stack.
setGasPriceOracle(); // f
Expand All @@ -259,7 +259,8 @@ contract L2Genesis is Deployer {
setSuperchainWETH(); // 24
setETHLiquidity(); // 25
}
setBOBA(_l1Dependencies.l1BobaToken); // 23
setBOBA(_l1Dependencies.l1BobaToken);
setWETH();
}

function setProxyAdmin() public {
Expand Down Expand Up @@ -375,6 +376,11 @@ contract L2Genesis is Deployer {
_setImplementationCode(Predeploys.DEPLOYER_WHITELIST);
}

function setLegacyERC20ETH() public {
console.log("Setting %s implementation at: %s", "LegacyERC20ETH", Predeploys.LEGACY_ERC20_ETH);
vm.etch(Predeploys.LEGACY_ERC20_ETH, vm.getDeployedCode("LegacyERC20ETH.sol:LegacyERC20ETH"));
}

/// @notice This predeploy is following the safety invariant #1.
/// This contract is NOT proxied and the state that is set
/// in the constructor is set manually.
Expand Down
8 changes: 4 additions & 4 deletions packages/contracts-bedrock/semver-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
"sourceCodeHash": "0xfb26fc80fbc7febdc91ac73ea91ceb479b238e0e81804a0a21192d78c261a755"
},
"src/L2/ETHLiquidity.sol": {
"initCodeHash": "0xb03b6936362a93a65de17876ed9bbb3b5cb17f5243d71578e9d264e1eb5b8ee5",
"initCodeHash": "0x98177562fca0de0dfea5313c9acefe2fdbd73dee5ce6c1232055601f208f0177",
"sourceCodeHash": "0x6dc23ceeed5a63fdc98ba8e5099df1822f3eeaa8c82afb1fa3235ff68a37b274"
},
"src/L2/GasPriceOracle.sol": {
Expand Down Expand Up @@ -108,19 +108,19 @@
"sourceCodeHash": "0x8388b9b8075f31d580fed815b66b45394e40fb1a63cd8cda2272d2c390fc908c"
},
"src/L2/L2ToL2CrossDomainMessenger.sol": {
"initCodeHash": "0xbe260ece49df99d85a4451efc472cbd7e651c7ad34d5bea8f2030bb4972fb119",
"initCodeHash": "0xe390be1390edc38fd879d7620538560076d7fcf3ef9debce327a1877d96d3ff0",
"sourceCodeHash": "0x20f77dc5a02869c6885b73347fa9e7d2bbc4eaf8a2313f7e7435e456001f7a75"
},
"src/L2/OptimismSuperchainERC20.sol": {
"initCodeHash": "0xd1e88c4e91c8bce58e874a30aaf0574f7ad442b27029b4fa4d3ba5502f451d49",
"initCodeHash": "0xd49214518ea1a30a43fac09f28b2cee9be570894a500cef342762c9820a070b0",
"sourceCodeHash": "0x6943d40010dcbd1d51dc3668d0a154fbb1568ea49ebcf3aa039d65ef6eab321b"
},
"src/L2/SequencerFeeVault.sol": {
"initCodeHash": "0xb94145f571e92ee615c6fe903b6568e8aac5fe760b6b65148ffc45d2fb0f5433",
"sourceCodeHash": "0x8f2a54104e5e7105ba03ba37e3ef9b6684a447245f0e0b787ba4cca12957b97c"
},
"src/L2/SuperchainWETH.sol": {
"initCodeHash": "0x319843df73cc9afe7bf1954de5e8430e70fa2cbdf45e70efc8a2dec8aec04bc5",
"initCodeHash": "0x599e948350c70d699f8a8be945abffd126097de97fade056d29767128320fe75",
"sourceCodeHash": "0x3df29ee1321418914d88ce303b521bf8267ef234b919870b26639d08d7f806bd"
},
"src/L2/WETH.sol": {
Expand Down
8 changes: 4 additions & 4 deletions packages/contracts-bedrock/src/libraries/Predeploys.sol
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,13 @@ library Predeploys {
address internal constant CROSS_L2_INBOX = 0x4200000000000000000000000000000000000022;

/// @notice Address of the L2ToL2CrossDomainMessenger predeploy.
address internal constant L2_TO_L2_CROSS_DOMAIN_MESSENGER = 0x4200000000000000000000000000000000000024;
address internal constant L2_TO_L2_CROSS_DOMAIN_MESSENGER = 0x4200000000000000000000000000000000000023;

/// @notice Address of the SuperchainWETH predeploy.
address internal constant SUPERCHAIN_WETH = 0x4200000000000000000000000000000000000025;
address internal constant SUPERCHAIN_WETH = 0x4200000000000000000000000000000000000024;

/// @notice Address of the ETHLiquidity predeploy.
address internal constant ETH_LIQUIDITY = 0x4200000000000000000000000000000000000026;
address internal constant ETH_LIQUIDITY = 0x4200000000000000000000000000000000000025;

/// @notice Address of the L2Boba predeploy.
address internal constant L2_BOBA = 0xa18bF3994C0Cc6E3b63ac420308E5383f53120D7;
Expand Down Expand Up @@ -132,7 +132,7 @@ library Predeploys {

/// @notice Returns true if the predeploy is not proxied.
function notProxied(address _addr) internal pure returns (bool) {
return _addr == GOVERNANCE_TOKEN || _addr == WETH || _addr == L2_BOBA;
return _addr == GOVERNANCE_TOKEN || _addr == WETH || _addr == LEGACY_ERC20_ETH || _addr == L2_BOBA;
}

/// @notice Returns true if the address is a defined predeploy that is embedded into new OP-Stack chains.
Expand Down
8 changes: 4 additions & 4 deletions packages/contracts-bedrock/test/L2Genesis.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -147,18 +147,18 @@ contract L2GenesisTest is Test {
genesis.setPredeployProxies();
genesis.writeGenesisAllocs(_path);

// 1 predeploys do not have proxies
assertEq(getCodeCount(_path, "Proxy.sol:Proxy"), Predeploys.PREDEPLOY_COUNT - 1);
// 2 predeploys do not have proxies
assertEq(getCodeCount(_path, "Proxy.sol:Proxy"), Predeploys.PREDEPLOY_COUNT - 2);

// 21 proxies have the implementation set if useInterop is true and 17 if useInterop is false
assertEq(getPredeployCountWithSlotSet(_path, Constants.PROXY_IMPLEMENTATION_ADDRESS), _useInterop ? 21 : 17);

// All proxies except 1 have the proxy 1967 admin slot set to the proxy admin
// All proxies except 2 have the proxy 1967 admin slot set to the proxy admin
assertEq(
getPredeployCountWithSlotSetToValue(
_path, Constants.PROXY_OWNER_ADDRESS, bytes32(uint256(uint160(Predeploys.PROXY_ADMIN)))
),
Predeploys.PREDEPLOY_COUNT - 1
Predeploys.PREDEPLOY_COUNT - 2
);

// Also see Predeploys.t.test_predeploysSet_succeeds which uses L1Genesis for the CommonTest prestate.
Expand Down
5 changes: 3 additions & 2 deletions packages/contracts-bedrock/test/Predeploys.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,13 @@ contract PredeploysTest is CommonTest {
|| _addr == Predeploys.L1_BLOCK_NUMBER || _addr == Predeploys.LEGACY_MESSAGE_PASSER
|| _addr == Predeploys.PROXY_ADMIN || _addr == Predeploys.BASE_FEE_VAULT || _addr == Predeploys.L1_FEE_VAULT
|| _addr == Predeploys.GOVERNANCE_TOKEN || _addr == Predeploys.SCHEMA_REGISTRY || _addr == Predeploys.EAS
|| _addr == Predeploys.L2_BOBA;
|| _addr == Predeploys.L2_BOBA || _addr == Predeploys.LEGACY_ERC20_ETH;
}

/// @dev Returns true if the address is not proxied.
function _notProxied(address _addr) internal pure returns (bool) {
return _addr == Predeploys.GOVERNANCE_TOKEN || _addr == Predeploys.WETH || _addr == Predeploys.L2_BOBA;
return _addr == Predeploys.GOVERNANCE_TOKEN || _addr == Predeploys.WETH || _addr == Predeploys.LEGACY_ERC20_ETH
|| _addr == Predeploys.L2_BOBA;
}

/// @dev Returns true if the account is not meant to be in the L2 genesis anymore.
Expand Down
Loading