logos-messaging-nim/scripts/build_rln_mix.sh
Arseniy Klempner b40ee69e0f
feat(mix,rln-gifter): LEZ-backed RLN mix + 2-phase gifter protocol (rebased onto PR #3807; plugin via nimble)
Ports commit 14562878 onto PR #3807's logos_delivery/ layout.

Changes vs original 14562878:
- Plugin consumed via nimble dep (no submodule add); the PR #3807 nimble
  resolution already provides it.
- mountMix signature carries both PR #3807's disableSpamProtection AND
  the patch's useOnchainLEZ parameters (callsite passes both).
- WakuMix.new branches on disableSpamProtection while also setting
  useOnchainLEZ on the spam-protection config. Cover-traffic params come
  from the plugin config when RLN is enabled, fall back to waku defaults
  when disabled.
- start() retains HEAD's split between local-only init and the separate
  registerDoSProtectionWithNetwork retry loop. publishGossipsubTrigger is
  promoted to a standalone proc instead of inline in an else branch.
- MixProtocol.init uses libp2p_mix's new Opt-wrapped coverTraffic and
  the MixRlnSpamProtection.new constructor (not the renamed newMixRlnSpamProtection).
- Makefile reverted to HEAD: PR #3807 dropped the separate mix-librln
  archive in favor of a single stateless zerokit, so the patch's
  MIX_LIBRLN_* additions are obsolete.
- README/sim helper config files: HEAD's values retained (env-specific
  paths from patch author dropped).

Adds:
- logos_delivery/waku/waku_mix/logos_core_client.nim (RLN client layer)
- logos_delivery/waku/waku_mix/coordination handler (via waku_node)
- logos_delivery/waku/waku_rln_relay/rln_gifter/{client,protocol,rpc,rpc_codec}.nim
- 5 new C FFI exports (logosdelivery_set_rln_fetcher, _set_rln_config,
  _set_rln_identity, _push_roots, _push_proof)
- --mix-gifter-* CLI flags + MixConf fields + MixConfBuilder methods
- tests/waku_rln_relay/test_rln_gifter.nim
2026-06-19 18:54:41 -04:00

44 lines
1.4 KiB
Bash
Executable File

#!/usr/bin/env bash
# Build a separate, pinned RLN library for mix spam-protection usage.
# This keeps the main nwaku RLN dependency flow unchanged.
set -euo pipefail
source_dir="${1:-}"
version="${2:-}"
output_file="${3:-}"
repo_url="${4:-https://github.com/vacp2p/zerokit.git}"
if [[ -z "${source_dir}" || -z "${version}" || -z "${output_file}" ]]; then
echo "Usage: $0 <source_dir> <version_tag> <output_file> [repo_url]"
exit 1
fi
mkdir -p "$(dirname "${source_dir}")"
mkdir -p "$(dirname "${output_file}")"
if [[ ! -d "${source_dir}/.git" ]]; then
echo "Cloning zerokit ${version} from ${repo_url}..."
if [[ -e "${source_dir}" ]]; then
echo "Path exists but is not a git repository: ${source_dir}"
echo "Please remove it and retry."
exit 1
fi
git clone --depth 1 --branch "${version}" "${repo_url}" "${source_dir}"
else
echo "Using existing zerokit checkout in ${source_dir}"
current_tag="$(git -C "${source_dir}" describe --tags --exact-match 2>/dev/null || true)"
if [[ "${current_tag}" != "${version}" ]]; then
echo "Updating zerokit checkout to ${version}..."
git -C "${source_dir}" fetch --tags origin "${version}"
git -C "${source_dir}" checkout --detach "${version}"
fi
fi
echo "Building mix RLN library from source (version ${version})..."
cargo build --release -p rln --manifest-path "${source_dir}/rln/Cargo.toml"
cp "${source_dir}/target/release/librln.a" "${output_file}"
echo "Successfully built ${output_file}"