Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/cont_integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
29 changes: 25 additions & 4 deletions ci/pin-msrv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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"
2 changes: 1 addition & 1 deletion crates/esplora/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }

Expand Down
28 changes: 15 additions & 13 deletions crates/esplora/src/async_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,10 +184,10 @@ async fn fetch_latest_blocks<S: Sleeper>(
client: &esplora_client::AsyncClient<S>,
) -> Result<BTreeMap<u32, BlockHash>, 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())
}

Expand Down Expand Up @@ -314,8 +314,11 @@ where
type TxsOfSpkIndex = (u32, Vec<esplora_client::Tx>, HashSet<Txid>);

let mut update = TxUpdate::<ConfirmationBlockTime>::default();
let mut last_index = Option::<u32>::None;
let mut last_active_index = Option::<u32>::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
Expand Down Expand Up @@ -352,8 +355,10 @@ where
}

for (index, txs, evicted) in handles.try_collect::<Vec<TxsOfSpkIndex>>().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 {
Expand All @@ -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;
}
}
Expand Down Expand Up @@ -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",
);

Expand Down
23 changes: 11 additions & 12 deletions crates/esplora/src/blocking_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,9 @@ fn fetch_latest_blocks(
client: &esplora_client::BlockingClient,
) -> Result<BTreeMap<u32, BlockHash>, 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())
}

Expand Down Expand Up @@ -282,8 +282,11 @@ fn fetch_txs_with_keychain_spks<I: Iterator<Item = Indexed<SpkWithExpectedTxids>
type TxsOfSpkIndex = (u32, Vec<esplora_client::Tx>, HashSet<Txid>);

let mut update = TxUpdate::<ConfirmationBlockTime>::default();
let mut last_index = Option::<u32>::None;
let mut last_active_index = Option::<u32>::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
Expand Down Expand Up @@ -321,8 +324,10 @@ fn fetch_txs_with_keychain_spks<I: Iterator<Item = Indexed<SpkWithExpectedTxids>

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 {
Expand All @@ -337,13 +342,7 @@ fn fetch_txs_with_keychain_spks<I: Iterator<Item = Indexed<SpkWithExpectedTxids>
.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;
}
}
Expand Down
Loading