-
Notifications
You must be signed in to change notification settings - Fork 74
/
cdk_central_environment.star
193 lines (176 loc) · 6.92 KB
/
cdk_central_environment.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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
data_availability_package = import_module("./lib/data_availability.star")
service_package = import_module("./lib/service.star")
zkevm_dac_package = import_module("./lib/zkevm_dac.star")
zkevm_node_package = import_module("./lib/zkevm_node.star")
zkevm_prover_package = import_module("./lib/zkevm_prover.star")
zkevm_sequence_sender_package = import_module("./lib/zkevm_sequence_sender.star")
cdk_node_package = import_module("./lib/cdk_node.star")
databases = import_module("./databases.star")
def run(plan, args):
db_configs = databases.get_db_configs(
args["deployment_suffix"], args["sequencer_type"]
)
# Start prover.
prover_config_template = read_file(
src="./templates/trusted-node/prover-config.json"
)
prover_config_artifact = plan.render_templates(
name="prover-config-artifact",
config={
"prover-config.json": struct(
template=prover_config_template,
data=args | db_configs,
)
},
)
if (
not args["zkevm_use_real_verifier"]
and not args["enable_normalcy"]
and not args["consensus_contract_type"] == "pessimistic"
):
zkevm_prover_package.start_prover(
plan, args, prover_config_artifact, "zkevm_prover_start_port"
)
# Get the genesis file artifact.
# TODO: Retrieve the genesis file artifact once it is available in Kurtosis.
genesis_artifact = ""
if "genesis_artifact" in args:
genesis_artifact = args["genesis_artifact"]
else:
genesis_file = read_file(src=args["genesis_file"])
genesis_artifact = plan.render_templates(
name="genesis",
config={"genesis.json": struct(template=genesis_file, data={})},
)
keystore_artifacts = get_keystores_artifacts(plan, args)
if args["sequencer_type"] == "zkevm":
# Create the zkevm node config.
node_config_template = read_file(
src="./templates/trusted-node/node-config.toml"
)
node_config_artifact = plan.render_templates(
config={
"node-config.toml": struct(
template=node_config_template,
data=args
| {
"is_cdk_validium": data_availability_package.is_cdk_validium(
args
),
}
| db_configs,
)
},
name="trusted-node-config",
)
# Start the synchronizer.
zkevm_node_package.start_synchronizer(
plan, args, node_config_artifact, genesis_artifact
)
# Start the rest of the zkevm node components.
zkevm_node_components_configs = (
zkevm_node_package.create_zkevm_node_components_config(
args, node_config_artifact, genesis_artifact, keystore_artifacts
)
)
plan.add_services(
configs=zkevm_node_components_configs,
description="Starting the rest of the zkevm node components",
)
if args["sequencer_type"] == "erigon":
# Create the cdk node config.
node_config_template = read_file(
src="./templates/trusted-node/cdk-node-config.toml"
)
contract_setup_addresses = service_package.get_contract_setup_addresses(
plan, args
)
node_config_artifact = plan.render_templates(
name="cdk-node-config-artifact",
config={
"cdk-node-config.toml": struct(
template=node_config_template,
data=args
| {
"is_cdk_validium": data_availability_package.is_cdk_validium(
args
),
}
| db_configs
| contract_setup_addresses,
)
},
)
# Start the cdk components.
cdk_node_configs = cdk_node_package.create_cdk_node_service_config(
args, node_config_artifact, genesis_artifact, keystore_artifacts
)
plan.add_services(
configs=cdk_node_configs,
description="Starting the cdk node components",
)
# Start the DAC if in validium mode.
if data_availability_package.is_cdk_validium(args):
dac_config_artifact = create_dac_config_artifact(plan, args, db_configs)
dac_config = zkevm_dac_package.create_dac_service_config(
args, dac_config_artifact, keystore_artifacts.dac
)
plan.add_services(
configs=dac_config,
description="Starting the DAC",
)
def get_keystores_artifacts(plan, args):
sequencer_keystore_artifact = plan.store_service_files(
name="sequencer-keystore",
service_name="contracts" + args["deployment_suffix"],
src="/opt/zkevm/sequencer.keystore",
)
aggregator_keystore_artifact = plan.store_service_files(
name="aggregator-keystore",
service_name="contracts" + args["deployment_suffix"],
src="/opt/zkevm/aggregator.keystore",
)
proofsigner_keystore_artifact = plan.store_service_files(
name="proofsigner-keystore",
service_name="contracts" + args["deployment_suffix"],
src="/opt/zkevm/proofsigner.keystore",
)
dac_keystore_artifact = plan.store_service_files(
name="dac-keystore",
service_name="contracts" + args["deployment_suffix"],
src="/opt/zkevm/dac.keystore",
)
claimsponsor_keystore_artifact = plan.store_service_files(
name="claimsponsor-keystore",
service_name="contracts" + args["deployment_suffix"],
src="/opt/zkevm/claimsponsor.keystore",
)
return struct(
sequencer=sequencer_keystore_artifact,
aggregator=aggregator_keystore_artifact,
proofsigner=proofsigner_keystore_artifact,
dac=dac_keystore_artifact,
claimsponsor=claimsponsor_keystore_artifact,
)
def create_dac_config_artifact(plan, args, db_configs):
dac_config_template = read_file(src="./templates/trusted-node/dac-config.toml")
contract_setup_addresses = service_package.get_contract_setup_addresses(plan, args)
return plan.render_templates(
name="dac-config-artifact",
config={
"dac-config.toml": struct(
template=dac_config_template,
data={
"deployment_suffix": args["deployment_suffix"],
"global_log_level": args["global_log_level"],
"l1_rpc_url": args["l1_rpc_url"],
"l1_ws_url": args["l1_ws_url"],
"zkevm_l2_keystore_password": args["zkevm_l2_keystore_password"],
# ports
"zkevm_dac_port": args["zkevm_dac_port"],
}
| contract_setup_addresses
| db_configs,
)
},
)