From bcc3e1306946528102bb26be9a7c41299e2f8e00 Mon Sep 17 00:00:00 2001 From: Tyler <109685178+tlongwell-block@users.noreply.github.com> Date: Thu, 23 Jul 2026 07:55:44 -0700 Subject: [PATCH 001/397] feat(relay): make Redis pool size configurable, default 16 (#2521) Signed-off-by: Tyler Longwell Co-authored-by: npub1qyvc0c5kl4gqv2fd97fsk46tu378sqgy35vc83rvgfwne90sel7s0ed67d <011987e296fd5006292d2f930b574be47c7801048d1983c46c425d3c95f0cffd@buzz.block.builderlab.xyz> Co-authored-by: Tyler Longwell --- .env.example | 2 ++ crates/buzz-relay/src/config.rs | 39 +++++++++++++++++++++++++++++++++ crates/buzz-relay/src/main.rs | 3 ++- 3 files changed, 43 insertions(+), 1 deletion(-) diff --git a/.env.example b/.env.example index 1e69c6a0e3b..db5a7ea25c7 100644 --- a/.env.example +++ b/.env.example @@ -31,6 +31,8 @@ PGDATABASE=buzz # Redis 7 # ----------------------------------------------------------------------------- REDIS_URL=redis://localhost:6379 +# Max connections in the relay's shared Redis pool (default 16). +# BUZZ_REDIS_POOL_SIZE=16 # ----------------------------------------------------------------------------- # Typesense (search) diff --git a/crates/buzz-relay/src/config.rs b/crates/buzz-relay/src/config.rs index 75e70d61796..47030dcf3f0 100644 --- a/crates/buzz-relay/src/config.rs +++ b/crates/buzz-relay/src/config.rs @@ -58,6 +58,12 @@ pub struct Config { pub read_database_url: Option, /// Redis connection URL used by the pub/sub manager. pub redis_url: String, + /// Maximum connections in the shared Redis pool. Defaults to 16. + /// + /// deadpool's own default is `CPU_COUNT * 2`, which on a 2-vCPU relay + /// pod is only 4 — small enough that rate-limit checks, presence, and + /// pub/sub publishes queue behind each other under load. + pub redis_pool_size: usize, /// Public WebSocket URL of this relay, advertised in NIP-11. pub relay_url: String, /// Public WebSocket URL of the dedicated device-pairing relay, when configured. @@ -412,6 +418,12 @@ impl Config { let redis_url = std::env::var("REDIS_URL").unwrap_or_else(|_| "redis://localhost:6379".to_string()); + let redis_pool_size = std::env::var("BUZZ_REDIS_POOL_SIZE") + .ok() + .and_then(|v| v.parse::().ok()) + .filter(|&v| v > 0) + .unwrap_or(16); + let relay_url = std::env::var("RELAY_URL").unwrap_or_else(|_| "ws://localhost:3000".to_string()); @@ -862,6 +874,7 @@ impl Config { database_url, read_database_url, redis_url, + redis_pool_size, relay_url, pairing_relay_url, max_connections, @@ -928,6 +941,7 @@ mod tests { assert!(config.bind_addr.port() > 0); assert!(!config.database_url.is_empty()); assert!(!config.redis_url.is_empty()); + assert_eq!(config.redis_pool_size, 16); assert!(config.max_connections > 0); assert!(config.send_buffer_size > 0); assert_eq!(config.max_frame_bytes, DEFAULT_MAX_FRAME_BYTES); @@ -970,6 +984,31 @@ mod tests { ); } + #[test] + fn redis_pool_size_env_override_and_invalid_fallback() { + let _guard = ENV_MUTEX.lock().unwrap(); + let previous = std::env::var_os("BUZZ_REDIS_POOL_SIZE"); + + std::env::set_var("BUZZ_REDIS_POOL_SIZE", "32"); + let overridden = Config::from_env().expect("config").redis_pool_size; + + std::env::set_var("BUZZ_REDIS_POOL_SIZE", "0"); + let zero = Config::from_env().expect("config").redis_pool_size; + + std::env::set_var("BUZZ_REDIS_POOL_SIZE", "not-a-number"); + let junk = Config::from_env().expect("config").redis_pool_size; + + if let Some(value) = previous { + std::env::set_var("BUZZ_REDIS_POOL_SIZE", value); + } else { + std::env::remove_var("BUZZ_REDIS_POOL_SIZE"); + } + + assert_eq!(overridden, 32); + assert_eq!(zero, 16, "zero must fall back to the default"); + assert_eq!(junk, 16, "unparsable value must fall back to the default"); + } + #[test] fn read_database_url_unset_or_blank_is_none() { let _guard = ENV_MUTEX.lock().unwrap(); diff --git a/crates/buzz-relay/src/main.rs b/crates/buzz-relay/src/main.rs index 00ef7819cb4..be9794922bb 100644 --- a/crates/buzz-relay/src/main.rs +++ b/crates/buzz-relay/src/main.rs @@ -334,7 +334,8 @@ async fn main() -> anyhow::Result<()> { }; let redis_pool = { - let cfg = deadpool_redis::Config::from_url(&config.redis_url); + let mut cfg = deadpool_redis::Config::from_url(&config.redis_url); + cfg.pool = Some(deadpool_redis::PoolConfig::new(config.redis_pool_size)); cfg.create_pool(Some(deadpool_redis::Runtime::Tokio1)) .map_err(|e| anyhow::anyhow!("Redis pool creation failed: {e}"))? }; From 03f645ef7e139f2eb703b477150034e8238062ae Mon Sep 17 00:00:00 2001 From: Tyler <109685178+tlongwell-block@users.noreply.github.com> Date: Thu, 23 Jul 2026 07:57:04 -0700 Subject: [PATCH 002/397] Script cleanup --- bench/t1a_evidence.sh | 77 ------------------------------------------- 1 file changed, 77 deletions(-) delete mode 100755 bench/t1a_evidence.sh diff --git a/bench/t1a_evidence.sh b/bench/t1a_evidence.sh deleted file mode 100755 index 1f23f2dc421..00000000000 --- a/bench/t1a_evidence.sh +++ /dev/null @@ -1,77 +0,0 @@ -#!/usr/bin/env bash -# T1a correctness evidence (runnable from this lane tip). -# -# Proves, against a live relay built from this tree: -# 1. permanent channel: kind:9 ingest emits no separate top-level TTL UPDATE -# transaction (the deferred trigger's conditional statement stays inside the -# event transaction and affects zero rows); -# 2. ephemeral channel: the TTL bump is still observed (ttl_deadline strictly advances -# across a message); -# 3. TTL-set-during-ingest race: messages committed after concurrent TTL activation -# extend the deadline beyond the activation update's own deadline. -# -# Usage: bench/t1a_evidence.sh -# Requires: relay running FROM THIS TREE against ; psql via docker exec; -# BENCH_PRIVATE_KEY env (member secret key hex); wamp_bench built --release. -set -euo pipefail - -PG="$1"; DBURL="$2"; RELAY="$3"; COMMUNITY="$4" -PSQL=(docker exec "$PG" psql "$DBURL" -tA) -sql() { "${PSQL[@]}" -c "$1"; } -BIN="./target/release/wamp_bench" -# BENCH_PUB = x-only pubkey hex for BENCH_PRIVATE_KEY (both required). -PUB="${BENCH_PUB:?set BENCH_PUB (x-only pubkey hex matching BENCH_PRIVATE_KEY)}" - -mkchan() { # $1 name, $2 ttl_seconds or NULL -> echoes uuid - local id; id=$(python3 -c "import uuid;print(uuid.uuid4())") - sql "insert into channels (id, community_id, name, channel_type, visibility, created_by, ttl_seconds, ttl_deadline) - values ('$id','$COMMUNITY','$1','stream','private',decode('$PUB','hex'),$2, - case when $2::int is null then null else now() + ($2::int || ' seconds')::interval end)" >/dev/null - sql "insert into channel_members (community_id, channel_id, pubkey, role) - values ('$COMMUNITY','$id',decode('$PUB','hex'),'owner')" >/dev/null - echo "$id" -} - -FAIL=0 - -echo "== 1. permanent channel: zero separate top-level TTL UPDATE statements ==" -PERM=$(mkchan t1a-perm NULL) -sql "select pg_stat_statements_reset()" >/dev/null -env -u BUZZ_AUTH_TAG BUZZ_RELAY_URL="$RELAY" "$BIN" "$PERM" 20 10 2 /tmp/t1a-perm.lat >/tmp/t1a-perm.json -ACC=$(python3 -c "import json;print(json.load(open('/tmp/t1a-perm.json'))['accepted'])") -TTL_CALLS=$(sql "select coalesce(sum(calls),0) from pg_stat_statements where query ilike '%UPDATE channels SET ttl_deadline%'") -echo "accepted=$ACC ttl_update_calls=$TTL_CALLS" -[[ "$ACC" -gt 0 && "$TTL_CALLS" == "0" ]] || { echo "FAIL: expected >0 accepted and 0 TTL updates"; FAIL=1; } - -echo "== 2. ephemeral channel: bump still observed ==" -EPH=$(mkchan t1a-eph 3600) -D0=$(sql "select extract(epoch from ttl_deadline) from channels where id='$EPH'") -sleep 2 -env -u BUZZ_AUTH_TAG BUZZ_RELAY_URL="$RELAY" "$BIN" "$EPH" 5 3 1 /tmp/t1a-eph.lat >/tmp/t1a-eph.json -D1=$(sql "select extract(epoch from ttl_deadline) from channels where id='$EPH'") -echo "deadline before=$D0 after=$D1" -python3 -c "import sys; sys.exit(0 if float('$D1') > float('$D0') else 1)" \ - || { echo "FAIL: ephemeral ttl_deadline did not advance"; FAIL=1; } - -echo "== 3. TTL-set-during-ingest race ==" -RACE=$(mkchan t1a-race NULL) -env -u BUZZ_AUTH_TAG BUZZ_RELAY_URL="$RELAY" "$BIN" "$RACE" 50 6 4 /tmp/t1a-race.lat >/tmp/t1a-race.json & -BPID=$! -sleep 2 -# update_channel-equivalent: set TTL and reset deadline in one statement, mid-burst. -ACTIVATION_DEADLINE=$(sql "update channels set ttl_seconds=600, ttl_deadline=clock_timestamp() + interval '600 seconds', updated_at=now() where id='$RACE' and deleted_at is null returning extract(epoch from ttl_deadline)") -wait "$BPID" -ROW=$(sql "select ttl_seconds, extract(epoch from ttl_deadline) from channels where id='$RACE'") -echo "activation_deadline=$ACTIVATION_DEADLINE post-race=$ROW" -FINAL_DEADLINE="${ROW#*|}" -python3 -c "import sys; sys.exit(0 if float('$FINAL_DEADLINE') > float('$ACTIVATION_DEADLINE') else 1)" \ - || { echo "FAIL: later message did not extend TTL beyond activation deadline"; FAIL=1; } -# and subsequent messages now bump it (channel is ephemeral now) -D0=$(sql "select extract(epoch from ttl_deadline) from channels where id='$RACE'") -sleep 2 -env -u BUZZ_AUTH_TAG BUZZ_RELAY_URL="$RELAY" "$BIN" "$RACE" 5 3 1 /tmp/t1a-race2.lat >/tmp/t1a-race2.json -D1=$(sql "select extract(epoch from ttl_deadline) from channels where id='$RACE'") -python3 -c "import sys; sys.exit(0 if float('$D1') > float('$D0') else 1)" \ - || { echo "FAIL: post-race ephemeral bump not observed"; FAIL=1; } - -[[ "$FAIL" == 0 ]] && echo "T1A EVIDENCE: ALL PASS" || { echo "T1A EVIDENCE: FAILURES"; exit 1; } From 06e3d82b04ab326a36694264ffb4b9dd94ec5661 Mon Sep 17 00:00:00 2001 From: Taksh Kothari Date: Thu, 23 Jul 2026 21:04:39 +0530 Subject: [PATCH 003/397] fix(desktop): allow skipping harness setup onboarding (#2360) Signed-off-by: Taksh --- .../features/onboarding/ui/MachineOnboardingFlow.tsx | 9 ++++++++- desktop/src/features/onboarding/ui/SetupStep.tsx | 10 ++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/desktop/src/features/onboarding/ui/MachineOnboardingFlow.tsx b/desktop/src/features/onboarding/ui/MachineOnboardingFlow.tsx index 89c284f237b..e400d07a914 100644 --- a/desktop/src/features/onboarding/ui/MachineOnboardingFlow.tsx +++ b/desktop/src/features/onboarding/ui/MachineOnboardingFlow.tsx @@ -215,7 +215,14 @@ export function MachineOnboardingFlow({ back: () => setPage(identityWasImported ? "key-import" : "backup"), next: (runtimeIds) => { - setReadyRuntimeIds(Array.from(runtimeIds)); + const ids = Array.from(runtimeIds); + setReadyRuntimeIds(ids); + // Harness install can fail (Windows/PATH/network). Don't soft-lock + // onboarding — users can finish setup later in Settings → Agents. + if (ids.length === 0) { + complete(selectedPubkey ?? undefined); + return; + } setPage("config"); }, }} diff --git a/desktop/src/features/onboarding/ui/SetupStep.tsx b/desktop/src/features/onboarding/ui/SetupStep.tsx index 6111589cef0..96e7322d14d 100644 --- a/desktop/src/features/onboarding/ui/SetupStep.tsx +++ b/desktop/src/features/onboarding/ui/SetupStep.tsx @@ -687,6 +687,16 @@ function SetupStepContent({ Next + +