Commit b952dc06 authored by Mark Tyneway's avatar Mark Tyneway Committed by GitHub

contracts-bedrock: deployer as msg.sender (#10343)

* contracts-bedrock: deployer as msg.sender

Use a special deployer account for the execution of the L2 genesis
script. This should remove the need to set the sender as part
of the devnet.

* devnet: simplify

* contracts-bedrock: fix deployer

* contracts-bedrock: fix build

* build: fix

* contracts-bedrock: more generic prank

* contracts-bedrock: attempt fixup

* contracts-bedrock: set deployer nonce to 0

* contracts-bedrock: prank in genesis

* contracts-bedrock: fix build

* contracts-bedrock: fixup

* contracts-bedrock: fixup

* contracts-bedrock: fixup
parent 3f9de382
...@@ -158,9 +158,8 @@ def devnet_l2_allocs(paths): ...@@ -158,9 +158,8 @@ def devnet_l2_allocs(paths):
log.info('Generating L2 genesis allocs, with L1 addresses: '+paths.l1_deployments_path) log.info('Generating L2 genesis allocs, with L1 addresses: '+paths.l1_deployments_path)
fqn = 'scripts/L2Genesis.s.sol:L2Genesis' fqn = 'scripts/L2Genesis.s.sol:L2Genesis'
# Use foundry pre-funded account #1 for the deployer
run_command([ run_command([
'forge', 'script', fqn, "--sig", "runWithAllUpgrades()", "--private-key", "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80" 'forge', 'script', fqn, "--sig", "runWithAllUpgrades()"
], env={ ], env={
'CONTRACT_ADDRESSES_PATH': paths.l1_deployments_path, 'CONTRACT_ADDRESSES_PATH': paths.l1_deployments_path,
}, cwd=paths.contracts_bedrock_dir) }, cwd=paths.contracts_bedrock_dir)
......
...@@ -96,6 +96,15 @@ contract L2Genesis is Deployer { ...@@ -96,6 +96,15 @@ contract L2Genesis is Deployer {
0x9DCCe783B6464611f38631e6C851bf441907c710 // 29 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) { function name() public pure override returns (string memory) {
return "L2Genesis"; return "L2Genesis";
} }
...@@ -128,6 +137,7 @@ contract L2Genesis is Deployer { ...@@ -128,6 +137,7 @@ contract L2Genesis is Deployer {
/// @notice Build the L2 genesis. /// @notice Build the L2 genesis.
function runWithOptions(OutputMode _mode, L1Dependencies memory _l1Dependencies) public { function runWithOptions(OutputMode _mode, L1Dependencies memory _l1Dependencies) public {
vm.startPrank(deployer);
vm.chainId(cfg.l2ChainID()); vm.chainId(cfg.l2ChainID());
dealEthToPrecompiles(); dealEthToPrecompiles();
...@@ -137,6 +147,8 @@ contract L2Genesis is Deployer { ...@@ -137,6 +147,8 @@ contract L2Genesis is Deployer {
if (cfg.fundDevAccounts()) { if (cfg.fundDevAccounts()) {
fundDevAccounts(); fundDevAccounts();
} }
vm.stopPrank();
// Genesis is "complete" at this point, but some hardfork activation steps remain. // 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. // Depending on the "Output Mode" we perform the activations and output the necessary state dumps.
if (_mode == OutputMode.LOCAL_DELTA) { if (_mode == OutputMode.LOCAL_DELTA) {
...@@ -145,6 +157,7 @@ contract L2Genesis is Deployer { ...@@ -145,6 +157,7 @@ contract L2Genesis is Deployer {
if (_mode == OutputMode.OUTPUT_ALL) { if (_mode == OutputMode.OUTPUT_ALL) {
writeGenesisAllocs(Config.stateDumpPath("-delta")); writeGenesisAllocs(Config.stateDumpPath("-delta"));
} }
activateEcotone(); activateEcotone();
if (_mode == OutputMode.OUTPUT_ALL || _mode == OutputMode.DEFAULT_LATEST) { if (_mode == OutputMode.OUTPUT_ALL || _mode == OutputMode.DEFAULT_LATEST) {
writeGenesisAllocs(Config.stateDumpPath("")); writeGenesisAllocs(Config.stateDumpPath(""));
...@@ -479,11 +492,14 @@ contract L2Genesis is Deployer { ...@@ -479,11 +492,14 @@ contract L2Genesis is Deployer {
vm.setNonce(Preinstalls.BeaconBlockRootsSender, 1); vm.setNonce(Preinstalls.BeaconBlockRootsSender, 1);
} }
/// @notice Activate Ecotone network upgrade.
function activateEcotone() public { function activateEcotone() public {
require(Preinstalls.BeaconBlockRoots.code.length > 0, "L2Genesis: must have beacon-block-roots contract"); require(Preinstalls.BeaconBlockRoots.code.length > 0, "L2Genesis: must have beacon-block-roots contract");
console.log("Activating ecotone in GasPriceOracle 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(); GasPriceOracle(Predeploys.GAS_PRICE_ORACLE).setEcotone();
vm.stopPrank();
} }
/// @notice Sets the bytecode in state /// @notice Sets the bytecode in state
...@@ -514,6 +530,9 @@ contract L2Genesis is Deployer { ...@@ -514,6 +530,9 @@ contract L2Genesis is Deployer {
vm.resetNonce(msg.sender); vm.resetNonce(msg.sender);
vm.deal(msg.sender, 0); vm.deal(msg.sender, 0);
vm.deal(deployer, 0);
vm.resetNonce(deployer);
console.log("Writing state dump to: %s", _path); console.log("Writing state dump to: %s", _path);
vm.dumpState(_path); vm.dumpState(_path);
sortJsonByKeys(_path); sortJsonByKeys(_path);
......
...@@ -187,8 +187,9 @@ contract Setup { ...@@ -187,8 +187,9 @@ contract Setup {
// Set the governance token's owner to be the final system owner // Set the governance token's owner to be the final system owner
address finalSystemOwner = deploy.cfg().finalSystemOwner(); address finalSystemOwner = deploy.cfg().finalSystemOwner();
vm.prank(governanceToken.owner()); vm.startPrank(governanceToken.owner());
governanceToken.transferOwnership(finalSystemOwner); governanceToken.transferOwnership(finalSystemOwner);
vm.stopPrank();
// L2 predeploys // L2 predeploys
labelPredeploy(Predeploys.L2_STANDARD_BRIDGE); labelPredeploy(Predeploys.L2_STANDARD_BRIDGE);
......
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