From a6db301b8b05017c7c867d102c270add95fb2456 Mon Sep 17 00:00:00 2001 From: PastaClaw Date: Sun, 22 Feb 2026 11:16:35 -0600 Subject: [PATCH 1/2] fix: add 30-second timeout to SPV quorum public key lookup Wrap the quorum public key lookup in a 30-second timeout to prevent indefinite hangs when the SPV client is unresponsive or the network request stalls. Returns a clear timeout error message with context. Cherry-picked from ralph/improvements (commit 9c179886). --- src/spv/manager.rs | 56 ++++++++++++++++++++++++++++------------------ 1 file changed, 34 insertions(+), 22 deletions(-) diff --git a/src/spv/manager.rs b/src/spv/manager.rs index a2e9ddcd3..6e917cabc 100644 --- a/src/spv/manager.rs +++ b/src/spv/manager.rs @@ -643,28 +643,40 @@ impl SpvManager { tokio::task::block_in_place(|| { tokio::runtime::Handle::current().block_on(async { - interface - .get_quorum_by_height(core_chain_locked_height, llmq_type, qh) - .await - .map(|q| { - tracing::debug!( - "Quorum public key found: type={}, hash={}, height={}", - quorum_type, - hex::encode(quorum_hash), - core_chain_locked_height - ); - *q.quorum_entry.quorum_public_key.as_ref() - }) - .map_err(|e| { - tracing::warn!( - "Quorum lookup failed at height {} for llmq_type={} hash=0x{}: {}", - core_chain_locked_height, - quorum_type, - hex::encode(quorum_hash), - e - ); - e.to_string() - }) + tokio::time::timeout( + std::time::Duration::from_secs(30), + interface.get_quorum_by_height(core_chain_locked_height, llmq_type, qh), + ) + .await + .map_err(|_| { + let msg = format!( + "Quorum lookup timed out after 30s at height {} for llmq_type={} hash=0x{}", + core_chain_locked_height, + quorum_type, + hex::encode(quorum_hash), + ); + tracing::warn!("{}", msg); + msg + })? + .map(|q| { + tracing::debug!( + "Quorum public key found: type={}, hash={}, height={}", + quorum_type, + hex::encode(quorum_hash), + core_chain_locked_height + ); + *q.quorum_entry.quorum_public_key.as_ref() + }) + .map_err(|e| { + tracing::warn!( + "Quorum lookup failed at height {} for llmq_type={} hash=0x{}: {}", + core_chain_locked_height, + quorum_type, + hex::encode(quorum_hash), + e + ); + e.to_string() + }) }) }) } From f5993b832ffa4a2be99498f04211cb15a9640e2b Mon Sep 17 00:00:00 2001 From: PastaClaw Date: Mon, 23 Feb 2026 19:16:25 -0600 Subject: [PATCH 2/2] fix(spv): use tracing formatting in quorum timeout warning --- src/spv/manager.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/spv/manager.rs b/src/spv/manager.rs index 6e917cabc..3ccd5a191 100644 --- a/src/spv/manager.rs +++ b/src/spv/manager.rs @@ -649,14 +649,18 @@ impl SpvManager { ) .await .map_err(|_| { - let msg = format!( + tracing::warn!( "Quorum lookup timed out after 30s at height {} for llmq_type={} hash=0x{}", core_chain_locked_height, quorum_type, hex::encode(quorum_hash), ); - tracing::warn!("{}", msg); - msg + format!( + "Quorum lookup timed out after 30s at height {} for llmq_type={} hash=0x{}", + core_chain_locked_height, + quorum_type, + hex::encode(quorum_hash), + ) })? .map(|q| { tracing::debug!(