forked from 0xPolygon/kurtosis-cdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy_zkevm_contracts.star
121 lines (114 loc) · 4.02 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
def run(plan, args):
# Create deploy parameters
deploy_parameters_template = read_file(
src="./templates/contract-deploy/deploy_parameters.json"
)
deploy_parameters_artifact = plan.render_templates(
name="deploy-parameters-artifact",
config={
"deploy_parameters.json": struct(
template=deploy_parameters_template,
data=args,
)
},
)
# Create rollup paramaters
create_rollup_parameters_template = read_file(
src="./templates/contract-deploy/create_rollup_parameters.json"
)
create_rollup_parameters_artifact = plan.render_templates(
name="create-rollup-parameters-artifact",
config={
"create_rollup_parameters.json": struct(
template=create_rollup_parameters_template,
data=args,
)
},
)
# Create contract deployment script
contract_deployment_script_template = read_file(
src="./templates/contract-deploy/run-contract-setup.sh"
)
contract_deployment_script_artifact = plan.render_templates(
name="contract-deployment-script-artifact",
config={
"run-contract-setup.sh": struct(
template=contract_deployment_script_template,
data=args,
),
},
)
# Create keystores script
create_keystores_script_template = read_file(
src="./templates/contract-deploy/create-keystores.sh"
)
create_keystores_script_artifact = plan.render_templates(
name="create-keystores-script-artifact",
config={
"create-keystores.sh": struct(
template=create_keystores_script_template,
data=args,
),
},
)
# 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=[
deploy_parameters_artifact,
create_rollup_parameters_artifact,
contract_deployment_script_artifact,
create_keystores_script_artifact,
]
),
},
# 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"
),
]
),
)