@@ -5,7 +5,7 @@ import { Script } from "forge-std/Script.sol";
55import { console2 as console } from "forge-std/console2.sol " ;
66import { Deployer } from "scripts/Deployer.sol " ;
77
8- import { Config } from "scripts/Config.sol " ;
8+ import { Config, OutputMode, Fork, LATEST_FORK } from "scripts/Config.sol " ;
99import { Artifacts } from "scripts/Artifacts.s.sol " ;
1010import { DeployConfig } from "scripts/DeployConfig.s.sol " ;
1111import { Predeploys } from "src/libraries/Predeploys.sol " ;
@@ -37,20 +37,6 @@ struct L1Dependencies {
3737 address payable l1ERC721BridgeProxy;
3838}
3939
40- /// @notice Enum representing different ways of outputting genesis allocs.
41- /// @custom:value DEFAULT_LATEST Represents only latest L2 allocs, written to output path.
42- /// @custom:value LOCAL_LATEST Represents latest L2 allocs, not output anywhere, but kept in-process.
43- /// @custom:value LOCAL_ECOTONE Represents Ecotone-upgrade L2 allocs, not output anywhere, but kept in-process.
44- /// @custom:value LOCAL_DELTA Represents Delta-upgrade L2 allocs, not output anywhere, but kept in-process.
45- /// @custom:value OUTPUT_ALL Represents creation of one L2 allocs file for every upgrade.
46- enum OutputMode {
47- DEFAULT_LATEST,
48- LOCAL_LATEST,
49- LOCAL_ECOTONE,
50- LOCAL_DELTA,
51- OUTPUT_ALL
52- }
53-
5440/// @title L2Genesis
5541/// @notice Generates the genesis state for the L2 network.
5642/// The following safety invariants are used when setting state:
@@ -120,7 +106,7 @@ contract L2Genesis is Deployer {
120106 /// Sets the precompiles, proxies, and the implementation accounts to be `vm.dumpState`
121107 /// to generate a L2 genesis alloc.
122108 function runWithStateDump () public {
123- runWithOptions (OutputMode.DEFAULT_LATEST , artifactDependencies ());
109+ runWithOptions (Config. outputMode (), Config. fork () , artifactDependencies ());
124110 }
125111
126112 /// @notice Alias for `runWithStateDump` so that no `--sig` needs to be specified.
@@ -130,11 +116,17 @@ contract L2Genesis is Deployer {
130116
131117 /// @notice This is used by op-e2e to have a version of the L2 allocs for each upgrade.
132118 function runWithAllUpgrades () public {
133- runWithOptions (OutputMode.OUTPUT_ALL, artifactDependencies ());
119+ runWithOptions (OutputMode.ALL, LATEST_FORK, artifactDependencies ());
120+ }
121+
122+ /// @notice This is used by foundry tests to enable the latest fork with the
123+ /// given L1 dependencies.
124+ function runWithLatestLocal (L1Dependencies memory _l1Dependencies ) public {
125+ runWithOptions (OutputMode.NONE, LATEST_FORK, _l1Dependencies);
134126 }
135127
136128 /// @notice Build the L2 genesis.
137- function runWithOptions (OutputMode _mode , L1Dependencies memory _l1Dependencies ) public {
129+ function runWithOptions (OutputMode _mode , Fork _fork , L1Dependencies memory _l1Dependencies ) public {
138130 vm.startPrank (deployer);
139131 vm.chainId (cfg.l2ChainID ());
140132
@@ -147,28 +139,29 @@ contract L2Genesis is Deployer {
147139 }
148140 vm.stopPrank ();
149141
150- // Genesis is "complete" at this point, but some hardfork activation steps remain.
151- // Depending on the "Output Mode" we perform the activations and output the necessary state dumps.
152- if (_mode == OutputMode.LOCAL_DELTA) {
153- return ;
154- }
155- if (_mode == OutputMode.OUTPUT_ALL) {
142+ if (_mode == OutputMode.ALL || _fork == Fork.DELTA && _mode == OutputMode.LATEST) {
156143 writeGenesisAllocs (Config.stateDumpPath ("-delta " ));
157144 }
145+ if (_fork == Fork.DELTA) {
146+ return ;
147+ }
158148
159149 activateEcotone ();
160150
161- if (_mode == OutputMode.LOCAL_ECOTONE) {
162- return ;
163- }
164- if (_mode == OutputMode.OUTPUT_ALL) {
151+ if (_mode == OutputMode.ALL || _fork == Fork.ECOTONE && _mode == OutputMode.LATEST) {
165152 writeGenesisAllocs (Config.stateDumpPath ("-ecotone " ));
166153 }
154+ if (_fork == Fork.ECOTONE) {
155+ return ;
156+ }
167157
168158 activateFjord ();
169159
170- if (_mode == OutputMode.OUTPUT_ALL || _mode == OutputMode.DEFAULT_LATEST) {
171- writeGenesisAllocs (Config.stateDumpPath ("" ));
160+ if (_mode == OutputMode.ALL || _fork == Fork.FJORD && _mode == OutputMode.LATEST) {
161+ writeGenesisAllocs (Config.stateDumpPath ("-fjord " ));
162+ }
163+ if (_fork == Fork.FJORD) {
164+ return ;
172165 }
173166 }
174167
0 commit comments