Skip to content

Commit 3eccff8

Browse files
committed
Merge branch 'main' of github.com:flashbots/flashbots-images into ilya/podman-init
2 parents b8620a2 + 36ea2a5 commit 3eccff8

40 files changed

+494
-424
lines changed

DEVELOPMENT.md

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,11 @@ This comprehensive guide covers everything you need to know about developing wit
2222
```
2323
flashboxes/
2424
├── base/ # Core minimal Linux system
25-
│ ├── base.conf # Base mkosi configuration
25+
│ ├── mkosi.conf # Base mkosi configuration
2626
│ ├── mkosi.skeleton/ # Base filesystem overlay
2727
│ └── debloat*.sh # System cleanup scripts
28-
├── bob/ # BoB Searcher sandbox
28+
├── bob-common/ # TEE Searcher common image
29+
├── bob-l1/ # L1 TEE Searcher sandbox image
2930
├── buildernet/ # BuilderNet
3031
├── tdx-dummy/ # TDX test environment
3132
├── kernel/ # Kernel configuration
@@ -58,7 +59,7 @@ chmod +x mkosi.build mkosi.postinst
5859

5960
### Step 2: Create Module Configuration
6061

61-
**`mymodule/mymodule.conf`**:
62+
**`mymodule/mkosi.conf`**:
6263
```ini
6364
[Build]
6465
# Environment variables available in scripts
@@ -89,8 +90,8 @@ BuildPackages=build-essential
8990
**`mymodule.conf`** (in project root):
9091
```ini
9192
[Include]
92-
Include=base/base.conf
93-
Include=mymodule/mymodule.conf
93+
Include=base/mkosi.conf
94+
Include=mymodule/mkosi.conf
9495
```
9596

9697
### Step 4: Build Your Module
@@ -469,7 +470,7 @@ Reproducible builds are essential for security and trust. Here's how to verify y
469470
mkosi --force -I mymodule.conf
470471
cp build/mymodule-image.efi build/first-build.efi
471472

472-
mkosi --force -I mymodule.conf
473+
mkosi --force -I mymodule.conf
473474
cp build/mymodule-image.efi build/second-build.efi
474475

475476
# Compare hashes
@@ -536,7 +537,7 @@ set -e
536537
# Create system user
537538
useradd -r -s /bin/false myapp || true
538539

539-
# Set permissions
540+
# Set permissions
540541
chown myapp:myapp /etc/myapp/config.conf
541542
chmod 600 /etc/myapp/config.conf
542543

@@ -547,7 +548,7 @@ systemctl start myapp.service || true
547548
exit 0
548549
```
549550

550-
### Pre-removal Script
551+
### Pre-removal Script
551552

552553
**`DEBIAN/prerm`**:
553554
```bash
@@ -598,15 +599,15 @@ sudo dpkg -i mypackage-1.0.deb
598599
### Package Scripts Execution Order
599600

600601
1. **Installation**: `preinst` → files copied → `postinst`
601-
2. **Upgrade**: `preinst upgrade` → files copied → `postinst configure`
602+
2. **Upgrade**: `preinst upgrade` → files copied → `postinst configure`
602603
3. **Removal**: `prerm remove` → files removed → `postrm remove`
603604
4. **Purge**: `prerm remove` → files removed → `postrm purge`
604605

