diff --git a/.github/workflows/cont_integration.yml b/.github/workflows/cont_integration.yml index 9014caf0b..09b72318a 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 diff --git a/ci/pin-msrv.sh b/ci/pin-msrv.sh index 418f26b6d..c1319a402 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" diff --git a/crates/esplora/Cargo.toml b/crates/esplora/Cargo.toml index e4c553f77..2fc2551a4 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 } diff --git a/crates/esplora/src/async_ext.rs b/crates/esplora/src/async_ext.rs index c0e55ab50..e73fe733a 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 5a52b7a09..3582ed889 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; } }