Commit 64a1f118 authored by Mark Tyneway's avatar Mark Tyneway Committed by refcell

contracts-bedrock: predeploys test

Ensures that the predeploys are set and have the correct admin
slot set as well as have code present. It does not check what the
specific code is so that this can be ran against forked networks.

Now that we have the L2 contracts imported into the state via
`vm.loadAllocs`, we can begin to port the implementation of `check-l2`
into Solidity and reduce the amount of overhead a developer needs
to make changes to the contracts. The goal is to make as few changes
to other parts of the codebase when making changes to solidity files.

[check-l2](https://github.com/ethereum-optimism/optimism/blob/develop/op-chain-ops/cmd/check-l2/main.go)
runs against the devnet to ensure that the genesis state is correct. Now
we can make those assertions directly in solidity and deprecate the
concept of `check-l2`. We should be able to still run the solidity tests
against forked backends if we write the code in a modular way, so that
we can still run the tests against live networks or devnets.
parent a78776a1
This diff is collapsed.
This diff is collapsed.
...@@ -4,6 +4,6 @@ ...@@ -4,6 +4,6 @@
"label": "mapping(uint256 => struct BlockOracle.BlockInfo)", "label": "mapping(uint256 => struct BlockOracle.BlockInfo)",
"offset": 0, "offset": 0,
"slot": "0", "slot": "0",
"type": "t_mapping(t_uint256,t_struct(BlockInfo)83035_storage)" "type": "t_mapping(t_uint256,t_struct(BlockInfo)72112_storage)"
} }
] ]
\ No newline at end of file
...@@ -11,6 +11,6 @@ ...@@ -11,6 +11,6 @@
"label": "mapping(string => struct Drippie.DripState)", "label": "mapping(string => struct Drippie.DripState)",
"offset": 0, "offset": 0,
"slot": "1", "slot": "1",
"type": "t_mapping(t_string_memory_ptr,t_struct(DripState)91598_storage)" "type": "t_mapping(t_string_memory_ptr,t_struct(DripState)91663_storage)"
} }
] ]
\ No newline at end of file
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
"label": "mapping(bytes32 => struct Attestation)", "label": "mapping(bytes32 => struct Attestation)",
"offset": 0, "offset": 0,
"slot": "50", "slot": "50",
"type": "t_mapping(t_bytes32,t_struct(Attestation)55340_storage)" "type": "t_mapping(t_bytes32,t_struct(Attestation)44875_storage)"
}, },
{ {
"bytes": "32", "bytes": "32",
......
...@@ -4,14 +4,14 @@ ...@@ -4,14 +4,14 @@
"label": "mapping(contract IFaucetAuthModule => struct Faucet.ModuleConfig)", "label": "mapping(contract IFaucetAuthModule => struct Faucet.ModuleConfig)",
"offset": 0, "offset": 0,
"slot": "0", "slot": "0",
"type": "t_mapping(t_contract(IFaucetAuthModule)92519,t_struct(ModuleConfig)92196_storage)" "type": "t_mapping(t_contract(IFaucetAuthModule)92584,t_struct(ModuleConfig)92261_storage)"
}, },
{ {
"bytes": "32", "bytes": "32",
"label": "mapping(contract IFaucetAuthModule => mapping(bytes32 => uint256))", "label": "mapping(contract IFaucetAuthModule => mapping(bytes32 => uint256))",
"offset": 0, "offset": 0,
"slot": "1", "slot": "1",
"type": "t_mapping(t_contract(IFaucetAuthModule)92519,t_mapping(t_bytes32,t_uint256))" "type": "t_mapping(t_contract(IFaucetAuthModule)92584,t_mapping(t_bytes32,t_uint256))"
}, },
{ {
"bytes": "32", "bytes": "32",
......
...@@ -4,49 +4,49 @@ ...@@ -4,49 +4,49 @@
"label": "Timestamp", "label": "Timestamp",
"offset": 0, "offset": 0,
"slot": "0", "slot": "0",
"type": "t_userDefinedValueType(Timestamp)88547" "type": "t_userDefinedValueType(Timestamp)77431"
}, },
{ {
"bytes": "1", "bytes": "1",
"label": "enum GameStatus", "label": "enum GameStatus",
"offset": 8, "offset": 8,
"slot": "0", "slot": "0",
"type": "t_enum(GameStatus)88563" "type": "t_enum(GameStatus)77447"
}, },
{ {
"bytes": "20", "bytes": "20",
"label": "contract IBondManager", "label": "contract IBondManager",
"offset": 9, "offset": 9,
"slot": "0", "slot": "0",
"type": "t_contract(IBondManager)86056" "type": "t_contract(IBondManager)75133"
}, },
{ {
"bytes": "32", "bytes": "32",
"label": "Hash", "label": "Hash",
"offset": 0, "offset": 0,
"slot": "1", "slot": "1",
"type": "t_userDefinedValueType(Hash)88539" "type": "t_userDefinedValueType(Hash)77423"
}, },
{ {
"bytes": "32", "bytes": "32",
"label": "struct IFaultDisputeGame.ClaimData[]", "label": "struct IFaultDisputeGame.ClaimData[]",
"offset": 0, "offset": 0,
"slot": "2", "slot": "2",
"type": "t_array(t_struct(ClaimData)86270_storage)dyn_storage" "type": "t_array(t_struct(ClaimData)75347_storage)dyn_storage"
}, },
{ {
"bytes": "128", "bytes": "128",
"label": "struct IFaultDisputeGame.OutputProposals", "label": "struct IFaultDisputeGame.OutputProposals",
"offset": 0, "offset": 0,
"slot": "3", "slot": "3",
"type": "t_struct(OutputProposals)86285_storage" "type": "t_struct(OutputProposals)75362_storage"
}, },
{ {
"bytes": "32", "bytes": "32",
"label": "mapping(ClaimHash => bool)", "label": "mapping(ClaimHash => bool)",
"offset": 0, "offset": 0,
"slot": "7", "slot": "7",
"type": "t_mapping(t_userDefinedValueType(ClaimHash)88543,t_bool)" "type": "t_mapping(t_userDefinedValueType(ClaimHash)77427,t_bool)"
}, },
{ {
"bytes": "32", "bytes": "32",
......
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
"label": "mapping(address => struct Counters.Counter)", "label": "mapping(address => struct Counters.Counter)",
"offset": 0, "offset": 0,
"slot": "5", "slot": "5",
"type": "t_mapping(t_address,t_struct(Counter)51095_storage)" "type": "t_mapping(t_address,t_struct(Counter)49118_storage)"
}, },
{ {
"bytes": "32", "bytes": "32",
...@@ -60,14 +60,14 @@ ...@@ -60,14 +60,14 @@
"label": "mapping(address => struct ERC20Votes.Checkpoint[])", "label": "mapping(address => struct ERC20Votes.Checkpoint[])",
"offset": 0, "offset": 0,
"slot": "8", "slot": "8",
"type": "t_mapping(t_address,t_array(t_struct(Checkpoint)48241_storage)dyn_storage)" "type": "t_mapping(t_address,t_array(t_struct(Checkpoint)46264_storage)dyn_storage)"
}, },
{ {
"bytes": "32", "bytes": "32",
"label": "struct ERC20Votes.Checkpoint[]", "label": "struct ERC20Votes.Checkpoint[]",
"offset": 0, "offset": 0,
"slot": "9", "slot": "9",
"type": "t_array(t_struct(Checkpoint)48241_storage)dyn_storage" "type": "t_array(t_struct(Checkpoint)46264_storage)dyn_storage"
}, },
{ {
"bytes": "20", "bytes": "20",
......
...@@ -123,6 +123,6 @@ ...@@ -123,6 +123,6 @@
"label": "contract SuperchainConfig", "label": "contract SuperchainConfig",
"offset": 0, "offset": 0,
"slot": "251", "slot": "251",
"type": "t_contract(SuperchainConfig)77365" "type": "t_contract(SuperchainConfig)4111"
} }
] ]
\ No newline at end of file
...@@ -32,6 +32,6 @@ ...@@ -32,6 +32,6 @@
"label": "struct Types.OutputProposal[]", "label": "struct Types.OutputProposal[]",
"offset": 0, "offset": 0,
"slot": "3", "slot": "3",
"type": "t_array(t_struct(OutputProposal)89412_storage)dyn_storage" "type": "t_array(t_struct(OutputProposal)2677_storage)dyn_storage"
} }
] ]
\ No newline at end of file
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
"label": "struct ResourceMetering.ResourceParams", "label": "struct ResourceMetering.ResourceParams",
"offset": 0, "offset": 0,
"slot": "1", "slot": "1",
"type": "t_struct(ResourceParams)76842_storage" "type": "t_struct(ResourceParams)3420_storage"
}, },
{ {
"bytes": "1536", "bytes": "1536",
...@@ -46,7 +46,7 @@ ...@@ -46,7 +46,7 @@
"label": "mapping(bytes32 => struct OptimismPortal.ProvenWithdrawal)", "label": "mapping(bytes32 => struct OptimismPortal.ProvenWithdrawal)",
"offset": 0, "offset": 0,
"slot": "52", "slot": "52",
"type": "t_mapping(t_bytes32,t_struct(ProvenWithdrawal)75921_storage)" "type": "t_mapping(t_bytes32,t_struct(ProvenWithdrawal)2750_storage)"
}, },
{ {
"bytes": "1", "bytes": "1",
...@@ -60,6 +60,6 @@ ...@@ -60,6 +60,6 @@
"label": "contract SuperchainConfig", "label": "contract SuperchainConfig",
"offset": 1, "offset": 1,
"slot": "53", "slot": "53",
"type": "t_contract(SuperchainConfig)77365" "type": "t_contract(SuperchainConfig)3943"
} }
] ]
\ No newline at end of file
...@@ -4,49 +4,49 @@ ...@@ -4,49 +4,49 @@
"label": "Timestamp", "label": "Timestamp",
"offset": 0, "offset": 0,
"slot": "0", "slot": "0",
"type": "t_userDefinedValueType(Timestamp)88547" "type": "t_userDefinedValueType(Timestamp)77431"
}, },
{ {
"bytes": "8", "bytes": "8",
"label": "Timestamp", "label": "Timestamp",
"offset": 8, "offset": 8,
"slot": "0", "slot": "0",
"type": "t_userDefinedValueType(Timestamp)88547" "type": "t_userDefinedValueType(Timestamp)77431"
}, },
{ {
"bytes": "1", "bytes": "1",
"label": "enum GameStatus", "label": "enum GameStatus",
"offset": 16, "offset": 16,
"slot": "0", "slot": "0",
"type": "t_enum(GameStatus)88563" "type": "t_enum(GameStatus)77447"
}, },
{ {
"bytes": "20", "bytes": "20",
"label": "contract IBondManager", "label": "contract IBondManager",
"offset": 0, "offset": 0,
"slot": "1", "slot": "1",
"type": "t_contract(IBondManager)86056" "type": "t_contract(IBondManager)75133"
}, },
{ {
"bytes": "32", "bytes": "32",
"label": "Hash", "label": "Hash",
"offset": 0, "offset": 0,
"slot": "2", "slot": "2",
"type": "t_userDefinedValueType(Hash)88539" "type": "t_userDefinedValueType(Hash)77423"
}, },
{ {
"bytes": "32", "bytes": "32",
"label": "struct IOutputBisectionGame.ClaimData[]", "label": "struct IOutputBisectionGame.ClaimData[]",
"offset": 0, "offset": 0,
"slot": "3", "slot": "3",
"type": "t_array(t_struct(ClaimData)86391_storage)dyn_storage" "type": "t_array(t_struct(ClaimData)75468_storage)dyn_storage"
}, },
{ {
"bytes": "32", "bytes": "32",
"label": "mapping(ClaimHash => bool)", "label": "mapping(ClaimHash => bool)",
"offset": 0, "offset": 0,
"slot": "4", "slot": "4",
"type": "t_mapping(t_userDefinedValueType(ClaimHash)88543,t_bool)" "type": "t_mapping(t_userDefinedValueType(ClaimHash)77427,t_bool)"
}, },
{ {
"bytes": "32", "bytes": "32",
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
"label": "mapping(address => enum ProxyAdmin.ProxyType)", "label": "mapping(address => enum ProxyAdmin.ProxyType)",
"offset": 0, "offset": 0,
"slot": "1", "slot": "1",
"type": "t_mapping(t_address,t_enum(ProxyType)95525)" "type": "t_mapping(t_address,t_enum(ProxyType)2988)"
}, },
{ {
"bytes": "32", "bytes": "32",
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
"label": "contract AddressManager", "label": "contract AddressManager",
"offset": 0, "offset": 0,
"slot": "3", "slot": "3",
"type": "t_contract(AddressManager)87040" "type": "t_contract(AddressManager)2205"
}, },
{ {
"bytes": "1", "bytes": "1",
......
...@@ -11,6 +11,6 @@ ...@@ -11,6 +11,6 @@
"label": "mapping(address => contract AddressManager)", "label": "mapping(address => contract AddressManager)",
"offset": 0, "offset": 0,
"slot": "1", "slot": "1",
"type": "t_mapping(t_address,t_contract(AddressManager)87040)" "type": "t_mapping(t_address,t_contract(AddressManager)76117)"
} }
] ]
\ No newline at end of file
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
"label": "mapping(bytes32 => struct SchemaRecord)", "label": "mapping(bytes32 => struct SchemaRecord)",
"offset": 0, "offset": 0,
"slot": "0", "slot": "0",
"type": "t_mapping(t_bytes32,t_struct(SchemaRecord)57720_storage)" "type": "t_mapping(t_bytes32,t_struct(SchemaRecord)47255_storage)"
}, },
{ {
"bytes": "1568", "bytes": "1568",
......
...@@ -67,6 +67,6 @@ ...@@ -67,6 +67,6 @@
"label": "struct ResourceMetering.ResourceConfig", "label": "struct ResourceMetering.ResourceConfig",
"offset": 0, "offset": 0,
"slot": "105", "slot": "105",
"type": "t_struct(ResourceConfig)76855_storage" "type": "t_struct(ResourceConfig)3433_storage"
} }
] ]
\ No newline at end of file
...@@ -41,6 +41,9 @@ library Predeploys { ...@@ -41,6 +41,9 @@ library Predeploys {
/// @notice Address of the DeployerWhitelist predeploy. No longer active. /// @notice Address of the DeployerWhitelist predeploy. No longer active.
address internal constant DEPLOYER_WHITELIST = 0x4200000000000000000000000000000000000002; address internal constant DEPLOYER_WHITELIST = 0x4200000000000000000000000000000000000002;
/// @notice Address of the canonical WETH9 contract.
address internal constant WETH9 = 0x4200000000000000000000000000000000000006;
/// @custom:legacy /// @custom:legacy
/// @notice Address of the LegacyERC20ETH predeploy. Deprecated. Balances are migrated to the /// @notice Address of the LegacyERC20ETH predeploy. Deprecated. Balances are migrated to the
/// state trie as of the Bedrock upgrade. Contract has been locked and write functions /// state trie as of the Bedrock upgrade. Contract has been locked and write functions
......
// SPDX-License-Identifier: MIT
pragma solidity 0.8.15;
import { CommonTest } from "test/setup/CommonTest.sol";
import { EIP1967Helper } from "test/mocks/EIP1967Helper.sol";
import { Predeploys } from "src/libraries/Predeploys.sol";
contract PredeploysTest is CommonTest {
/// @dev Tests that the predeploy addresses are set correctly. They have code
/// and the proxied accounts have the correct admin.
function test_predeploysSet_succeeds() external {
uint256 count = 2048;
uint160 prefix = uint160(0x420) << 148;
for (uint256 i = 0; i < count; i++) {
address addr = address(prefix | uint160(i));
bytes memory code = addr.code;
assertTrue(code.length > 0);
// Skip the accounts that do not have a proxy
if (addr == Predeploys.LEGACY_ERC20_ETH || addr == Predeploys.GOVERNANCE_TOKEN || addr == Predeploys.WETH9)
{
continue;
}
assertTrue(EIP1967Helper.getAdmin(addr) == Predeploys.PROXY_ADMIN, "Admin mismatch");
}
}
}
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