605606
For comprehensive .deb creation, see: [Debian New Maintainers' Guide](https://www.debian.org/doc/manuals/maint-guide/)
606607

607608
## Building with Podman (Not Recommended)
608609
For systems without systemd v250+ or where Nix installation isn't feasible, you can use the experimental Podman containerization support. This approach is not recommended due to slower build times and a complex setup process.
609-
1. Configure the Podman daemon to use a storage driver other than OverlayFS
610+
1. Configure the Podman daemon to use a storage driver other than OverlayFS
610611
- The btrfs driver is fastest, but requires that you have a btrfs filesystem
611612
- The storage driver can be configuring by editing `/etc/containers/storage.conf`
612613
2. Build the development container:
@@ -615,7 +616,7 @@ For systems without systemd v250+ or where Nix installation isn't feasible, you
615616
```
616617
3. Create required directories
617618
```
618-
mkdir mkosi.packages mkosi.cache mkosi.builddir build
619+
mkdir mkosi.packages mkosi.cache mkosi.builddir build
619620
```
620621
4. Run the container with proper mounts and privilages
621622
```

README.md

Lines changed: 97 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,18 @@
22

33
**Reproducible hardened Linux images for confidential computing and safe MEV**
44

5-
This repository provides a toolkit for building minimal, hardened Linux images designed for confidential computing environments and MEV (Maximum Extractable Value) applications. Built on mkosi and Nix, it provides reproducible, security-focused Linux distributions with strong network isolation, attestation capabilities, and blockchain infrastructure support.
5+
This repository provides a toolkit for building minimal, hardened Linux images
6+
designed for confidential computing environments and MEV (Maximum Extractable
7+
Value) applications. Built on mkosi and Nix, it provides reproducible,
8+
security-focused Linux distributions with strong network isolation, attestation
9+
capabilities, and blockchain infrastructure support.
610

7-
It contains our [bottom-of-block searcher sandbox](https://collective.flashbots.net/t/searching-in-tdx/3902) infrastructure and will soon contain our [BuilderNet](https://buildernet.org/blog/introducing-buildernet) infrastructure as well, along with any future TDX projects we implement.
11+
It contains our [bottom-of-block searcher sandbox](https://collective.flashbots.net/t/searching-in-tdx/3902)
12+
infrastructure and will soon contain our [BuilderNet](https://buildernet.org/blog/introducing-buildernet)
13+
infrastructure as well, along with any future TDX projects we implement.
814

9-
For more information about this repository, see [the Flashbots collective post](https://collective.flashbots.net/t/beyond-yocto-exploring-mkosi-for-tdx-images/4739).
15+
For more information about this repository, see
16+
[the Flashbots collective post](https://collective.flashbots.net/t/beyond-yocto-exploring-mkosi-for-tdx-images/4739).
1017

1118
## 🌟 Features
1219

@@ -19,57 +26,27 @@ For more information about this repository, see [the Flashbots collective post](
1926

2027
### Prerequisites
2128

22-
0. Make sure you're running systemd v250 or greater. Alternatively, you can utilize experimental [container support](DEVELOPMENT.md#building-with-podman-not-recommended).
23-
24-
1. **Install Nix** (single user mode is sufficient):
25-
```bash
26-
sh <(curl -L https://nixos.org/nix/install) --no-daemon
27-
```
28-
29-
2. **Enable Nix experimental features** in `~/.config/nix/nix.conf`:
30-
```
31-
experimental-features = nix-command flakes
32-
```
33-
34-
3. **Install Debian archive keyring** (temporary requirement):
35-
```bash
36-
# On Ubuntu/Debian
37-
sudo apt install debian-archive-keyring
38-
# On other systems, download via package manager or use Docker approach below
39-
```
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.
4030

4131
### Building Images
4232

43-
**Using Make (Recommended)**:
4433
```bash
4534
# Build the BOB (searcher sandbox) image
4635
make build IMAGE=bob
4736

48-
# Build the Buildernet image
37+
# Build the Buildernet image
4938
make build IMAGE=buildernet
5039

40+
# Build the l2 builder image
41+
make build IMAGE=l2-builder
42+
5143
# Build with development tools
5244
make build-dev IMAGE=bob
5345

5446
# View all available targets
5547
make help
5648
```
5749

58-
**Manual Build**:
59-
```bash
60-
# Enter the development environment
61-
nix develop -c $SHELL
62-
63-
# Build a specific image
64-
mkosi --force -I bob.conf
65-
mkosi --force -I buildernet.conf
66-
67-
# Build with profiles
68-
mkosi --force -I bob.conf --profile=devtools
69-
mkosi --force -I bob.conf --profile=azure
70-
mkosi --force -I bob.conf --profile=azure,devtools
71-
```
72-
7350
### Measuring TDX Boot Process
7451

7552
**Export TDX measurements** for the built image:
@@ -116,9 +93,89 @@ This generates measurement files in the `build/` directory for attestation and v
11693
# ... rest of options same as above
11794
```
11895

119-
> Depending on your Linux distro, these commands may require changing the supplied OVMF paths or installing your distro's OVMF package.
96+
> [!NOTE]
97+
>
98+
> Depending on your Linux distro, these commands may require changing the
99+
> supplied OVMF paths or installing your distro's OVMF package.
100+
101+
> [!NOTE]
102+
>
103+
> Running `systemctl status` generates a report with an `unmerged-bin` taint. That's
104+
> expected.
105+
>
106+
> See [bug report #1085370](https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1085370)
107+
> for details.
108+
109+
## Building Without Lima (Unsupported)
110+
111+
### Prerequisites
112+
113+
1. **Install Nix** (single user mode is sufficient):
114+
115+
```bash
116+
sh <(curl -L https://nixos.org/nix/install) --no-daemon
117+
```
118+
119+
2. **Enable Nix experimental features** in `~/.config/nix/nix.conf`:
120+
121+
```conf
122+
experimental-features = nix-command flakes
123+
```
124+
125+
3. **Install Debian archive keyring** (temporary requirement):
126+
127+
```bash
128+
# On Ubuntu/Debian
129+
sudo apt install debian-archive-keyring
130+
# On other systems, download via package manager or use Docker approach below
131+
```
132+
133+
### Building
134+
135+
```bash
136+
# Enter the development environment
137+
nix develop -c $SHELL
138+
139+
# Build a specific image
140+
mkosi --force -I bob.conf
141+
mkosi --force -I buildernet.conf
142+
143+
# Build with profiles
144+
mkosi --force -I bob.conf --profile=devtools
145+
mkosi --force -I bob.conf --profile=azure
146+
mkosi --force -I bob.conf --profile=azure,devtools
147+
```
148+
149+
### Troubleshooting
150+
151+
- If you encounter `mkosi was forbidden to unshare namespaces`, try
152+
adding an apparmor profile like so:
153+
154+
```bash
155+
sudo cat <<EOF > /etc/apparmor.d/mkosi
156+
abi <abi/4.0>,
157+
include <tunables/global>
158+
159+
/nix/store/*-mkosi-*/bin/mkosi flags=(default_allow) {
160+
userns,
161+
}
162+
EOF
163+
164+
sudo systemctl reload apparmor
165+
```
166+
167+
- If you encounter `unshare: setgroups failed: Operation not permitted`,
168+
try to disable apparmor's restriction:
169+
170+
```bash
171+
sudo sysctl kernel.apparmor_restrict_unprivileged_userns=0
172+
173+
sudo -c 'echo "kernel.apparmor_restrict_unprivileged_userns=0" >> /etc/sysctl.conf'
174+
```
175+
176+
- If you encounter `bootctl: unrecognized option '--root=/buildroot'`, you'll need to upgrade to a newer version of systemd (at least v250), which is only supported by recent versions of Ubuntu.
120177
121178
## 📖 Documentation
122179
123180
- [Development Guide](DEVELOPMENT.md) - Comprehensive guide for creating new modules and extending existing ones
124-
- [BOB Module Guide](bob/readme.md) - Detailed documentation for the MEV searcher environment
181+
- [BOB Module Guide](bob-common/readme.md) - Detailed documentation for the MEV searcher environment
File renamed without changes.

bob/mkosi.build renamed to bob-common/mkosi.build

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
#!/bin/bash
22
set -euxo pipefail
33

4-
source scripts/build_rust_package.sh
54
source scripts/make_git_package.sh
65

76
# Compile searchersh
87
mkdir -p "$DESTDIR/usr/bin"
9-
mkosi-chroot gcc -o "$DESTDIR/usr/bin/searchersh" "$SRCDIR/bob/searchersh.c"
8+
mkosi-chroot gcc -o "$DESTDIR/usr/bin/searchersh" "$SRCDIR/bob-common/searchersh.c"
109
chmod 755 "$DESTDIR/usr/bin/searchersh"
1110

1211
# Compile cryptsetup
@@ -18,32 +17,6 @@ make_git_package \
1817
".libs/cryptsetup:/usr/sbin/cryptsetup" \
1918
".libs/libcryptsetup.so.12.11.0:/usr/lib/libcryptsetup.so.12"
2019

21-
# Compile lighthouse
22-
LIGHTHOUSE_BUILD_CMD="
23-
# Switch from jemalloc to the system allocator to fix reproducibility issues
24-
sed -i 's/malloc_utils = { workspace = true, features = \[\"jemalloc\"\] }/malloc_utils = { workspace = true }/' lighthouse/Cargo.toml
25-
sed -i 's/#\[cfg(target_os = \"windows\")\]/#[cfg(not(feature = \"jemalloc\"))]/' lighthouse/src/main.rs
26-
sed -i 's/#\[cfg(not(target_os = \"windows\"))\]/#[cfg(feature = \"jemalloc\")]/' lighthouse/src/main.rs
27-
28-
# Reproducibility flags
29-
export RUSTFLAGS='-C target-cpu=generic -C link-arg=-Wl,--build-id=none -C symbol-mangling-version=v0 -L /usr/lib/x86_64-linux-gnu -l z -l zstd -l snappy'
30-
export CARGO_PROFILE_RELEASE_LTO='thin'
31-
export CARGO_PROFILE_RELEASE_CODEGEN_UNITS='1'
32-
export CARGO_PROFILE_RELEASE_PANIC='unwind'
33-
export CARGO_PROFILE_RELEASE_STRIP='none'
34-
export CARGO_PROFILE_RELEASE_OPT_LEVEL='3'
35-
export CARGO_TERM_COLOR='never'
36-
37-
cargo fetch
38-
DESTDIR=$BUILDROOT cargo build --release --frozen --bin lighthouse --no-default-features --features portable
39-
"
40-
make_git_package \
41-
"lighthouse" \
42-
"v7.1.0" \
43-
"https://github.com/sigp/lighthouse.git" \
44-
"$LIGHTHOUSE_BUILD_CMD" \
45-
"target/release/lighthouse:/usr/bin/lighthouse"
46-
4720
# Build fluent-bit
4821
BUILD_CMD="
4922
export SOURCE_DATE_EPOCH=0

bob/bob.conf renamed to bob-common/mkosi.conf

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
[Build]
2-
Environment=LIGHTHOUSE_BINARY KERNEL_CONFIG_SNIPPETS=bob/kernel.config
32
WithNetwork=true
43

54
[Content]
6-
ExtraTrees=bob/mkosi.extra
7-
PostInstallationScripts=bob/mkosi.postinst
8-
BuildScripts=bob/mkosi.build
5+
ExtraTrees=bob-common/mkosi.extra
6+
PostInstallationScripts=bob-common/mkosi.postinst
7+
BuildScripts=bob-common/mkosi.build
98

109
Packages=podman
1110
runc
@@ -32,12 +31,6 @@ Packages=podman
3231
BuildPackages=build-essential
3332
git
3433
gcc
35-
zlib1g-dev
36-
libzstd-dev
37-
libleveldb-dev
38-
libsnappy-dev
39-
libpq-dev
40-
libssl-dev
4134
golang
4235
autoconf
4336
automake
File renamed without changes.

0 commit comments

Comments
 (0)