Skip to content

Commit 1127cde

Browse files
committed
wip
1 parent 77f5ff3 commit 1127cde

33 files changed

+773
-57
lines changed

Makefile

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@ preflight:
4242

4343
# Build module
4444
build: check-perms setup ## Build the specified module
45-
$(WRAPPER) mkosi --force -I $(IMAGE).conf
45+
time $(WRAPPER) mkosi --force -I $(IMAGE).conf
4646

4747
# Build module with devtools profile
4848
build-dev: check-perms setup ## Build module with development tools
49-
$(WRAPPER) mkosi --force --profile=devtools -I $(IMAGE).conf
49+
time $(WRAPPER) mkosi --force --profile=devtools -I $(IMAGE).conf
5050

5151
##@ Utilities
5252

@@ -60,31 +60,28 @@ check-repro: ## Build same module twice and compare resulting images
6060
@sleep 15
6161

6262
@echo "Building image #1..."
63-
$(WRAPPER) mkosi --force -I $(IMAGE).conf
64-
@cp -r build build.1
63+
time $(WRAPPER) mkosi --force -I $(IMAGE).conf
64+
@mkdir -p build/cache
65+
@mv mkosi.builddir/* build/cache/
66+
@mv build build.1
6567

6668
@rm -rf build/* mkosi.builddir/* mkosi.cache/* mkosi.packages/*
6769
# hack: there's some race condition under lima that causes apt to fail while trying to
6870
# create a temp dir under apt cache
6971
@sleep 15
7072

7173
@echo "Building image #2..."
72-
$(WRAPPER) mkosi --force -I $(IMAGE).conf
73-
@cp -r build build.2
74+
time $(WRAPPER) mkosi --force -I $(IMAGE).conf
75+
@mkdir -p build/cache
76+
@mv mkosi.builddir/* build/cache/
77+
@mv build build.2
7478

7579
@echo "Comparing..."
76-
77-
@echo ""
78-
@sha256sum build.1/tdx-debian.vmlinuz
79-
@sha256sum build.2/tdx-debian.vmlinuz
80-
81-
@echo ""
82-
@sha256sum build.1/tdx-debian.initrd
83-
@sha256sum build.2/tdx-debian.initrd
84-
85-
@echo ""
86-
@sha256sum build.1/tdx-debian.efi
87-
@sha256sum build.2/tdx-debian.efi
80+
@for file in $$( find build.1 -type f ); do \
81+
sha256sum $$file; \
82+
sha256sum $${file/build1/build.2}; \
83+
echo ""; \
84+
done
8885

8986
measure: ## Export TDX measurements for the built EFI file
9087
@if [ ! -f build/tdx-debian.efi ]; then \

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,10 @@ For more information about this repository, see
2626

2727
### Prerequisites
2828

29-
In order to build images, you'll need to install [Lima](https://lima-vm.io/) for your operating system. Building images without Lima is possible, but due to inconsistencies between distributions, it is not supported for generating official reproducible images.
29+
In order to build images, you'll need to install [Lima](https://lima-vm.io/) for
30+
your operating system. Building images without Lima is possible, but due to
31+
inconsistencies between distributions, it is not supported for generating
32+
official reproducible images.
3033

3134
### Building Images
3235

@@ -94,7 +97,7 @@ This generates measurement files in the `build/` directory for attestation and v
9497
```
9598

9699
> [!NOTE]
97-
>
100+
>
98101
> Depending on your Linux distro, these commands may require changing the
99102
> supplied OVMF paths or installing your distro's OVMF package.
100103

l2-builder.conf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[Include]
2+
Include=base/mkosi.conf
3+
Include=l2/l2-builder.conf
4+
5+
[Config]
6+
Profiles=gcp

l2/_op_rbuilder/mkosi.build

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
#!/bin/bash
2+
3+
set -euxo pipefail
4+
5+
ENV_YAML="$SRCDIR/l2/_op_rbuilder/mkosi.extra/etc/flashbots/op-rbuilder.yaml"
6+
7+
RUST_VERSION=$(mkosi-chroot yq -r .rust.version < "$ENV_YAML")
8+
9+
OP_RBUILDER_REF=$(mkosi-chroot yq -r .op_rbuilder.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+
NODE_HEALTHCHECKER_REF=$(mkosi-chroot yq -r .node_healthchecker.git_reference < "$ENV_YAML")
13+
14+
export RUSTUP_HOME="/rustup"
15+
export CARGO_HOME="/cargo"
16+
mkosi-chroot rustup toolchain install $RUST_VERSION
17+
mkosi-chroot rustup default $RUST_VERSION
18+
export PATH="$CARGO_HOME/bin:$PATH"
19+
20+
source scripts/make_git_package.sh
21+
source scripts/build_rust_package.sh
22+
23+
# build op-rbuilder
24+
25+
if [ -f "l2/_op_rbuilder/mkosi.extra/usr/bin/op-rbuilder" ]; then
26+
echo "Using pre-built op-rbuilder binary"
27+
else
28+
build_rust_package \
29+
"op-rbuilder" \
30+
"${OP_RBUILDER_REF}" \
31+
"https://github.com/flashbots/op-rbuilder.git" \
32+
"" "" "-g"
33+
fi
34+
35+
# build tdx-quote-provider
36+
37+
if [ -f "l2/_op_rbuilder/mkosi.extra/usr/bin/tdx-quote-provider" ]; then
38+
echo "Using pre-built tdx-quote-provider binary"
39+
else
40+
build_rust_package \
41+
"tdx-quote-provider" \
42+
"${TDX_QUOTE_PROVIDER_REF}" \
43+
"https://github.com/flashbots/op-rbuilder.git" \
44+
"" "" "-g"
45+
fi
46+
47+
# build rproxy
48+
49+
if [ -f "l2/_op_rbuilder/mkosi.extra/usr/bin/rproxy" ]; then
50+
echo "Using pre-built rproxy binary"
51+
else
52+
make_git_package \
53+
"rproxy" \
54+
"${RPROXY_REF}" \
55+
"https://github.com/flashbots/rproxy.git" \
56+
'TARGET=x86_64-unknown-linux-gnu ./build.sh' \
57+
"target/x86_64-unknown-linux-gnu/release/rproxy:/usr/bin/rproxy"
58+
chmod +x $DESTDIR/usr/bin/rproxy
59+
fi
60+
61+
# build node-healthchecker
62+
63+
if [ -f "l2/mkosi.extra/usr/bin/node-healthchecker" ]; then
64+
echo "Using pre-built node-healthchecker binary"
65+
else
66+
make_git_package \
67+
"node-healthchecker" \
68+
"${NODE_HEALTHCHECKER_REF}" \
69+
"https://github.com/flashbots/node-healthchecker.git" \
70+
'go build -trimpath -ldflags "-s -w -X main.version=${NODE_HEALTHCHECKER_REF} -buildid=" -o ./bin/node-healthchecker github.com/flashbots/node-healthchecker/cmd' \
71+
"bin/node-healthchecker:/usr/bin/node-healthchecker"
72+
chmod +x $DESTDIR/usr/bin/node-healthchecker
73+
fi

l2/_op_rbuilder/mkosi.conf

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[Build]
2+
WithNetwork=true
3+
4+
[Content]
5+
BuildScripts=l2/_op_rbuilder/mkosi.build
6+
ExtraTrees=l2/_op_rbuilder/mkosi.extra
7+
PostInstallationScripts=l2/_op_rbuilder/mkosi.postinst
8+
9+
Packages=libtss2-dev
10+
sudo
11+
unzip
12+
13+
BuildPackages=golang
14+
libssl-dev
15+
rustup
16+
unzip
17+
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|op-rbuilder|prometheus-node-exporter|prometheus-process-exporter|rproxy|vault-agent).*\" \
5+
--log.format=json \
6+
--web.listen-address=0.0.0.0:9100 \
7+
"
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
rust:
2+
version: 1.91.1
3+
4+
node_healthchecker:
5+
git_reference: v0.1.11
6+
7+
op_rbuilder:
8+
git_reference: op-rbuilder/v0.2.9
9+
10+
rproxy:
11+
git_reference: v0.0.6
12+
13+
tdx_quote_provider:
14+
git_reference: tdx-quote-provider/v0.1.0
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: op-rbuilder
6+
cmdline:
7+
- '^\/([-.0-9a-zA-Z]+\/)*op-rbuilder[-.0-9a-zA-Z]* '
8+
- name: rproxy
9+
cmdline:
10+
- '^\/([-.0-9a-zA-Z]+\/)*rproxy[-.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=op-rbuilder
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

0 commit comments

Comments
 (0)