|
| 1 | +# Flashbots Images 📦⚡📦 |
| 2 | + |
| 3 | +**Reproducible hardened Linux images for confidential computing and safe MEV** |
| 4 | + |
| 5 | +Flashboxes is 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. |
| 6 | + |
| 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. |
| 8 | + |
| 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). |
| 10 | + |
| 11 | +## 🌟 Features |
| 12 | + |
| 13 | +- **Reproducible Builds**: Deterministic image generation using Nix and frozen Debian snapshots |
| 14 | +- **Confidential Computing**: Built-in support for Intel TDX and remote attestation |
| 15 | +- **Minimal Attack Surface**: Uses very few packages (20Mb base) |
| 16 | +- **Flexible Deployment**: Support for Bare Metal TDX, QEMU, Azure, and GCP |
| 17 | + |
| 18 | +## 🚀 Quick Start |
| 19 | + |
| 20 | +### Prerequisites |
| 21 | + |
| 22 | +0. Make sure you're running systemd v250 or greater, or wait for [Docker support](https://github.com/flashbots/flashboxes/pull/11) |
| 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 | + ``` |
| 40 | + |
| 41 | +### Building Images |
| 42 | + |
| 43 | +1. **Enter the development environment**: |
| 44 | + ```bash |
| 45 | + nix develop -c $SHELL |
| 46 | + ``` |
| 47 | + |
| 48 | +2. **Build a specific image**: |
| 49 | + ```bash |
| 50 | + # Build the BOB (searcher sandbox) image |
| 51 | + mkosi --force -I bob.conf |
| 52 | + |
| 53 | + # Build the Buildernet image |
| 54 | + mkosi --force -I buildernet.conf |
| 55 | + |
| 56 | + # Build with development tools |
| 57 | + mkosi --force -I bob.conf --profile=devtools |
| 58 | + |
| 59 | + # Build with Azure compatibility |
| 60 | + mkosi --force -I bob.conf --profile=azure |
| 61 | + |
| 62 | + # Build with both |
| 63 | + mkosi --force -I bob.conf --profile=azure,devtools |
| 64 | + ``` |
| 65 | + |
| 66 | +### Running Images |
| 67 | + |
| 68 | +**Create persistent storage** (for stateful applications): |
| 69 | + ```bash |
| 70 | + qemu-img create -f qcow2 persistent.qcow2 2048G |
| 71 | + ``` |
| 72 | + |
| 73 | +**Run QEMU**: |
| 74 | + ```bash |
| 75 | + sudo qemu-system-x86_64 \ |
| 76 | + -enable-kvm \ |
| 77 | + -machine type=q35,smm=on \ |
| 78 | + -m 16384M \ |
| 79 | + -nographic \ |
| 80 | + -drive if=pflash,format=raw,readonly=on,file=/usr/share/edk2/x64/OVMF_CODE.secboot.4m.fd \ |
| 81 | + -drive file=/usr/share/edk2/x64/OVMF_VARS.4m.fd,if=pflash,format=raw \ |
| 82 | + -kernel build/tdx-debian.efi \ |
| 83 | + -netdev user,id=net0,hostfwd=tcp::2222-:22,hostfwd=tcp::8080-:8080 \ |
| 84 | + -device virtio-net-pci,netdev=net0 \ |
| 85 | + -device virtio-scsi-pci,id=scsi0 \ |
| 86 | + -drive file=persistent.qcow2,format=qcow2,if=none,id=disk0 \ |
| 87 | + -device scsi-hd,drive=disk0,bus=scsi0.0,channel=0,scsi-id=0,lun=10 |
| 88 | + ``` |
| 89 | + |
| 90 | +**With TDX confidential computing** (requires TDX-enabled hardware/hypervisor): |
| 91 | + ```bash |
| 92 | + sudo qemu-system-x86_64 \ |
| 93 | + -accel kvm \ |
| 94 | + -machine type=q35,kernel_irqchip=split,confidential-guest-support=tdx0 \ |
| 95 | + -object tdx-guest,id=tdx0 \ |
| 96 | + -cpu host,-kvm-steal-time,-kvmclock \ |
| 97 | + -m 16384M \ |
| 98 | + -nographic \ |
| 99 | + -kernel build/tdx-debian.efi \ |
| 100 | + # ... rest of options same as above |
| 101 | + ``` |
| 102 | + |
| 103 | +> Depending on your Linux distro, these commands may require changing the supplied OVMF paths or installing your distro's OVMF package. |
| 104 | +
|
| 105 | +## 📖 Documentation |
| 106 | + |
| 107 | +- [Development Guide](DEVELOPMENT.md) - Comprehensive guide for creating new modules and extending existing ones |
| 108 | +- [BOB Module Guide](bob/readme.md) - Detailed documentation for the MEV searcher environment |
0 commit comments