nim-chat-poc/RESTORE.md
Arseniy Klempner 29c64b340d
feat: mix+LEZ+RLN chat over the testnet via 2-phase gifter
Chat-side integration of the LEZ-backed RLN mix protocol:
- src/chat/delivery/waku_client.nim: mount waku_mix with onchain
  RLN spam protection wired to logos_core_client fetchers; gate
  the first publish on (a) gifter status confirmation, (b)
  cushion of 2 poll intervals after confirmation, and (c) proof
  root stability in the local valid_roots window; wrap mix
  lightpush in withTimeout so vanished SURB replies surface as
  Err instead of pinning the send coroutine.
- src/chat/client.nim: surface sendBytes errors via asyncSpawn
  wrapped try/except instead of discarding the future (was
  hiding every mix-publish failure).
- chat-side gifter client invocation (RLN membership service
  wire format, EIP-191 ethereum-allowlist auth).
- Background membership status watcher that reconciles the
  optimistic leaf returned by the gifter against the chain's
  authoritative leaf via the status RPC.

Simulation harness (simulations/mix_lez_chat/):
- Spin up sequencer + run_setup + 4 mix nodes (one of which
  runs the gifter service) + chat sender + chat receiver.
- SIM_NETWORK={local,testnet}, SIM_SLIM for testnet (reuses
  shipped config_account + cached payment_account), Docker
  image + GHCR for cross-platform testing.
- Strict mix-pool readiness gate, kademlia + RLN root activity
  checks, gifter EIP-191 auth fixture, slim-mode submodule
  minimization.
- TREE_ID_HEX pinned to the canonical testnet deployment.

Submodule bumps:
- vendor/nwaku to 8e6ba04 (LEZ-backed RLN mix + 2-phase gifter).
- vendor/logos-lez-rln to 950f287 (SPEL RLN program + mix sim
  infrastructure + canonical testnet deploy).

Docs:
- RUN_SLIM_TESTNET.md: slim sim recipe.
- cleanup/MODE_A_GIFTER_SLOT_BUG.md: per-signer nonce collision
  postmortem driving the queue+worker fix.
2026-05-28 10:53:36 -06:00

2.8 KiB

Restore point: working testnet sim — 2026-05-17

Snapshot taken before consolidation / refactoring. Reproduces a passing testnet sim run in two modes:

  • Default: SIM_NETWORK=testnet ./simulations/mix_lez_chat/run_simulation.sh --fresh — runs run_setup to create a fresh per-dev payment account, registers all 5 sim participants on the deployed RLN tree, delivers test messages.
  • Slim: SIM_NETWORK=testnet SIM_SLIM=1 ./simulations/mix_lez_chat/run_simulation.sh --fresh — skips run_setup; uses the shared payment account shipped in the submodule. Useful for fresh-clone devs who don't want to build the lez-rln/run_setup Rust binary.

Both modes pass at ~2/3 reliability (intermittent mix-routing / QtRO flake; re-run with --fresh if a single attempt stalls).

Pinned commits (per repo)

Each repo carries both an annotated tag and a branch named restore/working-2026-05-17 at the listed commit. Either can be used to recover the state if HEAD moves during consolidation.

Repo Branch when tagged Commit
. (logos-chat) feat/sim-rln-gifter-auth-v2 b6f094e
vendor/nwaku feat/sim-rln-gifter-auth 60e875f3
vendor/logos-lez-rln feat/eip191-gifter-auth ed88c8f8
vendor/logos-lez-rln/logos-delivery-module feat/eip191-gifter-auth 94173a3d
vendor/logos-lez-rln/logos-delivery-module/vendor/logos-delivery feat/eip191-gifter-auth e2799efe

Restore

# From the outer repo root:
for r in . vendor/nwaku vendor/logos-lez-rln \
         vendor/logos-lez-rln/logos-delivery-module \
         vendor/logos-lez-rln/logos-delivery-module/vendor/logos-delivery; do
  git -C "$r" checkout restore/working-2026-05-17
done

After checkout, rebuild affected nim/Rust artifacts:

# Rebuild liblogosdelivery (used by sim's delivery_module_plugin)
( cd vendor/logos-lez-rln/logos-delivery-module/vendor/logos-delivery && make liblogosdelivery )

# Rebuild run_setup (only needed for default mode, not slim)
( cd vendor/logos-lez-rln/lez-rln && cargo build --bin run_setup )

What's in this state

  • TREE_ID …1a05100200000000 (2026-05-16 deploy #2) — programs deployed on testnet, is_initialized=true.
  • vendor/logos-lez-rln/testnet/storage.json.seed ships full post-deploy wallet state (10 accounts: 2 roots + 3 deploy publics + intermediate + shared payment + 4 preconfigured).
  • vendor/logos-lez-rln/testnet/{supply_holding,payment_account,config_account}.txt for the slim-mode bootstrap.
  • Gifter (mix node 0) self-registers as a mix relay at startup (eliminates the "Plugin not ready" forwarding drop when sender's circuit routes through it).
  • FFI aligned with SPEL ConfigState (240-byte borsh) + 4-field Register instruction.
  • Cross-thread Nim heap-string race fix in mix_lez_client.