From 8d2ca9b7750d324a2d1fae5d01326f0ff1d4ea48 Mon Sep 17 00:00:00 2001 From: Matthew Date: Mon, 29 Sep 2025 16:00:47 -0500 Subject: [PATCH 1/4] fix: remove panic from stop gap scan loop --- crates/esplora/src/async_ext.rs | 28 +++++++++++++++------------- crates/esplora/src/blocking_ext.rs | 23 +++++++++++------------ 2 files changed, 26 insertions(+), 25 deletions(-) diff --git a/crates/esplora/src/async_ext.rs b/crates/esplora/src/async_ext.rs index c0e55ab507..e73fe733a5 100644 --- a/crates/esplora/src/async_ext.rs +++ b/crates/esplora/src/async_ext.rs @@ -184,10 +184,10 @@ async fn fetch_latest_blocks( client: &esplora_client::AsyncClient, ) -> Result, Error> { Ok(client - .get_blocks(None) + .get_block_infos(None) .await? .into_iter() - .map(|b| (b.time.height, b.id)) + .map(|b| (b.height, b.id)) .collect()) } @@ -314,8 +314,11 @@ where type TxsOfSpkIndex = (u32, Vec, HashSet); let mut update = TxUpdate::::default(); - let mut last_index = Option::::None; let mut last_active_index = Option::::None; + // Use consecutive_unused so unused count drives stop gap. + let mut consecutive_unused = 0usize; + // Treat stop_gap = 0 as 1 while preserving original semantics for other values. + let gap_limit = stop_gap.max(1); loop { let handles = keychain_spks @@ -352,8 +355,10 @@ where } for (index, txs, evicted) in handles.try_collect::>().await? { - last_index = Some(index); - if !txs.is_empty() { + if txs.is_empty() { + consecutive_unused = consecutive_unused.saturating_add(1); + } else { + consecutive_unused = 0; last_active_index = Some(index); } for tx in txs { @@ -368,13 +373,7 @@ where .extend(evicted.into_iter().map(|txid| (txid, start_time))); } - let last_index = last_index.expect("Must be set since handles wasn't empty."); - let gap_limit_reached = if let Some(i) = last_active_index { - last_index >= i.saturating_add(stop_gap as u32) - } else { - last_index + 1 >= stop_gap as u32 - }; - if gap_limit_reached { + if consecutive_unused >= gap_limit { break; } } @@ -599,7 +598,10 @@ mod test { let res = chain_update(&client, &latest_blocks, &cp, &anchors).await; use esplora_client::Error; assert!( - matches!(*res.unwrap_err(), Error::HeaderHashNotFound(hash) if hash == genesis_hash), + matches!( + *res.unwrap_err(), + Error::HeaderHashNotFound(hash) if hash == genesis_hash + ), "`chain_update` should error if it can't connect to the local CP", ); diff --git a/crates/esplora/src/blocking_ext.rs b/crates/esplora/src/blocking_ext.rs index 5a52b7a098..3582ed8896 100644 --- a/crates/esplora/src/blocking_ext.rs +++ b/crates/esplora/src/blocking_ext.rs @@ -170,9 +170,9 @@ fn fetch_latest_blocks( client: &esplora_client::BlockingClient, ) -> Result, Error> { Ok(client - .get_blocks(None)? + .get_block_infos(None)? .into_iter() - .map(|b| (b.time.height, b.id)) + .map(|b| (b.height, b.id)) .collect()) } @@ -282,8 +282,11 @@ fn fetch_txs_with_keychain_spks type TxsOfSpkIndex = (u32, Vec, HashSet); let mut update = TxUpdate::::default(); - let mut last_index = Option::::None; let mut last_active_index = Option::::None; + // Use consecutive_unused so unused count drives stop gap. + let mut consecutive_unused = 0usize; + // Treat stop_gap = 0 as 1 while preserving original semantics for other values. + let gap_limit = stop_gap.max(1); loop { let handles = keychain_spks @@ -321,8 +324,10 @@ fn fetch_txs_with_keychain_spks for handle in handles { let (index, txs, evicted) = handle.join().expect("thread must not panic")?; - last_index = Some(index); - if !txs.is_empty() { + if txs.is_empty() { + consecutive_unused = consecutive_unused.saturating_add(1); + } else { + consecutive_unused = 0; last_active_index = Some(index); } for tx in txs { @@ -337,13 +342,7 @@ fn fetch_txs_with_keychain_spks .extend(evicted.into_iter().map(|txid| (txid, start_time))); } - let last_index = last_index.expect("Must be set since handles wasn't empty."); - let gap_limit_reached = if let Some(i) = last_active_index { - last_index >= i.saturating_add(stop_gap as u32) - } else { - last_index + 1 >= stop_gap as u32 - }; - if gap_limit_reached { + if consecutive_unused >= gap_limit { break; } } From fb3e169e72ea2246ac98ed1b2bf6fec3de663ac4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BF=97=E5=AE=87?= Date: Wed, 11 Mar 2026 10:49:55 +0000 Subject: [PATCH 2/4] ci: Fix pin msrv for 1.75.0 --- .github/workflows/cont_integration.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/cont_integration.yml b/.github/workflows/cont_integration.yml index 9014caf0b9..09b72318a4 100644 --- a/.github/workflows/cont_integration.yml +++ b/.github/workflows/cont_integration.yml @@ -58,6 +58,7 @@ jobs: cargo update -p rayon-core --precise "1.12.1" cargo update -p time --precise "0.3.41" cargo update -p proptest --precise "1.8.0" + cargo update -p "getrandom@0.4.2" --precise "0.2.17" - name: Pin dependencies for MSRV if: matrix.rust.version == '1.63.0' run: ./ci/pin-msrv.sh From af6791f3db090809e2919bc73ab362df7a675c3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BF=97=E5=AE=87?= Date: Wed, 11 Mar 2026 10:31:36 +0000 Subject: [PATCH 3/4] ci: Fix `ci/pin-msrv.sh` --- ci/pin-msrv.sh | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/ci/pin-msrv.sh b/ci/pin-msrv.sh index 418f26b6de..c1319a4023 100755 --- a/ci/pin-msrv.sh +++ b/ci/pin-msrv.sh @@ -3,7 +3,7 @@ set -x set -euo pipefail -# Pin dependencies for MSRV +# Pin dependencies for MSRV (1.63.0) # To pin deps, switch toolchain to MSRV and execute the below updates @@ -17,22 +17,43 @@ cargo update -p proptest --precise "1.2.0" cargo update -p url --precise "2.5.0" cargo update -p tokio --precise "1.38.1" cargo update -p reqwest --precise "0.12.4" +cargo update -p native-tls --precise "0.2.13" cargo update -p security-framework-sys --precise "2.11.1" cargo update -p csv --precise "1.3.0" cargo update -p unicode-width --precise "0.1.13" -cargo update -p native-tls --precise "0.2.13" cargo update -p flate2 --precise "1.0.35" cargo update -p bzip2-sys --precise "0.1.12" cargo update -p ring --precise "0.17.12" cargo update -p once_cell --precise "1.20.3" cargo update -p base64ct --precise "1.6.0" cargo update -p minreq --precise "2.13.2" +cargo update -p tracing --precise "0.1.40" cargo update -p tracing-core --precise "0.1.33" -cargo update -p webpki-roots@1.0.4 --precise "1.0.1" +cargo update -p "webpki-roots@1.0.6" --precise "1.0.1" cargo update -p rayon --precise "1.10.0" cargo update -p rayon-core --precise "1.12.1" -cargo update -p socket2@0.6.1 --precise "0.5.10" cargo update -p quote --precise "1.0.41" cargo update -p syn --precise "2.0.106" cargo update -p openssl --precise "0.10.73" cargo update -p openssl-sys --precise "0.9.109" +cargo update -p "getrandom@0.4.2" --precise "0.2.17" +cargo update -p serde_json --precise "1.0.138" +cargo update -p ryu --precise "1.0.18" +cargo update -p futures --precise "0.3.30" +cargo update -p futures-executor --precise "0.3.31" +cargo update -p futures-util --precise "0.3.31" +cargo update -p futures-macro --precise "0.3.31" +cargo update -p futures-channel --precise "0.3.31" +cargo update -p futures-core --precise "0.3.31" +cargo update -p futures-io --precise "0.3.31" +cargo update -p futures-sink --precise "0.3.31" +cargo update -p futures-task --precise "0.3.31" +cargo update -p proc-macro2 --precise "1.0.92" +cargo update -p log --precise "0.4.22" +cargo update -p itoa --precise "1.0.11" +cargo update -p anyhow --precise "1.0.86" +cargo update -p unicode-ident --precise "1.0.13" +cargo update -p hyper-util --precise "0.1.6" +cargo update -p pin-project --precise "1.1.5" +cargo update -p pin-project-internal --precise "1.1.5" +cargo update -p "rustls@0.23.37" --precise "0.23.26" From 2ee48d7b5199d9a4ef8626b2ff87e124f8897604 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BF=97=E5=AE=87?= Date: Thu, 5 Mar 2026 23:23:14 +0000 Subject: [PATCH 4/4] fix(esplora): Bump `esplora-client` to `0.12.3` This is required for `.get_block_infos` to be available. --- crates/esplora/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/esplora/Cargo.toml b/crates/esplora/Cargo.toml index e4c553f77c..2fc2551a4f 100644 --- a/crates/esplora/Cargo.toml +++ b/crates/esplora/Cargo.toml @@ -16,7 +16,7 @@ workspace = true [dependencies] bdk_core = { path = "../core", version = "0.6.1", default-features = false } -esplora-client = { version = "0.12.1", default-features = false } +esplora-client = { version = "0.12.3", default-features = false } async-trait = { version = "0.1.66", optional = true } futures = { version = "0.3.26", optional = true }