diff --git a/deploy_l2_contracts.star b/deploy_l2_contracts.star index 40180eb1..9c0d1d6c 100644 --- a/deploy_l2_contracts.star +++ b/deploy_l2_contracts.star @@ -1,62 +1,18 @@ service_package = import_module("./lib/service.star") -ARTIFACTS = [ - { - "name": "run-l2-contract-setup.sh", - "file": "./templates/contract-deploy/run-l2-contract-setup.sh", - }, -] - - def run(plan, args): l2_rpc_url = service_package.get_l2_rpc_url(plan, args) - artifact_paths = list(ARTIFACTS) - artifacts = [] - for artifact_cfg in artifact_paths: - template = read_file(src=artifact_cfg["file"]) - artifact = plan.render_templates( - name=artifact_cfg["name"], - config={ - artifact_cfg["name"]: struct( - template=template, - data=args - | { - "l2_rpc_url": l2_rpc_url.http, - "deterministic_deployment_proxy_branch": "master", - }, - ) - }, - ) - artifacts.append(artifact) - - # Create helper service to deploy contracts - contracts_service_name = "contracts-l2" + args["deployment_suffix"] - plan.add_service( - name=contracts_service_name, - config=ServiceConfig( - image=args["l2_contracts_image"], - files={ - "/opt/zkevm": Directory(persistent_key="zkevm-l2-artifacts"), - "/opt/contract-deploy/": Directory(artifact_names=artifacts), - }, - # These two lines are only necessary to deploy to any Kubernetes environment (e.g. GKE). - entrypoint=["bash", "-c"], - cmd=["sleep infinity"], - user=User(uid=0, gid=0), # Run the container as root user. - ), - ) - - # Deploy contracts. plan.exec( description="Deploying contracts on L2", - service_name=contracts_service_name, + service_name="contracts" + args["deployment_suffix"], recipe=ExecRecipe( command=[ "/bin/sh", "-c", - "chmod +x {0} && {0}".format( - "/opt/contract-deploy/run-l2-contract-setup.sh" + "export l2_rpc_url={0} && chmod +x {1} && {1}".format( + l2_rpc_url.http, + "/opt/contract-deploy/run-l2-contract-setup.sh", ), ] ), diff --git a/deploy_zkevm_contracts.star b/deploy_zkevm_contracts.star index 21db2a9c..bcdbe974 100644 --- a/deploy_zkevm_contracts.star +++ b/deploy_zkevm_contracts.star @@ -21,6 +21,10 @@ ARTIFACTS = [ "name": "update-ger.sh", "file": "./templates/contract-deploy/update-ger.sh", }, + { + "name": "run-l2-contract-setup.sh", + "file": "./templates/contract-deploy/run-l2-contract-setup.sh", + }, ] diff --git a/input_parser.star b/input_parser.star index d83e69c4..bf0eac93 100644 --- a/input_parser.star +++ b/input_parser.star @@ -36,7 +36,7 @@ DEFAULT_IMAGES = { "zkevm_bridge_proxy_image": "haproxy:3.0-bookworm", # https://hub.docker.com/_/haproxy/tags "zkevm_bridge_service_image": "hermeznetwork/zkevm-bridge-service:v0.6.0-RC1", # https://hub.docker.com/r/hermeznetwork/zkevm-bridge-service/tags "zkevm_bridge_ui_image": "leovct/zkevm-bridge-ui:multi-network-2", # https://hub.docker.com/r/leovct/zkevm-bridge-ui/tags - "zkevm_contracts_image": "leovct/zkevm-contracts:v8.0.0-rc.4-fork.12", # https://hub.docker.com/repository/docker/leovct/zkevm-contracts/tags + "zkevm_contracts_image": "minhdvu/zkevm-contracts:v8.0.0-rc.4-fork.12", # https://hub.docker.com/repository/docker/leovct/zkevm-contracts/tags "zkevm_da_image": "0xpolygon/cdk-data-availability:0.0.10", # https://hub.docker.com/r/0xpolygon/cdk-data-availability/tags "zkevm_node_image": "hermeznetwork/zkevm-node:v0.7.3", # https://hub.docker.com/r/hermeznetwork/zkevm-node/tags "zkevm_pool_manager_image": "hermeznetwork/zkevm-pool-manager:v0.1.1", # https://hub.docker.com/r/hermeznetwork/zkevm-pool-manager/tags diff --git a/templates/contract-deploy/run-l2-contract-setup.sh b/templates/contract-deploy/run-l2-contract-setup.sh index f8e1d788..121311d3 100644 --- a/templates/contract-deploy/run-l2-contract-setup.sh +++ b/templates/contract-deploy/run-l2-contract-setup.sh @@ -20,7 +20,7 @@ wait_for_rpc_to_be_available() { local retry_interval=5 until cast send --legacy \ - --rpc-url "{{.l2_rpc_url}}" \ + --rpc-url "$l2_rpc_url" \ --private-key "{{.zkevm_l2_admin_private_key}}" \ --value 0 "{{.zkevm_l2_sequencer_address}}" &> /dev/null; do ((counter++)) @@ -38,13 +38,13 @@ fund_account_on_l2() { echo_ts "Funding $address" cast send \ --legacy \ - --rpc-url "{{.l2_rpc_url}}" \ + --rpc-url "$l2_rpc_url" \ --private-key "{{.zkevm_l2_admin_private_key}}" \ --value "{{.l2_funding_amount}}" \ "$address" } -if [[ -e "/opt/zkevm/.init-complete{{.deployment_suffix}}.lock" ]]; then +if [[ -e "/opt/zkevm/.init-l2-complete{{.deployment_suffix}}.lock" ]]; then echo_ts "This script has already been executed" exit 1 fi @@ -87,15 +87,15 @@ fi echo_ts "Deploying deterministic deployment proxy on l2" cast send \ --legacy \ - --rpc-url "{{.l2_rpc_url}}" \ + --rpc-url "$l2_rpc_url" \ --private-key "{{.zkevm_l2_admin_private_key}}" \ --value "$gas_cost" \ "$signer_address" -cast publish --rpc-url "{{.l2_rpc_url}}" "$transaction" -if [[ $(cast code --rpc-url "{{.l2_rpc_url}}" $deployer_address) == "0x" ]]; then +cast publish --rpc-url "$l2_rpc_url" "$transaction" +if [[ $(cast code --rpc-url "$l2_rpc_url" $deployer_address) == "0x" ]]; then echo_ts "No code at expected l2 address: $deployer_address" exit 1; fi # The contract setup is done! -touch "/opt/zkevm/.init-complete{{.deployment_suffix}}.lock" +touch "/opt/zkevm/.init-l2-complete{{.deployment_suffix}}.lock"