Skip to content

Latest commit

 

History

History
172 lines (137 loc) · 8.49 KB

test-server-architecture.md

File metadata and controls

172 lines (137 loc) · 8.49 KB

Test / build server architecture & recreation

How the Pithead reference test server (the reference box) is structured, and how to recreate it on another box. The synced chains are the slow-to-acquire asset (days to sync); everything else is reproducible in minutes from the repo.

See also Releasing and Release / Validation Server.

What this server is

A single box that runs the live Pithead stack against real, synced chains and serves three jobs:

  1. Tier-4 release gate: the integration harness (integration-testing) validates a release end-to-end here before it ships.
  2. Developer + AI-agent test bench: a consistent place to reproduce, test, and debug stack behavior against real daemons.
  3. Reference deployment: a known-good, documented install other boxes can be cloned from.

It is not a production miner. Downtime is fine; tear-down/redeploy is fine. The one rule: don't lose the synced chains (reuse them, don't re-sync).

Hardware & storage policy

NVMe SSD (fast, PRIMARY)               HDD (slow, SPARING)
  /boot, /boot/efi                      /home   ← cold backups / archives only
  / (root, LVM ext4)
    ├─ /var/lib/docker        (images)
    ├─ /srv/code/pithead      (CHECKOUT, = ~/code/pithead)
    └─ /srv/code/pithead-data (CHAINS)  ← the asset, on fast storage

Policy, the single most important hardware rule: the chains monerod/Tari actively run against live on the SSD/NVMe. monerod is random-I/O heavy; a chain on a spinning HDD makes every test crawl. The HDD is for cold things only (backup tarballs, archived snapshots). Check lsblk -d -o NAME,ROTA before placing any chain: ROTA=0 is SSD/NVMe, ROTA=1 is HDD.

Sizing (a pruned-Monero test bench fits in ~1 TB):

Component Size
Pruned Monero ~258 GiB
Tari (archival/full) ~132 GiB
Docker images + cache ~20 GiB
OS + working headroom ~30 GiB
Total ~440 GiB
+ optional full Monero node [TODO: verify upstream — no full-chain measurement on this bench]
+ each extra pruned chain copy ~258 GiB

A 1 TB NVMe (~931 GiB usable) holds the pruned bench with ~490 GiB to spare.

The Monero row is measured on this bench, not a compaction target — the table previously carried "~95 GB (compacted)", which under-budgeted the disk by ~160 GiB. Read the freelist note below before planning around a smaller number.

NOTE: verify the disk is actually fast. "SSD" in the model name is not enough; check the bus. A drive sold as an "SSD" can enumerate on SATA rather than NVMe, on a link that negotiates down to a slow speed, and benchmark at ~37–98 MB/s, HDD-class. That single fact bottlenecks monerod, builds, and makes LMDB compaction (heavy random I/O) impractical (~16 h instead of ~10 min). Confirm the bus before relying on a drive:

lsblk -d -o NAME,TRAN,ROTA,MODEL   # want TRAN=nvme, not sata
ls /dev/nvme*                       # an NVMe drive appears as a /dev/nvme* node
# quick reality check on random read (what monerod does):
dd if=/path/to/data.mdb of=/dev/null bs=4k count=200000 skip=10000000   # want >>100 MB/s

The fix is to put the chains on a fast NVMe SSD. Add an m.2 PCIe NVMe and migrate the chains onto it; mount the data dir by UUID via fstab (ext4, noatime, nofail) and keep the OS on a separate disk. monerod then opens the pruned LMDB in seconds and the full integration matrix runs green.

