Skip to content

Commit

Permalink
chore: Upgrade op-deployer, fix intent generation (#121)
Browse files Browse the repository at this point in the history
  • Loading branch information
mslipper authored Jan 6, 2025
1 parent 99fe41d commit 48f3ebd
Show file tree
Hide file tree
Showing 5 changed files with 161 additions and 72 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -364,9 +364,9 @@ optimism_package:
# L2 contract deployer configuration - used for all L2 networks
# The docker image that should be used for the L2 contract deployer
op_contract_deployer_params:
image: us-docker.pkg.dev/oplabs-tools-artifacts/images/op-deployer:v0.0.7
l1_artifacts_locator: https://storage.googleapis.com/oplabs-contract-artifacts/artifacts-v1-9af7366a7102f51e8dbe451dcfa22971131d89e218915c91f420a164cc48be65.tar.gz
l2_artifacts_locator: https://storage.googleapis.com/oplabs-contract-artifacts/artifacts-v1-9af7366a7102f51e8dbe451dcfa22971131d89e218915c91f420a164cc48be65.tar.gz
image: us-docker.pkg.dev/oplabs-tools-artifacts/images/op-deployer:v0.0.8
l1_artifacts_locator: https://storage.googleapis.com/oplabs-contract-artifacts/artifacts-v1-c193a1863182092bc6cb723e523e8313a0f4b6e9c9636513927f1db74c047c15.tar.gz
l2_artifacts_locator: https://storage.googleapis.com/oplabs-contract-artifacts/artifacts-v1-c193a1863182092bc6cb723e523e8313a0f4b6e9c9636513927f1db74c047c15.tar.gz

# The global log level that all clients should log at
# Valid values are "error", "warn", "info", "debug", and "trace"
Expand Down
6 changes: 3 additions & 3 deletions network_params.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ optimism_package:
builder_port: ""
additional_services: []
op_contract_deployer_params:
image: us-docker.pkg.dev/oplabs-tools-artifacts/images/op-deployer:v0.0.7
l1_artifacts_locator: https://storage.googleapis.com/oplabs-contract-artifacts/artifacts-v1-9af7366a7102f51e8dbe451dcfa22971131d89e218915c91f420a164cc48be65.tar.gz
l2_artifacts_locator: https://storage.googleapis.com/oplabs-contract-artifacts/artifacts-v1-9af7366a7102f51e8dbe451dcfa22971131d89e218915c91f420a164cc48be65.tar.gz
image: us-docker.pkg.dev/oplabs-tools-artifacts/images/op-deployer:v0.0.8
l1_artifacts_locator: https://storage.googleapis.com/oplabs-contract-artifacts/artifacts-v1-c193a1863182092bc6cb723e523e8313a0f4b6e9c9636513927f1db74c047c15.tar.gz
l2_artifacts_locator: https://storage.googleapis.com/oplabs-contract-artifacts/artifacts-v1-c193a1863182092bc6cb723e523e8313a0f4b6e9c9636513927f1db74c047c15.tar.gz
global_log_level: "info"
global_node_selectors: {}
global_tolerations: []
Expand Down
214 changes: 152 additions & 62 deletions src/contracts/contract_deployer.star
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,18 @@ FUND_SCRIPT_FILEPATH = "../../static_files/scripts"
utils = import_module("../util.star")


CANNED_VALUES = (
("int", "eip1559Denominator", 50),
("int", "eip1559DenominatorCanyon", 250),
("int", "eip1559Elasticity", 6),
)


def deploy_contracts(plan, priv_key, l1_config_env_vars, optimism_args, l1_network):
l2_chain_ids = ",".join(
[str(chain.network_params.network_id) for chain in optimism_args.chains]
)
l2_chain_ids_list = [
str(chain.network_params.network_id) for chain in optimism_args.chains
]
l2_chain_ids = ",".join(l2_chain_ids_list)

op_deployer_init = plan.run_sh(
name="op-deployer-init",
Expand All @@ -28,13 +36,41 @@ def deploy_contracts(plan, priv_key, l1_config_env_vars, optimism_args, l1_netwo
run=" && ".join(
[
"mkdir -p /network-data",
"op-deployer init --l1-chain-id $L1_CHAIN_ID --l2-chain-ids {0} --workdir /network-data".format(
"op-deployer init --intent-config-type custom --l1-chain-id $L1_CHAIN_ID --l2-chain-ids {0} --workdir /network-data".format(
l2_chain_ids
),
]
),
)

fund_script_artifact = plan.upload_files(
src=FUND_SCRIPT_FILEPATH,
name="op-deployer-fund-script",
)

collect_fund = plan.run_sh(
name="op-deployer-fund",
description="Collect keys, and fund addresses",
image=utils.DEPLOYMENT_UTILS_IMAGE,
env_vars={
"PRIVATE_KEY": str(priv_key),
"FUND_VALUE": "10ether",
"L1_NETWORK": str(l1_network),
}
| l1_config_env_vars,
store=[
StoreSpec(
src="/network-data",
name="op-deployer-configs",
)
],
files={
"/network-data": op_deployer_init.files_artifacts[0],
"/fund-script": fund_script_artifact,
},
run='bash /fund-script/fund.sh "{0}"'.format(l2_chain_ids),
)

hardfork_schedule = []
for index, chain in enumerate(optimism_args.chains):
np = chain.network_params
Expand All @@ -54,45 +90,91 @@ def deploy_contracts(plan, priv_key, l1_config_env_vars, optimism_args, l1_netwo
if activation_timestamp != None:
hardfork_schedule.append((index, fork_key, activation_timestamp))

intent_updates = (
intent_updates = [
(
"string",
"l1ContractsLocator",
optimism_args.op_contract_deployer_params.l1_artifacts_locator,
),
(
"string",
"l2ContractsLocator",
optimism_args.op_contract_deployer_params.l2_artifacts_locator,
),
address_update(
"superchainRoles.guardian", "l1ProxyAdmin", l2_chain_ids_list[0]
),
address_update(
"superchainRoles.protocolVersionsOwner",
"l1ProxyAdmin",
l2_chain_ids_list[0],
),
address_update(
"superchainRoles.proxyAdminOwner", "l1ProxyAdmin", l2_chain_ids_list[0]
),
]
intent_updates.extend(
[
(
"string",
"l1ContractsLocator",
optimism_args.op_contract_deployer_params.l1_artifacts_locator,
),
(
"string",
"l2ContractsLocator",
optimism_args.op_contract_deployer_params.l2_artifacts_locator,
),
]
+ [
(
"int",
"chains.[{0}].deployOverrides.l2BlockTime".format(index),
str(chain.network_params.seconds_per_slot),
)
for index, chain in enumerate(optimism_args.chains)
]
+ [
(
"bool",
"chains.[{0}].deployOverrides.fundDevAccounts".format(index),
"true" if chain.network_params.fund_dev_accounts else "false",
)
for index, chain in enumerate(optimism_args.chains)
]
+ [
(
"string",
"chains.[{0}].deployOverrides.{1}".format(index, fork_key),
chain_key(index, "deployOverrides.{0}".format(fork_key)),
"0x%x" % activation_timestamp,
)
for index, fork_key, activation_timestamp in hardfork_schedule
]
)

for i, chain in enumerate(optimism_args.chains):
chain_id = str(chain.network_params.network_id)

intent_updates.extend(
[
(
"int",
chain_key(i, "deployOverrides.l2BlockTime"),
str(chain.network_params.seconds_per_slot),
),
(
"bool",
chain_key(i, "deployOverrides.fundDevAccounts"),
"true" if chain.network_params.fund_dev_accounts else "false",
),
address_update(
chain_key(i, "baseFeeVaultRecipient"),
"baseFeeVaultRecipient",
chain_id,
),
address_update(
chain_key(i, "l1FeeVaultRecipient"), "l1FeeVaultRecipient", chain_id
),
address_update(
chain_key(i, "sequencerFeeVaultRecipient"),
"sequencerFeeVaultRecipient",
chain_id,
),
address_update(chain_key(i, "roles.batcher"), "batcher", chain_id),
address_update(
chain_key(i, "roles.challenger"), "challenger", chain_id
),
address_update(
chain_key(i, "roles.l1ProxyAdminOwner"), "l1ProxyAdmin", chain_id
),
address_update(
chain_key(i, "roles.l2ProxyAdminOwner"), "l2ProxyAdmin", chain_id
),
address_update(chain_key(i, "roles.proposer"), "proposer", chain_id),
address_update(
chain_key(i, "roles.systemConfigOwner"),
"systemConfigOwner",
chain_id,
),
address_update(
chain_key(i, "roles.unsafeBlockSigner"), "sequencer", chain_id
),
]
)
intent_updates.extend([(t, chain_key(i, k), v) for t, k, v in CANNED_VALUES])

op_deployer_configure = plan.run_sh(
name="op-deployer-configure",
description="Configure L2 contract deployments",
Expand All @@ -108,7 +190,7 @@ def deploy_contracts(plan, priv_key, l1_config_env_vars, optimism_args, l1_netwo
},
run=" && ".join(
[
"cat /network-data/intent.toml | dasel put -r toml -t {0} -v '{2}' '{1}' -o /network-data/intent.toml".format(
"cat /network-data/intent.toml | dasel put -r toml -t {0} -v {2} '{1}' -o /network-data/intent.toml".format(
t, k, v
)
for t, k, v in intent_updates
Expand All @@ -132,7 +214,7 @@ def deploy_contracts(plan, priv_key, l1_config_env_vars, optimism_args, l1_netwo
]
)

op_deployer_apply = plan.run_sh(
op_deployer_output = plan.run_sh(
name="op-deployer-apply",
description="Apply L2 contract deployments",
image=optimism_args.op_contract_deployer_params.image,
Expand All @@ -149,32 +231,40 @@ def deploy_contracts(plan, priv_key, l1_config_env_vars, optimism_args, l1_netwo
run=" && ".join(apply_cmds),
)

fund_script_artifact = plan.upload_files(
src=FUND_SCRIPT_FILEPATH,
name="op-deployer-fund-script",
)
for chain in optimism_args.chains:
plan.run_sh(
name="op-deployer-generate-chainspec",
description="Generate chainspec",
image=utils.DEPLOYMENT_UTILS_IMAGE,
env_vars={"CHAIN_ID": str(chain.network_params.network_id)},
store=[
StoreSpec(
src="/network-data",
name="op-deployer-configs",
)
],
files={
"/network-data": op_deployer_output.files_artifacts[0],
"/fund-script": fund_script_artifact,
},
run='cat "/network-data/genesis-$CHAIN_ID.json" | jq --from-file /fund-script/gen2spec.jq > "/network-data/chainspec-$CHAIN_ID.json"',
)

collect_fund = plan.run_sh(
name="op-deployer-fund",
description="Collect keys, and fund addresses",
image=utils.DEPLOYMENT_UTILS_IMAGE,
env_vars={
"PRIVATE_KEY": str(priv_key),
"FUND_VALUE": "10ether",
"L1_NETWORK": str(l1_network),
}
| l1_config_env_vars,
store=[
StoreSpec(
src="/network-data",
name="op-deployer-configs",
)
],
files={
"/network-data": op_deployer_apply.files_artifacts[0],
"/fund-script": fund_script_artifact,
},
run='bash /fund-script/fund.sh "{0}"'.format(l2_chain_ids),
return op_deployer_output.files_artifacts[0]


def chain_key(index, key):
return "chains.[{0}].{1}".format(index, key)


def address_update(key, filename, l2_chain_id):
return (
"string",
key,
read_address_cmd(filename + "-" + l2_chain_id),
)

return collect_fund.files_artifacts[0]

def read_address_cmd(filename):
cmd = "jq -r .address /network-data/{0}.json".format(filename)
return "`{0}`".format(cmd)
6 changes: 3 additions & 3 deletions src/package_io/input_parser.star
Original file line number Diff line number Diff line change
Expand Up @@ -425,9 +425,9 @@ def default_participant():

def default_op_contract_deployer_params():
return {
"image": "us-docker.pkg.dev/oplabs-tools-artifacts/images/op-deployer:v0.0.7",
"l1_artifacts_locator": "https://storage.googleapis.com/oplabs-contract-artifacts/artifacts-v1-9af7366a7102f51e8dbe451dcfa22971131d89e218915c91f420a164cc48be65.tar.gz",
"l2_artifacts_locator": "https://storage.googleapis.com/oplabs-contract-artifacts/artifacts-v1-9af7366a7102f51e8dbe451dcfa22971131d89e218915c91f420a164cc48be65.tar.gz",
"image": "us-docker.pkg.dev/oplabs-tools-artifacts/images/op-deployer:v0.0.8",
"l1_artifacts_locator": "https://storage.googleapis.com/oplabs-contract-artifacts/artifacts-v1-c193a1863182092bc6cb723e523e8313a0f4b6e9c9636513927f1db74c047c15.tar.gz",
"l2_artifacts_locator": "https://storage.googleapis.com/oplabs-contract-artifacts/artifacts-v1-c193a1863182092bc6cb723e523e8313a0f4b6e9c9636513927f1db74c047c15.tar.gz",
}


Expand Down
1 change: 0 additions & 1 deletion static_files/scripts/fund.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ for chain_id in "${chain_ids[@]}"; do
'.[$role + "PrivateKey"] = $private_key | .[$role + "Address"] = $address')

done
cat "/network-data/genesis-$chain_id.json" | jq --from-file /fund-script/gen2spec.jq > "/network-data/chainspec-$chain_id.json"
done

echo "Wallet private key and addresses"
Expand Down

0 comments on commit 48f3ebd

Please sign in to comment.