-
Notifications
You must be signed in to change notification settings - Fork 74
/
deploy_zkevm_contracts.star
150 lines (140 loc) · 4.67 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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
data_availability_package = import_module("./lib/data_availability.star")
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",
},
{
"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",
},
]
def run(plan, args):
artifact_paths = list(ARTIFACTS)
# If we are configured to use a previous deployment, we'll
# dynamically add artifacts for the genesis and combined outputs.
if (
"use_previously_deployed_contracts" in args
and args["use_previously_deployed_contracts"]
):
artifact_paths.append(
{
"name": "genesis.json",
"file": "./templates/contract-deploy/genesis.json",
}
)
artifact_paths.append(
{
"name": "combined.json",
"file": "./templates/contract-deploy/combined.json",
}
)
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
| {
"is_cdk_validium": data_availability_package.is_cdk_validium(
args
),
"zkevm_rollup_consensus": data_availability_package.get_consensus_contract(
args
),
},
)
},
)
artifacts.append(artifact)
# Create helper service to deploy contracts
contracts_service_name = "contracts" + args["deployment_suffix"]
plan.add_service(
name=contracts_service_name,
config=ServiceConfig(
image=args["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.
),
)
# 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"
),
]
),
)
# Store CDK configs.
plan.store_service_files(
name="cdk-erigon-chain-config",
service_name="contracts" + args["deployment_suffix"],
src="/opt/zkevm/dynamic-kurtosis-conf.json",
)
plan.store_service_files(
name="cdk-erigon-chain-allocs",
service_name="contracts" + args["deployment_suffix"],
src="/opt/zkevm/dynamic-kurtosis-allocs.json",
)
plan.store_service_files(
name="cdk-erigon-chain-first-batch",
service_name="contracts" + args["deployment_suffix"],
src="/opt/zkevm/first-batch-config.json",
)
# Force update GER.
plan.exec(
description="Update the GER so the L1 Info Tree Index is greater than 0",
service_name=contracts_service_name,
recipe=ExecRecipe(
command=[
"/bin/sh",
"-c",
"chmod +x {0} && {0}".format("/opt/contract-deploy/update-ger.sh"),
]
),
)