Skip to content

Commit f4ed911

Browse files
committed
feat: implement l2 simulator builds
1 parent b104a74 commit f4ed911

23 files changed

+560
-3
lines changed

l2/_simulator/mkosi.build

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/bin/bash
2+
3+
set -euxo pipefail
4+
5+
ENV_YAML="$SRCDIR/l2/_simulator/mkosi.extra/etc/flashbots/simulator.yaml"
6+
7+
RUST_VERSION=$(mkosi-chroot yq -r '.rust.version' < "$ENV_YAML")
8+
9+
SIMULATOR_REF=$(mkosi-chroot yq -r '.simulator.git_reference' < "$ENV_YAML")
10+
TDX_QUOTE_PROVIDER_REF=$(mkosi-chroot yq -r '.tdx_quote_provider.git_reference' < "$ENV_YAML")
11+
RPROXY_REF=$(mkosi-chroot yq -r '.rproxy.git_reference' < "$ENV_YAML")
12+
RPROXY_FEATURES=$(mkosi-chroot yq -r '.rproxy.features // ["default"] | sort | join(",")' < "$ENV_YAML")
13+
NODE_HEALTHCHECKER_REF=$(mkosi-chroot yq -r '.node_healthchecker.git_reference' < "$ENV_YAML")
14+
15+
export RUSTUP_HOME="/rustup"
16+
export CARGO_HOME="/cargo"
17+
mkosi-chroot rustup toolchain install $RUST_VERSION
18+
mkosi-chroot rustup default $RUST_VERSION
19+
export PATH="$CARGO_HOME/bin:$PATH"
20+
21+
source scripts/make_git_package.sh
22+
source scripts/build_rust_package.sh
23+
24+
# build simulator
25+
26+
build_rust_package \
27+
"simulator" \
28+
"${SIMULATOR_REF}" \
29+
"https://github.com/flashbots/simulator.git" \
30+
"" "" "-g"
31+
32+
# build rproxy
33+
34+
make_git_package \
35+
"rproxy" \
36+
"${RPROXY_REF}" \
37+
"https://github.com/flashbots/rproxy.git" \
38+
"FEATURES=${RPROXY_FEATURES} TARGET=x86_64-unknown-linux-gnu ./build.sh" \
39+
"target/x86_64-unknown-linux-gnu/release/rproxy:/usr/bin/rproxy"
40+
chmod +x $DESTDIR/usr/bin/rproxy
41+
42+
# build node-healthchecker
43+
44+
make_git_package \
45+
"node-healthchecker" \
46+
"${NODE_HEALTHCHECKER_REF}" \
47+
"https://github.com/flashbots/node-healthchecker.git" \
48+
'go build -trimpath -ldflags "-s -w -X main.version=${NODE_HEALTHCHECKER_REF} -buildid=" -o ./bin/node-healthchecker github.com/flashbots/node-healthchecker/cmd' \
49+
"bin/node-healthchecker:/usr/bin/node-healthchecker"
50+
chmod +x $DESTDIR/usr/bin/node-healthchecker