Do not budget for compaction to reclaim that size. The chain is correctly pruned, and it is also dense: mdb_stat -ef on an idle copy reports a freelist of 10 pages out of 67,605,667, and pages_used * 4096 equals the file size exactly. An in-place prune can leave reclaimable free pages (LMDB never shrinks its file), and compact-chain.sh (monero-blockchain-prune --copy-pruned-database) rewrites the DB when it does — but measure the freelist first; this paragraph used to promise compaction down to ~95 GB, which was never measured (#1446).

MDB_VERSION_MISMATCH from a stock LMDB tool is the lock-file format, not a patched on-disk format: it appears while monerod holds the environment, and the same tool opens an idle copy of the same chain. Measured here on monerod 0.18.5.1, where both DBs read magic 0xbeefc0de, version 1 (#1446) — one bench, one build. Do not stop monerod over it. CoW snapshots need btrfs/zfs on the NVMe (if it's ext4); see below.

A second m.2 NVMe (PCIe) with btrfs/zfs additionally enables copy-on-write snapshots: instant, near-free chain clones for isolated/parallel test runs.

Directory layout

Path Disk What Lose it?
~/code/pithead/ (/srv/code/pithead) SSD stack checkout (docker-compose.yml, the pithead CLI), config.json, .env reproducible (clone)
/srv/code/pithead-data/{monero,tari,p2pool,dashboard,tor}/ NVMe the chains + Tor onion keys, the asset (mounted by UUID, ext4) don't (days to re-sync)
/var/lib/docker/ SSD images / build cache reproducible (rebuild)
~/pithead-testbench/ HDD build-server docs + ops tools (see its README.md) reproducible (repo)
/home … /mnt/chains HDD cold backups / archives —

The chains live outside the checkout (/srv/..., absolute paths in config.json), so the stack can be refreshed/redeployed without ever touching them.

Recreate on another box

Goal: stand up an equivalent server. Minutes of work + one chain transfer (vs days of re-sync).

1. Prereqs. Ubuntu LTS, Docker (Compose v2), git jq curl tar, and your user in the docker group. Put the chains' target on the SSD.

2. Clone + configure:

git clone https://github.com/p2pool-starter-stack/pithead.git ~/pithead && cd ~/pithead
cp /path/to/your/config.json .         # your wallets/settings — or run `./pithead setup` to make one
# point data dirs at fast storage (checkout-independent):
jq '.monero.data_dir="/srv/<you>/pithead/data/monero"
  | .tari.data_dir="/srv/<you>/pithead/data/tari"
  | .p2pool.data_dir="/srv/<you>/pithead/data/p2pool"
  | .dashboard.data_dir="/srv/<you>/pithead/data/dashboard"
  | .tor.data_dir="/srv/<you>/pithead/data/tor"' config.json | sponge config.json

3. Bring the chains (reuse, don't re-sync). Stop the stack on the source box (./pithead down) so the LMDBs are consistent, then copy /srv/.../pithead/data/ to the new box's SSD, over the network or a fast external drive:

# from the new box, pulling from the old one (chains measure ~390 GiB: ~258 Monero + ~132 Tari;
# hours over GbE, faster over USB3/10G):
rsync -aP --info=progress2 olduser@oldbox:/srv/code/pithead-data/ /srv/<you>/pithead/data/

The Tor onion keys travel in data/tor, so the box keeps its onion identity. (No old box yet? Omit this and let monerod/Tari sync from scratch; days, but hands-off.)

4. Deploy + verify:

cd ~/pithead && ./pithead setup        # deps, .env, Tor, Caddy; then `up`
./pithead status                        # all healthy; monerod just catches up the gap

5. Test-bench tooling:

mkdir -p ~/pithead-testbench/bin
cp ~/pithead/tests/integration/tools/{build-pruned-chain,compact-chain,system-info}.sh ~/pithead-testbench/
cp ~/pithead/tests/integration/tools/testbench-README.md ~/pithead-testbench/README.md
# fetch monero-blockchain-prune at the running monerod's version (see build/monero/Dockerfile pins):
~/pithead-testbench/system-info.sh > ~/pithead-testbench/system-info.md

These copies seed a fresh box. On a box that already has them they overwrite whatever the operator annotated locally, and both halves have held such detail (#1506): the README names hosts, users and paths the repo twin deliberately does not carry, and a deployed script has outlived the tracked one on a safety warning. Diff before you copy, and reconcile by hand rather than overwrite.

6. Validate it's release-fit:

tests/integration/run.sh --host you@newbox --dir pithead --readiness

Migrating the test bench → a bigger box later

Same as above, steps 3–6: rsync the chains + config.json over, pithead setup, redeploy, copy the test-bench tooling, regenerate system-info.md. Because the chains are decoupled and the config is captured, the move is a transfer + a redeploy. No reconfiguration, no re-sync. Put the chains on the bigger box's fastest disk; if it has spare NVMe, that's the place for a btrfs/zfs CoW volume to get cheap test-chain snapshots.