Skip to main content

Set up and run a Flashbox

This page takes you from the IP address of a new Flashbox VM to a bot that runs in production mode.

You need:

  • an ed25519 SSH key pair (ssh-keygen -t ed25519),
  • the IP address of your VM,
  • a strong passphrase for the disk. Save it. It cannot be recovered or changed.

1. Register your SSH key​

A new VM waits for one SSH public key on port 8080. Submit yours, as the base64 part of the key only, without the ssh-ed25519 prefix and the comment:

curl -X POST -d "$(cut -d' ' -f2 ~/.ssh/my_searcher_key.pub)" http://VM_IP:8080

The VM accepts one key, one time, and keeps it for good. If your SSH login works in step 3, no other key can control the VM. If the login fails, somebody else registered a key first: tell us and we deploy a new VM.

2. Verify the VM​

Before you upload anything, check that the VM runs the image that you can read on GitHub.

  1. Check out the release tag in flashbots/flashbots-images and build the image: make build IMAGE=flashbox-l1. A cold build takes about 30 minutes. Build on x86-64 Linux.
  2. Compute the measurements of your build. They must match the measurements that the release publishes.
  3. Run the attestation client against port 8745 of your VM. It passes only when the VM's TDX quote matches your measurements.
  4. Add the VM's SSH host keys to your known_hosts over the attested connection. Your first SSH connection is then already verified. The VM makes new host keys on every boot, so fetch them again after a reboot.

The exact commands change between releases. Use the attestation walkthrough in the readme of the release you run.

3. Unlock the disk​

Run this on every boot:

ssh -i ~/.ssh/my_searcher_key searcher@<vm-ip> initialize

On the first boot it creates the encrypted disk and asks for a new passphrase. On later boots it asks for the same passphrase and unlocks the disk. In both cases it ends with /persistent mounted.

If it fails with Permission denied (publickey), your SSH key was not accepted. Check that you registered it, wait a few seconds and try again. If it still fails, contact us.

4. Deploy your bot​

A new VM starts in maintenance mode:

ssh -i ~/.ssh/my_searcher_key searcher@<vm-ip> status
# maintenance

SSH into your container on port 10022:

ssh -i ~/.ssh/my_searcher_key -p 10022 root@<vm-ip>

Inside the container:

  • Keep everything that must survive a reboot under /persistent. The rest of the container is rebuilt on every boot.
  • Run your own execution client. It talks to the managed Lighthouse over the engine API on port 8551, with the JWT secret at /secrets/jwt.hex. Bind the engine API to 0.0.0.0, because Lighthouse connects from outside the container.
  • Write your logs to /var/log/searcher/bob.log. Only this file is readable from outside in production mode.
  • Nothing starts your processes after a reboot. Start them yourself over SSH.

A Geth configuration that works:

geth --datadir /persistent \
--authrpc.jwtsecret /secrets/jwt.hex \
--authrpc.port 8551 \
--authrpc.addr 0.0.0.0 \
--syncmode snap

Your bot connects to the streams from inside the container. See Orderflow APIs.

5. Push data into the container (optional)​

Two input channels stay open in production mode. Both are one-way, so the container cannot reply on them.

  • UDP, port 27017. The VM forwards these packets into the container. Your bot binds the port and reads them.
  • TLS, port 27018. The VM accepts only a client certificate made from your SSH key, and writes what you send to the Unix socket /persistent/input/input.sock. Your bot creates that socket and listens on it.

To use the TLS channel:

# The VM's certificate, fetched over the verified SSH connection
ssh -i ~/.ssh/my_searcher_key searcher@<vm-ip> input-cert > server.crt

# A client certificate made from your SSH key (once)
git clone https://github.com/flashbots/input-only-proxy.git
./input-only-proxy/scripts/ssh_to_tls_cert.py ~/.ssh/my_searcher_key client-cert.pem

# Example client
cd input-only-proxy
cargo run --example tls_client -- <vm-ip>:27018 ../client-cert.pem ../server.crt

6. Switch to production​

ssh searcher@<vm-ip> toggle
ssh searcher@<vm-ip> status # production
ssh searcher@<vm-ip> tail-the-logs # your logs, 5 minutes late

The streams are now on, and SSH into the container is off.

Update your bot​

To get back into the container, toggle out of production, wait 5 minutes, and toggle again. status prints stopped in between.

ssh searcher@<vm-ip> toggle    # production -> stopped: the streams are cut
# wait 5 minutes
ssh searcher@<vm-ip> toggle # stopped -> maintenance: SSH into the container is back
# update your bot over ssh -p 10022
ssh searcher@<vm-ip> toggle # maintenance -> production

Commands​

Run each as ssh -i <key> searcher@<vm-ip> <command>.

CommandWhat it does
statusPrints the current mode.
toggleSwitches to the next mode.
initializeCreates or unlocks the encrypted disk.
logs NPrints the last N lines of your delayed log.
tail-the-logsFollows your delayed log.
restart-lighthouseRestarts the consensus client.
input-certPrints the certificate of the TLS input channel.
reboot [--force]Reboots the VM. It works only in maintenance mode.

Image upgrades​

We upgrade the image for security fixes and improvements, and we announce each upgrade in your Telegram group before it happens. After an upgrade:

  1. The VM restarts in maintenance mode with your disk locked. Only you can unlock it.
  2. The SSH host keys are new, as after every boot. Verify the VM against the new release, then accept the keys.
  3. Run initialize with your passphrase, start your processes, and toggle to production.

Before an upgrade, stop your bot and your execution client cleanly, and back up what matters from /persistent. A new Lighthouse version can need a newer execution client, so check the release notes.