Skip to content

Commit

Permalink
fix: l2 contract deployment (#35)
Browse files Browse the repository at this point in the history
* fix: l2 contract deployment

* add some readme
  • Loading branch information
barnabasbusa authored Jun 19, 2024
1 parent d6fb36f commit 3f2b16d
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 89 deletions.
2 changes: 2 additions & 0 deletions .github/tests/op-node.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@ ethereum_package:
- el_type: reth
network_params:
preset: minimal
additional_services:
- dora

3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,3 +140,6 @@ ethereum_package:
- blockscout
```
Note: if configuring multiple L2s, make sure that the `network_id` and `name` are set to differentiate networks.

### Additional configurations
Please find examples of additional configurations in the [test folder](.github/tests/).
6 changes: 1 addition & 5 deletions main.star
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@ def run(plan, args):
l1_config_env_vars = get_l1_config(all_l1_participants, l1_network_params)

# Deploy Create2 Factory contract (only need to do this once for multiple l2s)
l2_private_keys = contract_deployer.deploy_factory_contract(
plan, l1_priv_key, l1_config_env_vars
)
contract_deployer.deploy_factory_contract(plan, l1_priv_key, l1_config_env_vars)

# Deploy L2s
if type(args["optimism_package"]) == "dict":
Expand All @@ -44,7 +42,6 @@ def run(plan, args):
l1_config_env_vars,
l1_priv_key,
all_l1_participants[0].el_context,
l2_private_keys,
)
elif type(args["optimism_package"]) == "list":
seen_names = {}
Expand Down Expand Up @@ -74,7 +71,6 @@ def run(plan, args):
l1_config_env_vars,
l1_priv_key,
all_l1_participants[0].el_context,
l2_private_keys,
)
else:
fail("invalid type provided for param: `optimism-package`")
Expand Down
21 changes: 0 additions & 21 deletions network_params_two_rollups.yaml

This file was deleted.

87 changes: 26 additions & 61 deletions src/contracts/contract_deployer.star
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ def deploy_factory_contract(
l1_config_env_vars,
):
factory_deployment_result = plan.run_sh(
name="op_deploy_factory_contract",
description="Deploying L2 factory contract to L1 (needs to wait for l1 to finalize, about 4 min for minimal preset, 30 min for mainnet)",
image=IMAGE,
env_vars={
Expand All @@ -21,31 +22,9 @@ def deploy_factory_contract(
"DEPLOYMENT_CONTEXT": "getting-started",
}
| l1_config_env_vars,
store=[
StoreSpec(src="/network-configs", name="network-configs"),
],
run=" && ".join(
[
"./packages/contracts-bedrock/scripts/getting-started/wallets.sh >> {0}".format(
ENVRC_PATH
),
"sed -i '1d' {0}".format(
ENVRC_PATH
), # Remove the first line (not commented out)
"echo 'export IMPL_SALT=$(openssl rand -hex 32)' >> {0}".format(
ENVRC_PATH
),
". {0}".format(ENVRC_PATH),
"mkdir -p /network-configs",
"web3 transfer $FUND_VALUE to $GS_ADMIN_ADDRESS", # Fund Admin
"sleep 3",
"web3 transfer $FUND_VALUE to $GS_BATCHER_ADDRESS", # Fund Batcher
"sleep 3",
"web3 transfer $FUND_VALUE to $GS_PROPOSER_ADDRESS", # Fund Proposer
"sleep 3",
"web3 transfer $FUND_VALUE to {0}".format(
FACTORY_DEPLOYER_ADDRESS
), # Fund Factory deployer
"web3 transfer $FUND_VALUE to {0}".format(FACTORY_DEPLOYER_ADDRESS),
"sleep 3",
# sleep till chain is finalized
"while true; do sleep 3; echo 'Chain is not yet finalized...'; if [ \"$(curl -s $CL_RPC_URL/eth/v1/beacon/states/head/finality_checkpoints | jq -r '.data.finalized.epoch')\" != \"0\" ]; then echo 'Chain is finalized!'; break; fi; done",
Expand All @@ -54,49 +33,22 @@ def deploy_factory_contract(
"cast codesize {0} --rpc-url $L1_RPC_URL".format(
FACTORY_DEPLOYER_ADDRESS
),
"echo -n $GS_SEQUENCER_PRIVATE_KEY > /network-configs/GS_SEQUENCER_PRIVATE_KEY",
"echo -n $GS_BATCHER_PRIVATE_KEY > /network-configs/GS_BATCHER_PRIVATE_KEY",
"echo -n $GS_PROPOSER_PRIVATE_KEY > /network-configs/GS_PROPOSER_PRIVATE_KEY",
]
),
wait="2000s",
)

gs_sequencer_private_key = plan.run_sh(
description="Getting the sequencer private key",
run="cat /network-configs/GS_SEQUENCER_PRIVATE_KEY ",
files={"/network-configs": factory_deployment_result.files_artifacts[0]},
)

gs_batcher_private_key = plan.run_sh(
description="Getting the batcher private key",
run="cat /network-configs/GS_BATCHER_PRIVATE_KEY ",
files={"/network-configs": factory_deployment_result.files_artifacts[0]},
)

gs_proposer_private_key = plan.run_sh(
description="Getting the proposer private key",
run="cat /network-configs/GS_PROPOSER_PRIVATE_KEY ",
files={"/network-configs": factory_deployment_result.files_artifacts[0]},
)

return struct(
sequencer_private_key=gs_sequencer_private_key.output,
batcher_private_key=gs_batcher_private_key.output,
proposer_private_key=gs_proposer_private_key.output,
)


def deploy_l2_contracts(
plan,
priv_key,
l1_config_env_vars,
l2_config_env_vars,
l2_services_suffix,
private_keys,
):
op_genesis = plan.run_sh(
description="Deploying L2 contracts (takes a few minutes (30 mins for mainnet preset - 4 mins for minimal preset) -- L1 has to be finalized first)",
name="op_deploy_l2_contracts",
description="Deploying L2 contracts (takes about a minute)",
image=IMAGE,
env_vars={
"WEB3_PRIVATE_KEY": str(priv_key),
Expand All @@ -117,9 +69,6 @@ def deploy_l2_contracts(
"./packages/contracts-bedrock/scripts/getting-started/wallets.sh >> {0}".format(
ENVRC_PATH
),
"sed -i '1d' {0}".format(
ENVRC_PATH
), # Remove the first line (not commented out)
"echo 'export IMPL_SALT=$(openssl rand -hex 32)' >> {0}".format(
ENVRC_PATH
),
Expand All @@ -131,8 +80,6 @@ def deploy_l2_contracts(
"sleep 3",
"web3 transfer $FUND_VALUE to $GS_PROPOSER_ADDRESS", # Fund Proposer
"sleep 3",
"web3 transfer $FUND_VALUE to {0}".format(FACTORY_DEPLOYER_ADDRESS),
"sleep 3",
"cd /workspace/optimism/packages/contracts-bedrock",
"./scripts/getting-started/config.sh",
"sleep 5",
Expand All @@ -156,7 +103,25 @@ def deploy_l2_contracts(
"echo -n $GS_PROPOSER_PRIVATE_KEY > /network-configs/GS_PROPOSER_PRIVATE_KEY",
]
),
wait="2000s",
wait="300s",
)

gs_sequencer_private_key = plan.run_sh(
description="Getting the sequencer private key",
run="cat /network-configs/GS_SEQUENCER_PRIVATE_KEY ",
files={"/network-configs": op_genesis.files_artifacts[0]},
)

gs_batcher_private_key = plan.run_sh(
description="Getting the batcher private key",
run="cat /network-configs/GS_BATCHER_PRIVATE_KEY ",
files={"/network-configs": op_genesis.files_artifacts[0]},
)

gs_proposer_private_key = plan.run_sh(
description="Getting the proposer private key",
run="cat /network-configs/GS_PROPOSER_PRIVATE_KEY ",
files={"/network-configs": op_genesis.files_artifacts[0]},
)

l2oo_address = plan.run_sh(
Expand Down Expand Up @@ -189,9 +154,9 @@ def deploy_l2_contracts(
)

private_keys = {
"GS_SEQUENCER_PRIVATE_KEY": private_keys.sequencer_private_key,
"GS_BATCHER_PRIVATE_KEY": private_keys.batcher_private_key,
"GS_PROPOSER_PRIVATE_KEY": private_keys.proposer_private_key,
"GS_SEQUENCER_PRIVATE_KEY": gs_sequencer_private_key.output,
"GS_BATCHER_PRIVATE_KEY": gs_batcher_private_key.output,
"GS_PROPOSER_PRIVATE_KEY": gs_proposer_private_key.output,
}

blockscout_env_variables = {
Expand Down
2 changes: 0 additions & 2 deletions src/l2.star
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ def launch_l2(
l1_config,
l1_priv_key,
l1_bootnode_context,
l2_private_keys,
):
plan.print("Parsing the L2 input args")
args_with_right_defaults = input_parser.input_parser(plan, l2_args)
Expand All @@ -36,7 +35,6 @@ def launch_l2(
l1_config,
l2_config_env_vars,
l2_services_suffix,
l2_private_keys,
)

plan.print("Deploying L2 with name {0}".format(network_params.name))
Expand Down

0 comments on commit 3f2b16d

Please sign in to comment.