Skip to content

Adding the consensus committee

The committee puts a BFT agreement step in front of the relayer: an event is executed only after a committee of virtual relayer nodes has agreed on it.

It exists for experiments comparing an honest committee with one containing crashed or Byzantine members, not for production. It is off unless CONSENSUS_ENABLED=true.

You will learn / You need

You will learn: how to turn the committee on, what its nodes accept, how the four Byzantine presets behave, which CSV columns it adds, and where it stops protecting you. You need: a working bridge setup (the committee sits in front of BridgeAA) and the ideas in Agreement: the consensus committee. Every CONSENSUS_* variable is in Configuration.

flowchart LR
    L[event_listener] --> I["consensus_committee<br/>n CometBFT nodes"]
    I -- "signed delivery<br/>after ⌊(n−1)/3⌋+1 reports" --> H[event_handler]
    H --> AA[BridgeAA]

How it works

  • Nodes. One container runs every node: one CometBFT v0.38 process per validator, each driving its own ABCI application in the Rust process, all on loopback.
  • What honest nodes accept. An event that the executor's own intent_from_event accepts, whose source_sender is in the destination ACL, and which the node observed itself and has not seen committed. The last check rejects forged, altered and replayed events.
  • Delivery. Once ⌊(n−1)/3⌋+1 nodes report a commit, the committee posts the event to event_handler, signed with HMAC-SHA256 under CONSENSUS_DELIVERY_KEY. The handler answers 403 to anything unsigned, including events posted to it directly, and executes each delivery once.
  • Liveness. If crashes at runtime leave no quorum, /health and ingest answer 503, so the listener keeps its cursor. A committee configured without a quorum stays up, since that stall is the experiment.

Running it

# in stealth_name_service/backend/.env
CONSENSUS_ENABLED=true
CONSENSUS_DELIVERY_KEY=<output of: openssl rand -hex 32>
CONSENSUS_NODES=4
CONSENSUS_BYZANTINE_NODES=1
CONSENSUS_FAULTY_NODES=0
CONSENSUS_BYZANTINE_STRATEGY=forge

./deploy.sh bridge
docker exec $(docker ps -qf name=consensus_committee) curl -s localhost:5000/api/status

deploy.sh stops before touching the running stack if the key is missing or shorter than 32 characters. Each node's CometBFT home and cometbft.log go to ./consensus_data, wiped on every start. .env_sample documents every other CONSENSUS_* setting, including the timeouts and the localhost network tuning.

Try it

With n validators the committee tolerates f = ⌊(n−1)/3⌋ faulty or Byzantine nodes. Committing needs a quorum, which means more than ⅔ of the nodes live. A delivery to the executor needs min(f+1, live) commit reports, and at least 1. Worked example: n = 4 with 1 Byzantine node gives f = 1, so the committee is within its bound and the delivery threshold is 2.

Byzantine presets

Set with CONSENSUS_BYZANTINE_STRATEGY:

Strategy What Byzantine nodes do Expected with f ≤ ⌊(n−1)/3⌋
forge Propose tampered and fabricated events; accept any proposal Rejected; only real events commit
censor Propose empty blocks Events commit later, through honest proposers
delay Propose honestly, CONSENSUS_BYZANTINE_DELAY_MS late Added latency
equivocate A twin process with the same key votes the opposite way Duplicate-vote evidence is committed

CONSENSUS_FAULTY_NODES are crash-stop: in the validator set but never started. Past the bound the committee only warns. Too many crashed nodes stall it; too many forgers commit forged events, which are logged as UNSAFE COMMIT and then executed.

Testing and comparing

consensus_smoke.sh runs the committee locally against real CometBFT and a mock executor, with no stack, chain or gas. It then checks the outcome and exits non-zero on failure. all runs every preset plus the two past-bound cases:

cd stealth_name_service/backend
./consensus_smoke.sh all
./consensus_smoke.sh 4 1 0 equivocate 15   # nodes, byzantine, faulty, strategy, events

consensus_compare.sh deploys each configuration in turn (baseline, honest, 2 crashed, 2 Byzantine per strategy, honest with a 200 ms commit timeout; all but the baseline are 7-validator committees), runs the same load from the host, and writes results/consensus_compare_<timestamp>/summary.md.

Spends gas

consensus_compare.sh sends real transactions and asks before starting. --scenarios, --reps, --agents, --requests and --interval adjust the run.

Metrics

With the committee on, bridge_results.csv gains these columns. Without it, the file is unchanged.

Column Meaning
consensus_height Committee block the event was committed in
consensus_observed_at_ms When the committee ingested the event; empty for a forged commit
consensus_committed_at_ms When the first node reported the commit
consensus_delivered_at_ms When the delivery threshold was reached
consensus_latency_ms Observed to committed: the latency the committee adds
consensus_observed false means a forged commit
committee_nodes, committee_faulty, committee_byzantine, committee_strategy The run's configuration; the strategy is none without Byzantine nodes

Limitations

  • The executor is still a single point of trust. BridgeAA checks one relayer signature, so whoever holds the relayer key or CONSENSUS_DELIVERY_KEY can get an intent signed without the committee. Fixing it needs k-of-n signatures checked on-chain.
  • Observation is shared. Every node gets the same feed from the one listener: a forged proposal is caught, a lying listener is not.
  • One host. Network latency and partitions are not realistic.
  • No state across restarts. Events ingested but not yet committed when the committee restarts are lost.
  • Invalid events are dropped at ingest, counted in /api/status, and get no row in bridge_results.csv.

Check it worked

  • docker exec $(docker ps -qf name=consensus_committee) curl -s localhost:5000/api/status answers with the committee's status.
  • With CONSENSUS_BYZANTINE_STRATEGY=forge inside the bound, forged events do not appear in bridge_results.csv, and every row has consensus_observed true.
  • An event posted straight to event_handler is answered with 403.

Next