Prem Chaitanya Prathi 4a3db364e7
fix(kademlia): allow clientMode without switch.mount
ServiceDiscovery.new(client=true) installs no inbound handler, so
switch.mount always failed. Skip mount for clientMode and keep the
protocol for outbound mix lookups only. Add a unit test and document
relative CHAT_UI paths in the mixnet chat-ui launcher.
2026-07-09 18:41:49 +05:30

46 lines
1.9 KiB
Bash
Executable File

#!/usr/bin/env bash
# Run a logos-chat-ui client against this mixnet sim.
#
# ./run_chat_ui.sh A # first client (adopts provisioned chat membership 1)
# ./run_chat_ui.sh B # second client (adopts provisioned chat membership 2)
#
# Each client adopts one of the two provisioned chat memberships via CHAT_NODEKEY
# (the same nodekeys run_chat_mix*.sh use), and runs from a per-client dir holding
# the RLN tree + keystores — mountMix loads rln_keystore_<peerId>.json + rln_tree.db
# from cwd, and CHAT_NODEKEY fixes the peerId so the right keystore resolves.
#
# Prereqs (from ../):
# 1. make wakunode2 # build the mix node binary
# 2. ./build_setup.sh # generate rln_tree.db + keystores
# 3. ./run_mix_node.sh and run_mix_node1..4.sh # all 5 mix nodes running
set -euo pipefail
HERE="$(cd "$(dirname "$0")" && pwd)"
SIM="$(cd "$HERE/.." && pwd)"
source "$HERE/env.sh"
case "${1:-}" in
A) export CHAT_NAME=ClientA CHAT_PORT=60010 \
CHAT_NODEKEY=35eace7ccb246f20c487e05015ca77273d8ecaed0ed683de3d39bf4f69336feb ;;
B) export CHAT_NAME=ClientB CHAT_PORT=60011 \
CHAT_NODEKEY=cb6fe589db0e5d5b48f7e82d33093e4d9d35456f4aaffc2322c473a173b2ac49 ;;
*) echo "usage: $0 <A|B>"; exit 1 ;;
esac
DIR="$HERE/run-${1}"
mkdir -p "$DIR"
cp -f "$SIM/rln_tree.db" "$DIR/" 2>/dev/null \
|| { echo "missing rln_tree.db — run ../build_setup.sh first"; exit 1; }
cp -f "$SIM"/rln_keystore_*.json "$DIR/"
# If CHAT_UI is a local checkout (not a flake ref like github:/git+/path:),
# resolve it to an absolute path NOW — before we cd into the per-client run dir
# below — so it can be passed relative to where you invoke this script (e.g.
# CHAT_UI=../../../../logos-chat-ui). Flake refs don't exist on disk, so the
# `-e` test skips them and they're left untouched.
if [ -e "$CHAT_UI" ]; then
CHAT_UI="$(cd "$CHAT_UI" && pwd)"
fi
cd "$DIR"
exec nix run "$CHAT_UI" --accept-flake-config