-
Notifications
You must be signed in to change notification settings - Fork 76
/
agglayer.star
167 lines (150 loc) · 6.01 KB
/
agglayer.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
databases_package = import_module("./databases.star")
service_package = import_module("./lib/service.star")
ports_package = import_module("./src/package_io/ports.star")
def run(plan, args):
# Create agglayer prover service.
agglayer_prover_config_artifact = create_agglayer_prover_config_artifact(plan, args)
(ports, public_ports) = get_agglayer_prover_ports(args)
prover_env_vars = {}
prover_env_vars["RUST_BACKTRACE"] = "1"
if "agglayer_prover_sp1_key" in args and args["agglayer_prover_sp1_key"] != None:
prover_env_vars["SP1_PRIVATE_KEY"] = args["agglayer_prover_sp1_key"]
agglayer_prover = plan.add_service(
name="agglayer-prover",
config=ServiceConfig(
image=args["agglayer_image"],
ports=ports,
public_ports=public_ports,
files={
"/etc/zkevm": Directory(
artifact_names=[
agglayer_prover_config_artifact,
]
),
},
entrypoint=[
"/usr/local/bin/agglayer",
],
env_vars=prover_env_vars,
cmd=["prover", "--cfg", "/etc/zkevm/agglayer-prover-config.toml"],
),
description="AggLayer Prover",
)
agglayer_prover_url = "http://{}:{}".format(
agglayer_prover.ip_address, agglayer_prover.ports["api"].number
)
# Deploy agglayer service.
agglayer_config_artifact = create_agglayer_config_artifact(
plan, args, agglayer_prover_url
)
agglayer_keystore_artifact = plan.store_service_files(
name="agglayer-keystore",
service_name="contracts" + args["deployment_suffix"],
src="/opt/zkevm/agglayer.keystore",
)
(ports, public_ports) = get_agglayer_ports(args)
plan.add_service(
name="agglayer",
config=ServiceConfig(
image=args["agglayer_image"],
ports=ports,
public_ports=public_ports,
files={
"/etc/zkevm": Directory(
artifact_names=[
agglayer_config_artifact,
agglayer_keystore_artifact,
]
),
},
entrypoint=[
"/usr/local/bin/agglayer",
],
cmd=["run", "--cfg", "/etc/zkevm/agglayer-config.toml"],
),
description="AggLayer",
)
def create_agglayer_prover_config_artifact(plan, args):
agglayer_prover_config_template = read_file(
src="./templates/bridge-infra/agglayer-prover-config.toml"
)
is_cpu_prover_enabled = "true"
is_network_prover_enabled = "false"
if "agglayer_prover_sp1_key" in args and args["agglayer_prover_sp1_key"] != None:
is_cpu_prover_enabled = "false"
is_network_prover_enabled = "true"
return plan.render_templates(
name="agglayer-prover-config-artifact",
config={
"agglayer-prover-config.toml": struct(
template=agglayer_prover_config_template,
# TODO: Organize those args.
data={
"deployment_suffix": args["deployment_suffix"],
"global_log_level": args["global_log_level"],
# ports
"agglayer_prover_port": args["agglayer_prover_port"],
"prometheus_port": args["agglayer_prover_metrics_port"],
"is_cpu_prover_enabled": is_cpu_prover_enabled,
"is_network_prover_enabled": is_network_prover_enabled,
},
)
},
)
def create_agglayer_config_artifact(plan, args, agglayer_prover_url):
agglayer_config_template = read_file(
src="./templates/bridge-infra/agglayer-config.toml"
)
contract_setup_addresses = service_package.get_contract_setup_addresses(plan, args)
db_configs = databases_package.get_db_configs(
args["deployment_suffix"], args["sequencer_type"]
)
return plan.render_templates(
name="agglayer-config-artifact",
config={
"agglayer-config.toml": struct(
template=agglayer_config_template,
# TODO: Organize those args.
data={
"deployment_suffix": args["deployment_suffix"],
"global_log_level": args["global_log_level"],
"l1_chain_id": args["l1_chain_id"],
"l1_rpc_url": args["l1_rpc_url"],
"l1_ws_url": args["l1_ws_url"],
"zkevm_l2_keystore_password": args["zkevm_l2_keystore_password"],
"zkevm_l2_proofsigner_address": args[
"zkevm_l2_proofsigner_address"
],
"zkevm_l2_sequencer_address": args["zkevm_l2_sequencer_address"],
# ports
"zkevm_rpc_http_port": args["zkevm_rpc_http_port"],
"agglayer_port": args["agglayer_port"],
"agglayer_prover_entrypoint": agglayer_prover_url,
"prometheus_port": args["agglayer_metrics_port"],
"l2_rpc_name": args["l2_rpc_name"],
}
| contract_setup_addresses
| db_configs,
)
},
)
def get_agglayer_prover_ports(args):
ports = {
"api": PortSpec(args["agglayer_prover_port"], application_protocol="grpc"),
"prometheus": PortSpec(
args["agglayer_prover_metrics_port"], application_protocol="http"
),
}
public_ports = ports_package.get_public_ports(
ports, "agglayer_prover_start_port", args
)
return (ports, public_ports)
def get_agglayer_ports(args):
ports = {
"agglayer": PortSpec(args["agglayer_port"], application_protocol="http"),
"prometheus": PortSpec(
args["agglayer_metrics_port"], application_protocol="http"
),
}
public_ports = ports_package.get_public_ports(ports, "agglayer_start_port", args)
return (ports, public_ports)