forked from 0xPolygon/kurtosis-cdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy_zkevm_contracts.star
87 lines (81 loc) · 2.82 KB
/
deploy_zkevm_contracts.star
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
ARTIFACTS = [
{
"name": "deploy_parameters.json",
"file": "./templates/contract-deploy/deploy_parameters.json",
},
{
"name": "create_rollup_parameters.json",
"file": "./templates/contract-deploy/create_rollup_parameters.json",
},
{
"name": "run-contract-setup.sh",
"file": "./templates/contract-deploy/run-contract-setup.sh",
},
{
"name": "create-keystores.sh",
"file": "./templates/contract-deploy/create-keystores.sh",
},
]
def run(plan, args):
artifacts = []
for artifact_cfg in ARTIFACTS:
template = read_file(src=artifact_cfg["file"])
artifact = plan.render_templates(
name=artifact_cfg["name"],
config={artifact_cfg["name"]: struct(template=template, data=args)},
)
artifacts.append(artifact)
# Create helper service to deploy contracts
contracts_service_name = "contracts" + args["deployment_suffix"]
zkevm_contracts_image = "{}:fork{}".format(
args["zkevm_contracts_image"], args["zkevm_rollup_fork_id"]
)
plan.add_service(
name=contracts_service_name,
config=ServiceConfig(
image=zkevm_contracts_image,
files={
"/opt/zkevm": Directory(persistent_key="zkevm-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.
),
)
# TODO: Check if the contracts were already initialized.. I'm leaving this here for now, but it's not useful!!
contract_init_stat = plan.exec(
description="Checking if contracts are already initialized",
service_name=contracts_service_name,
acceptable_codes=[0, 1],
recipe=ExecRecipe(command=["stat", "/opt/zkevm/.init-complete.lock"]),
)
# Deploy contracts.
plan.exec(
description="Deploying zkevm contracts on L1",
service_name=contracts_service_name,
recipe=ExecRecipe(
command=[
"/bin/sh",
"-c",
"chmod +x {0} && {0}".format(
"/opt/contract-deploy/run-contract-setup.sh"
),
]
),
)
# Create keystores.
plan.exec(
description="Creating keystores for zkevm-node/cdk-validium components",
service_name=contracts_service_name,
recipe=ExecRecipe(
command=[
"/bin/sh",
"-c",
"chmod +x {0} && {0}".format(
"/opt/contract-deploy/create-keystores.sh"
),
]
),
)