Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge stabilisation 21095de into demos/docs-914-install
INSTALL.md "Joining the network": kept the base's two opening paragraphs; kept
the PR's no-solo-mode point and local devnet steps, dropped sentences the base
already states, fixed Sources line numbers, merged the step 3 snapshot pin note.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
  • Loading branch information
randomblocker and claude committed Nov 12, 2026
commit 85ac88cf57c52de595fadc3514579a7010de45d2
31 changes: 13 additions & 18 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -359,30 +359,25 @@ Leave `PG_HOST=postgres` and `TLSNOTARY_HOST=tlsnotary` exactly as shipped — t

### Joining the network — required steps before real-world use

A fresh node does **not** run as an isolated single-validator chain, and the code has no solo or single-validator mode. On an empty database the node builds block 0 from `data/genesis.json` and `data/snapshot/` (or the files `DEMOS_GENESIS_FILE` and `DEMOS_SNAPSHOT_DIR` name). The bundled snapshot carries 35 validators and wins over the 4 listed in the bundled `genesis.json`; a freshly generated identity is in neither list. `properties.shardSize` in the bundled genesis is 10.
A fresh node joins no network by itself: it starts from the genesis bundled in the image (the testnet's) and knows no peer. To participate in the actual Demos testnet/mainnet, you must do **three things** before the node's first start. A validator does them as part of [Run a released image](#run-a-released-image-validators) (steps 3, 4 and 6); a source build does them here.

A node forges a block only when the committee it draws has at least `floor(2 × shardSize / 3) + 1` members online (7 for a shard size of 10) and includes the node's own identity. The Track 1 steps with the shipped `.env` defaults (`./run --docker`) do not get that far: the image sets `NODE_ENV=production` and `EXPECTED_GENESIS_HASH` and `DEMOS_ALLOW_UNPINNED_GENESIS` are empty, so the node refuses to boot with "EXPECTED_GENESIS_HASH is not set. A production node must pin the genesis it joins" before it builds block 0. The bundled `data/genesis.json` does not declare `snapshot.manifestSha256`, and the bundled `data/snapshot/` is present, so with any `EXPECTED_GENESIS_HASH` the node still refuses to boot ("a snapshot is present but the pinned genesis does not declare snapshot.manifestSha256, so nothing binds it"). With the image's own files the node starts only with `DEMOS_ALLOW_UNPINNED_GENESIS=true` (the opt-out described under step 3 below, for a local network that has no published hash). It also starts if you mount a genesis that declares `snapshot.manifestSha256` for the snapshot present (the mainnet template does) and pin that genesis's hash (step 3 below, "Pin the network's genesis"). Once it starts, with no peerlist it stays at block 0: each consensus round ends with `NotInShardError` in the log ("Committee below minimum size: refusing to forge" or "We are not in the shard") and no block is produced.
A node forges only while at least the quorum of the genesis `shardSize` (2/3 + 1: 7 of 10, 3 of 3) of its validators are online. A genesis whose validator set has fewer validators active at block 0 than that never gets past block 0. The smallest `shardSize` a node accepts is 3, with a quorum of 3, so a network of fewer than 3 validators never forges: a rehearsal needs at least 3 validators at `shardSize` 3. `genesis-hash.ts` and `node-doctor --production` report such a genesis before the start.

Genesis rejects a `shardSize` below 3, so the smallest committee that can forge is 3 validators. The code has no setting that lets one node forge alone. There is also no documented step that adds your node's identity to the validator set of the bundled genesis. A local chain needs at least the committee floor of validators whose identities are in the validator set it starts from. In the repository's local devnet, `testing/devnet/scripts/setup.sh` runs `generate-genesis.sh`, which rewrites the validator list in `testing/devnet/genesis.devnet.json` to the newly generated node identities (4 by default, set by `NODE_COUNT`; see [testing/devnet/README.md](testing/devnet/README.md)). The devnet genesis has a `shardSize` of 10, which gives a floor of 7, so the default 4 validators are below it: the repository's `floor` quorum drill boots exactly that and expects no block past 0.
A fresh node does **not** run as an isolated single-validator chain, and the code has no solo or single-validator mode. Started alone from the bundled files it stays at block 0: the 35 validators of the bundled snapshot take precedence over the 4 listed in the bundled `genesis.json` (`shardSize` 10), a freshly generated identity is in neither list, and a node forges only in a committee that includes its own identity (otherwise it logs `We are not in the shard`).
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved

That edited genesis only applies when `testing/devnet/docker-compose.fixture.yml` is used as an overlay: it mounts `genesis.devnet.json` over `/app/data/genesis.json` and `./empty-snapshot`, a directory with no `manifest.json`, over `/app/data/snapshot/`. With no snapshot the node takes the balances path, and `ensureValidatorSeed` seeds the genesis validators at boot, while the chain is still at block 0. A snapshot whose `validators.jsonl` has rows owns the validator set, so the genesis list applies only when the snapshot has no validator rows. Without the overlay, the image's baked genesis and the 35-validator snapshot are used, and the snapshot validators win. The devnet compose file runs the nodes with `NODE_ENV=development`, so the pin requirement above does not apply there.
For a local chain that forges, use the repository's devnet ([testing/devnet/README.md](testing/devnet/README.md)). Its `scripts/setup.sh` runs `generate-genesis.sh`, which rewrites the validator list in `testing/devnet/genesis.devnet.json` to the newly generated node identities (4 by default, set by `NODE_COUNT`). That genesis applies only with `testing/devnet/docker-compose.fixture.yml` as an overlay: it mounts `genesis.devnet.json` over `/app/data/genesis.json` and `./empty-snapshot`, a directory with no `manifest.json`, over `/app/data/snapshot/`, so with no snapshot the genesis validators are seeded at block 0. The devnet nodes run with `NODE_ENV=development` and the devnet genesis has a test network's chain id (1337), so the pin requirement of step 3 does not apply there.

`NODE_COUNT` cannot reach the floor of 7: `generate-genesis.sh` rejects node 6, and Compose defines at most five nodes (`node-5` is in the `rehearsal` profile). To get a devnet that forges, run `setup.sh` (it regenerates identities on every run and overwrites `testing/devnet/identities/node<N>.identity` and `node<N>.pubkey` for each node, so copy any you still need first), then lower `properties.shardSize` to the validator count in a copy of `genesis.devnet.json` and mount the copy over `/app/data/genesis.json` with one more compose file, listed after the fixture file. `testing/devnet/scripts/test-tx-status-e2e.sh` does this with `jq '.properties.shardSize = (.validators | length)'`. Start on an empty database: the Postgres data is a named volume that survives `docker compose down` (`.env.example` sets `PERSISTENT=0`, and any non-empty value mounts it), and a node that already holds block 0 reads `shardSize` from that block, so the copy has no effect. Run `docker compose` with the same `--profile` and `-f` options and `down -v` first, as that script does. Four validators with a `shardSize` of 4 have a floor of 3. For `NODE_COUNT=5`, add `--profile rehearsal` and mount the copy on `node-5` too.
The devnet genesis has a `shardSize` of 10 (quorum 7), so the default 4 validators never get past block 0, and `NODE_COUNT` cannot reach 7: `generate-genesis.sh` rejects node 6, and Compose defines at most five nodes (`node-5` is in the `rehearsal` profile). To get a devnet that forges, run `setup.sh` (it regenerates identities on every run and overwrites `testing/devnet/identities/node<N>.identity` and `node<N>.pubkey` for each node, so copy any you still need first), then lower `properties.shardSize` to the validator count in a copy of `genesis.devnet.json` and mount the copy over `/app/data/genesis.json` with one more compose file, listed after the fixture file; four validators at `shardSize` 4 have a quorum of 3. `testing/devnet/scripts/test-tx-status-e2e.sh` does this with `jq '.properties.shardSize = (.validators | length)'`. Start on an empty database: the Postgres data is a named volume that survives `docker compose down` (`testing/devnet/.env.example` sets `PERSISTENT=0`, and any non-empty value mounts it), and a node that already holds block 0 reads `shardSize` from that block, so the copy has no effect. Run `docker compose` with the same `--profile` and `-f` options and `down -v` first, as that script does. For `NODE_COUNT=5`, add `--profile rehearsal` and mount the copy on `node-5` too.
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved

Sources for the paragraphs above:
Sources for the paragraphs above and the snapshot paragraph of step 3:

- `data/genesis.json` (`properties.shardSize`, `validators`), `data/snapshot/manifest.json` and `data/snapshot/validators.jsonl` (35 rows), `Dockerfile:49` (`COPY data/ ./data/`)
- `src/libs/blockchain/genesis/restoreGenesisState.ts:86-96` and `src/libs/blockchain/routines/ensureValidatorSeed.ts:107-151` (snapshot validators take precedence over the genesis list; the genesis list is the fallback at block 0)
- `src/libs/blockchain/genesis/genesisFile.ts:12-16` and `src/libs/blockchain/genesis/loadSnapshot.ts:170-176` (`DEMOS_GENESIS_FILE`, `DEMOS_SNAPSHOT_DIR`), `src/libs/blockchain/genesis/loadSnapshot.ts:444-452` (no snapshot directory or no `manifest.json` means no snapshot)
- `Dockerfile:266` (`NODE_ENV=production`), `docker-compose.yml:192-194` (the pin variables pass through empty), `src/libs/blockchain/routines/findGenesisBlock.ts:155-163` and `src/libs/blockchain/genesis/genesisPin.ts:56-68` (boot refused without a pin or `DEMOS_ALLOW_UNPINNED_GENESIS`), `src/libs/blockchain/genesis/genesisPin.ts:186,199-204` (an empty pin returns before this refusal) and `src/libs/blockchain/routines/findGenesisBlock.ts:217-227` (a pinned genesis that does not declare `snapshot.manifestSha256` is refused while a snapshot is present, before block 0 is written)
- `src/libs/consensus/genesisShardSize.ts:20-21,50-54` (shard size must be 3 to 100)
- `src/libs/consensus/v2/quorum.ts:10-12` and `src/libs/consensus/v2/routines/getShard.ts:32-34` (committee floor)
- `src/libs/consensus/v2/types/secretaryManager.ts:267-281` (the two `NotInShardError` cases)
- `testing/devnet/scripts/generate-genesis.sh:1-10,27`, `testing/devnet/scripts/setup.sh:24`, `testing/devnet/genesis.devnet.json` (`properties.shardSize`), `testing/devnet/docker-compose.fixture.yml:9-13,27-28`, `testing/devnet/docker-compose.yml:62` (`NODE_ENV=development`), `testing/devnet/quorum-drills/README.md:131` (the `floor` drill)
- `data/genesis.json` (`properties.shardSize`, `validators`), `data/snapshot/manifest.json` and `data/snapshot/validators.jsonl` (35 rows), `Dockerfile:99` (`COPY data/ ./data/`)
- `src/libs/blockchain/genesis/restoreGenesisState.ts:86-96` and `src/libs/blockchain/routines/ensureValidatorSeed.ts:107-151` (snapshot validators take precedence over the genesis list; the genesis list is the fallback at block 0), `src/libs/blockchain/genesis/loadSnapshot.ts:444-452` (no snapshot directory or no `manifest.json` means no snapshot)
- `src/libs/consensus/v2/quorum.ts:10-12` and `src/libs/consensus/v2/routines/getShard.ts:32-34` (committee floor), `src/libs/consensus/v2/types/secretaryManager.ts:276-281` (`We are not in the shard`)
- `Dockerfile:290` (`NODE_ENV=production`), `docker-compose.yml:192-194` (the pin variables pass through empty), `src/libs/blockchain/routines/findGenesisBlock.ts:159-166` and `src/libs/blockchain/genesis/genesisPin.ts:75-95` (without a pin, boot is refused on a chain id that is not a test network's, and in production unless `DEMOS_ALLOW_UNPINNED_GENESIS` is set), `src/forks/forkConfig.ts:653` (chain ids 1 and 1337 are test networks'), `src/libs/blockchain/genesis/genesisPin.ts:261-273,286-291` and `src/libs/blockchain/routines/findGenesisBlock.ts:240-251` (while a snapshot is present, a genesis that does not declare `snapshot.manifestSha256` is refused with either pin set, before block 0 is written), `docs/mainnet/genesis.template.json` (declares `snapshot.manifestSha256`)
- `testing/devnet/scripts/generate-genesis.sh:1-10,27`, `testing/devnet/scripts/setup.sh:24`, `testing/devnet/genesis.devnet.json` (`properties.id`, `properties.shardSize`), `testing/devnet/docker-compose.fixture.yml:9-13,27-28`, `testing/devnet/docker-compose.yml:62` (`NODE_ENV=development`), `testing/devnet/quorum-drills/README.md:131` (the `floor` drill boots the default 4 validators and expects no block past 0)
- `testing/devnet/scripts/setup.sh:18` (calls `generate-identities.sh` on every run), `testing/devnet/scripts/generate-identities.sh:6,18-34` (`node${i}.identity` and `node${i}.pubkey` in `testing/devnet/identities` are written unconditionally, with no existence check)
- `testing/devnet/scripts/generate-genesis.sh:30-39,45-54` (node index 6 is rejected), `testing/devnet/docker-compose.yml:221-222` (`node-5`, `rehearsal` profile; no `node-6`), `testing/devnet/scripts/test-tx-status-e2e.sh:44,75-89,95-97` (the `rehearsal` profile, the `shardSize` copy and the override file, `down -v` before `up`), `testing/devnet/.env.example:35` and `testing/devnet/docker-compose.yml:13` (`PERSISTENT=0` still mounts the `postgres-data` volume), `src/libs/consensus/genesisShardSize.ts:63-85` and `src/libs/blockchain/routines/findGenesisBlock.ts:167-202` (a node with block 0 reads `shardSize` from the stored block)

To participate in the actual Demos testnet/mainnet, you must do **three things** before the node's first start:
- `testing/devnet/scripts/generate-genesis.sh:30-39,45-54` (node index 6 is rejected), `testing/devnet/docker-compose.yml:221-222` (`node-5`, `rehearsal` profile; no `node-6`), `testing/devnet/scripts/test-tx-status-e2e.sh:44,75-89,95-97` (the `rehearsal` profile, the `shardSize` copy and the override file, `down -v` before `up`), `testing/devnet/.env.example:35` and `testing/devnet/docker-compose.yml:13` (`PERSISTENT=0` still mounts the `postgres-data` volume), `src/libs/consensus/genesisShardSize.ts:63-85` and `src/libs/blockchain/routines/findGenesisBlock.ts:173-223` (a node with block 0 reads `shardSize` from the stored block)

**1. Set `EXPOSED_URL` to your reachable address.**

Expand Down Expand Up @@ -439,7 +434,7 @@ EXPECTED_GENESIS_BLOCK_HASH=<published block 0 hash>

`scripts/genesis-hash.ts --genesis <file> --snapshot <dir>` prints both values for a genesis file and the snapshot it declares; the block 0 hash is the one labelled "genesis block hash". Without `--snapshot` it reads `DEMOS_SNAPSHOT_DIR`; a genesis that declares a snapshot and gets none is reported as a problem. A Docker host has no Bun: run it inside the image, as in step 4 of [Run a released image](#run-a-released-image-validators). What each hash covers, and where mainnet's are published, is in [docs/mainnet/genesis-hash.md](docs/mainnet/genesis-hash.md).

While a snapshot is present, a pin is accepted only for a genesis that declares `snapshot.manifestSha256` for it, as the mainnet genesis template does. The genesis bundled in the image declares none and the bundled snapshot is present, so with the bundled files a node with an empty database refuses to boot with any non-empty pin (an empty pin skips this check; this snapshot check runs only when block 0 is built, so a database that already holds block 0 is not refused for it); see the paragraphs at the top of this section.
While a snapshot is present, a pin is accepted only for a genesis that declares `snapshot.manifestSha256` for it, as the mainnet genesis template does. The genesis bundled in the image declares none and the bundled snapshot is present, so on an empty database the image starts on its own files only with neither pin set and `DEMOS_ALLOW_UNPINNED_GENESIS=true`.

A validator never leaves these set in `.env`: `DEMOS_ALLOW_UNPINNED_GENESIS`, and the one-start switches `DEMOS_GENERATE_IDENTITY`, `DEMOS_IDENTITY_TAKEOVER`, `DEMOS_SIGNING_RECORD_REBIND` and `DEMOS_ACCEPT_FORK_SCHEDULE_DIGEST`. Each of the last four is for the single start that needs it (see [docs/runbooks/validator-key.md](docs/runbooks/validator-key.md) and below); remove it once the node runs. `./scripts/node-doctor --production` fails while any of them is set.

Expand Down
Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.