l2/_simulator/mkosi.conf

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
[Build]
2+
WithNetwork=true
3+
4+
[Content]
5+
BuildScripts=l2/_simulator/mkosi.build
6+
ExtraTrees=l2/_simulator/mkosi.extra
7+
PostInstallationScripts=l2/_simulator/mkosi.postinst
8+
9+
Packages=sudo
10+
unzip
11+
12+
BuildPackages=golang
13+
libssl-dev
14+
rustup
15+
unzip
16+
yq
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Set the command-line arguments to pass to the server.
2+
ARGS="\
3+
--collector.systemd \
4+
--collector.systemd.unit-include=\".*(node-healthchecker|prometheus-node-exporter|prometheus-process-exporter|rproxy|simulator|vault-agent).*\" \
5+
--log.format=json \
6+
--web.listen-address=0.0.0.0:9100 \
7+
"
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
rust:
2+
version: 1.91.1
3+
node_healthchecker:
4+
git_reference: v0.1.11
5+
simulator:
6+
git_reference: v0.0.1-dev.1
7+
rproxy:
8+
git_reference: v0.0.10-dev.7
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
process_names:
2+
- name: node-healthchecker
3+
cmdline:
4+
- '^\/([-.0-9a-zA-Z]+\/)*node-healthchecker[-.0-9a-zA-Z]* '
5+
- name: rproxy
6+
cmdline:
7+
- '^\/([-.0-9a-zA-Z]+\/)*rproxy[-.0-9a-zA-Z]* '
8+
- name: simulator
9+
cmdline:
10+
- '^\/([-.0-9a-zA-Z]+\/)*simulator[-.0-9a-zA-Z]* '
11+
- name: vault-agent
12+
cmdline:
13+
- '^\/([-.0-9a-zA-Z]+\/)*vault[-.0-9a-zA-Z]* '
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
AUTOMOUNT_PATH_DATA=/var/opt/optimism
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
[Unit]
2+
Description=Blockchain node healthchecker
3+
After=network.target
4+
Wants=network.target
5+
6+
[Service]
7+
Type=simple
8+
SyslogIdentifier=node-healthchecker
9+
User=simulator
10+
Group=optimism
11+
12+
Restart=always
13+
RestartSec=5
14+
TimeoutStopSec=60
15+
16+
ExecStart=/usr/bin/node-healthchecker serve \
17+
--healthcheck-block-age-threshold 10s \
18+
--healthcheck-timeout 500ms \
19+
--healthcheck-reth-base-url http://127.0.0.1:18645 \
20+
--healthcheck-unconditional-fail-duration 1m \
21+
--http-status-warning 200 \
22+
--server-listen-address 0.0.0.0:8080
23+
24+
[Install]
25+
WantedBy=default.target
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
template {
2+
left_delimiter = "(("
3+
right_delimiter = "))"
4+
5+
destination = "/var/opt/optimism/simulator/discovery-secret"
6+
7+
user = "simulator"
8+
group = "optimism"
9+
perms = "0600"
10+
11+
exec {
12+
timeout = "60s"
13+
14+
command = ["/bin/sh", "-c",
15+
<<-EOT
16+
# discovery-secret
17+
chown simulator:optimism /var/opt/optimism/simulator
18+
chmod 0750 /var/opt/optimism/simulator
19+
systemctl restart simulator
20+
EOT
21+
]
22+
}
23+
24+
contents = <<-EOT
25+
((- $node := ( secret "[[ gcp.Meta "attributes/vault_kv_path" ]]/node/[[ gcp.Meta "name" ]]" ).Data.data -))
26+
27+
((- $node.el_nodekey -))
28+
EOT
29+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
template {
2+
left_delimiter = "(("
3+
right_delimiter = "))"
4+
5+
destination = "/var/opt/optimism/simulator/genesis.json.tar.gz.base64"
6+
7+
user = "simulator"
8+
group = "optimism"
9+
perms = "0640"
10+
11+
exec {
12+
timeout = "60s"
13+
14+
command = ["/bin/sh", "-c",
15+
<<-EOT
16+
# genesis.json
17+
chown simulator:optimism /var/opt/optimism/simulator
18+
chmod 0750 /var/opt/optimism/simulator
19+
systemctl restart simulator
20+
EOT
21+
]
22+
}
23+
24+
contents = <<-EOT
25+
((- $service := ( secret "[[ gcp.Meta "attributes/vault_kv_path" ]]/node/_common[[ if ( gcp.Meta "attributes/service" ) ]]_[[ gcp.Meta "attributes/service" | strings.ReplaceAll "-" "_" ]][[ end ]]" ).Data.data -))
26+
27+
((- if $service.genesis_json -))
28+
((- $service.genesis_json -))
29+
((- end -))
30+
EOT
31+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
template {
2+
left_delimiter = "(("
3+
right_delimiter = "))"
4+
5+
destination = "/var/opt/optimism/jwtsecret"
6+
7+
user = "root"
8+
group = "optimism"
9+
perms = "0440"
10+
11+
contents = <<-EOT
12+
((- with secret "[[ gcp.Meta "attributes/vault_kv_path" ]]/node/[[ gcp.Meta "name" ]]" -))
13+
(( .Data.data.jwt_secret ))
14+
((- end -))
15+
EOT
16+
}

0 commit comments

Comments
 (0)