Skip to content
3 changes: 1 addition & 2 deletions bedrock-devnet/devnet/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,8 @@ def devnet_l2_allocs(paths):
log.info('Generating L2 genesis allocs, with L1 addresses: '+paths.l1_deployments_path)

fqn = 'scripts/L2Genesis.s.sol:L2Genesis'
# Use foundry pre-funded account #1 for the deployer
run_command([
'forge', 'script', fqn, "--sig", "runWithAllUpgrades()", "--private-key", "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"
'forge', 'script', fqn, "--sig", "runWithAllUpgrades()"
], env={
'CONTRACT_ADDRESSES_PATH': paths.l1_deployments_path,
}, cwd=paths.contracts_bedrock_dir)
Expand Down
21 changes: 20 additions & 1 deletion packages/contracts-bedrock/scripts/L2Genesis.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,15 @@ contract L2Genesis is Deployer {
0x9DCCe783B6464611f38631e6C851bf441907c710 // 29
];

/// @notice The address of the deployer account.
address internal deployer;

/// @notice Sets up the script and ensures the deployer account is used to make calls.
function setUp() public override {
deployer = makeAddr("deployer");
super.setUp();
}

function name() public pure override returns (string memory) {
return "L2Genesis";
}
Expand Down Expand Up @@ -128,6 +137,7 @@ contract L2Genesis is Deployer {

/// @notice Build the L2 genesis.
function runWithOptions(OutputMode _mode, L1Dependencies memory _l1Dependencies) public {
vm.startPrank(deployer);
vm.chainId(cfg.l2ChainID());

dealEthToPrecompiles();
Expand All @@ -137,6 +147,8 @@ contract L2Genesis is Deployer {
if (cfg.fundDevAccounts()) {
fundDevAccounts();
}
vm.stopPrank();

// Genesis is "complete" at this point, but some hardfork activation steps remain.
// Depending on the "Output Mode" we perform the activations and output the necessary state dumps.
if (_mode == OutputMode.LOCAL_DELTA) {
Expand All @@ -145,6 +157,7 @@ contract L2Genesis is Deployer {
if (_mode == OutputMode.OUTPUT_ALL) {
writeGenesisAllocs(Config.stateDumpPath("-delta"));
}

activateEcotone();
if (_mode == OutputMode.OUTPUT_ALL || _mode == OutputMode.DEFAULT_LATEST) {
writeGenesisAllocs(Config.stateDumpPath(""));
Expand Down Expand Up @@ -479,11 +492,14 @@ contract L2Genesis is Deployer {
vm.setNonce(Preinstalls.BeaconBlockRootsSender, 1);
}

/// @notice Activate Ecotone network upgrade.
function activateEcotone() public {
require(Preinstalls.BeaconBlockRoots.code.length > 0, "L2Genesis: must have beacon-block-roots contract");
console.log("Activating ecotone in GasPriceOracle contract");
vm.prank(L1Block(Predeploys.L1_BLOCK_ATTRIBUTES).DEPOSITOR_ACCOUNT());

vm.startPrank(L1Block(Predeploys.L1_BLOCK_ATTRIBUTES).DEPOSITOR_ACCOUNT());
GasPriceOracle(Predeploys.GAS_PRICE_ORACLE).setEcotone();
vm.stopPrank();
}

/// @notice Sets the bytecode in state
Expand Down Expand Up @@ -514,6 +530,9 @@ contract L2Genesis is Deployer {
vm.resetNonce(msg.sender);
vm.deal(msg.sender, 0);

vm.deal(deployer, 0);
vm.resetNonce(deployer);

console.log("Writing state dump to: %s", _path);
vm.dumpState(_path);
sortJsonByKeys(_path);
Expand Down
3 changes: 2 additions & 1 deletion packages/contracts-bedrock/test/setup/Setup.sol
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,9 @@ contract Setup {

// Set the governance token's owner to be the final system owner
address finalSystemOwner = deploy.cfg().finalSystemOwner();
vm.prank(governanceToken.owner());
vm.startPrank(governanceToken.owner());
governanceToken.transferOwnership(finalSystemOwner);
vm.stopPrank();

// L2 predeploys
labelPredeploy(Predeploys.L2_STANDARD_BRIDGE);
Expand Down