From 8d190bacedf80039626397ba87d5b7139cb644e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zoe=20Faltib=C3=A0?= Date: Wed, 18 Dec 2024 15:38:49 +0100 Subject: [PATCH 1/9] fix electrum conftime_req filter for needs_block_height --- src/blockchain/electrum.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/blockchain/electrum.rs b/src/blockchain/electrum.rs index 70e8eca30..5bfd51ef8 100644 --- a/src/blockchain/electrum.rs +++ b/src/blockchain/electrum.rs @@ -168,7 +168,7 @@ impl WalletSync for ElectrumBlockchain { let needs_block_height = conftime_req .request() .filter_map(|txid| txid_to_height.get(txid).cloned()) - .filter(|height| block_times.contains_key(height)) + .filter(|height| !block_times.contains_key(height)) .take(chunk_size) .collect::>(); From 4aa8fba7f0005f27bc4d581891535dabd426ac0c Mon Sep 17 00:00:00 2001 From: Steve Myers Date: Mon, 6 Jan 2025 10:10:05 -0600 Subject: [PATCH 2/9] ci: update examples/rpcwallet to use electrds/bitcoind_22_1 --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 95a503bab..4e33f6adb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -130,7 +130,7 @@ path = "examples/policy.rs" [[example]] name = "rpcwallet" path = "examples/rpcwallet.rs" -required-features = ["keys-bip39", "key-value-db", "rpc", "electrsd/bitcoind_22_0"] +required-features = ["keys-bip39", "key-value-db", "rpc", "electrsd/bitcoind_22_1"] [[example]] name = "psbt_signer" From 24ec31bf66ec3a3788f96e8941c203a1e198af81 Mon Sep 17 00:00:00 2001 From: Steve Myers Date: Mon, 6 Jan 2025 10:19:41 -0600 Subject: [PATCH 3/9] ci(clippy): fix new stricter needless_lifetime errors for rust 1.83 https://rust-lang.github.io/rust-clippy/master/index.html#needless_lifetimes rust-lang/rust-clippy#13286 --- examples/policy.rs | 1 - src/descriptor/mod.rs | 4 +--- src/wallet/tx_builder.rs | 6 +++--- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/examples/policy.rs b/examples/policy.rs index 64e17825b..1dcd38987 100644 --- a/examples/policy.rs +++ b/examples/policy.rs @@ -27,7 +27,6 @@ use bdk::wallet::signer::SignersContainer; /// /// This example demos a Policy output for a 2of2 multisig between between 2 parties, where the wallet holds /// one of the Extend Private key. - fn main() -> Result<(), Box> { env_logger::init_from_env( env_logger::Env::default().filter_or(env_logger::DEFAULT_FILTER_ENV, "info"), diff --git a/src/descriptor/mod.rs b/src/descriptor/mod.rs index dfb7bcc5f..17c5800dc 100644 --- a/src/descriptor/mod.rs +++ b/src/descriptor/mod.rs @@ -134,9 +134,7 @@ impl IntoWalletDescriptor for (ExtendedDescriptor, KeyMap) { network: Network, } - impl<'s, 'd> miniscript::Translator - for Translator<'s, 'd> - { + impl miniscript::Translator for Translator<'_, '_> { fn pk(&mut self, pk: &DescriptorPublicKey) -> Result { let secp = &self.secp; diff --git a/src/wallet/tx_builder.rs b/src/wallet/tx_builder.rs index 9ce101217..cdbcee0a4 100644 --- a/src/wallet/tx_builder.rs +++ b/src/wallet/tx_builder.rs @@ -167,7 +167,7 @@ impl std::default::Default for FeePolicy { } } -impl<'a, Cs: Clone, Ctx, D> Clone for TxBuilder<'a, D, Cs, Ctx> { +impl Clone for TxBuilder<'_, D, Cs, Ctx> { fn clone(&self) -> Self { TxBuilder { wallet: self.wallet, @@ -584,7 +584,7 @@ impl<'a, D: BatchDatabase, Cs: CoinSelectionAlgorithm, Ctx: TxBuilderContext> } } -impl<'a, D: BatchDatabase, Cs: CoinSelectionAlgorithm> TxBuilder<'a, D, Cs, CreateTx> { +impl> TxBuilder<'_, D, Cs, CreateTx> { /// Replace the recipients already added with a new list pub fn set_recipients(&mut self, recipients: Vec<(ScriptBuf, u64)>) -> &mut Self { self.params.recipients = recipients; @@ -658,7 +658,7 @@ impl<'a, D: BatchDatabase, Cs: CoinSelectionAlgorithm> TxBuilder<'a, D, Cs, C } // methods supported only by bump_fee -impl<'a, D: BatchDatabase> TxBuilder<'a, D, DefaultCoinSelectionAlgorithm, BumpFee> { +impl TxBuilder<'_, D, DefaultCoinSelectionAlgorithm, BumpFee> { /// Explicitly tells the wallet that it is allowed to reduce the amount of the output matching this /// `script_pubkey` in order to bump the transaction fee. Without specifying this the wallet /// will attempt to find a change output to shrink instead. From 341b86986bbc3f57264d658b3343fd714d6ecbe3 Mon Sep 17 00:00:00 2001 From: Steve Myers Date: Mon, 6 Jan 2025 10:22:04 -0600 Subject: [PATCH 4/9] ci(clippy): fix updated ptr_arg check for rust 1.83 https://rust-lang.github.io/rust-clippy/master/index.html#ptr_arg rust-lang/rust-clippy#13313 --- src/wallet/coin_selection.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/coin_selection.rs b/src/wallet/coin_selection.rs index 8eaf31121..e85e24443 100644 --- a/src/wallet/coin_selection.rs +++ b/src/wallet/coin_selection.rs @@ -868,7 +868,7 @@ mod test { vec![utxo; utxos_number] } - fn sum_random_utxos(mut rng: &mut StdRng, utxos: &mut Vec) -> u64 { + fn sum_random_utxos(mut rng: &mut StdRng, utxos: &mut [WeightedUtxo]) -> u64 { let utxos_picked_len = rng.gen_range(2..utxos.len() / 2); utxos.shuffle(&mut rng); utxos[..utxos_picked_len] From 6a5b418f6c88127bd9af22f18d859bafd6403d8c Mon Sep 17 00:00:00 2001 From: Steve Myers Date: Mon, 6 Jan 2025 10:42:16 -0600 Subject: [PATCH 5/9] ci(clippy): fix missing docs errors for rust 1.83 --- examples/compiler.rs | 1 - src/database/mod.rs | 1 + src/keys/mod.rs | 2 +- src/wallet/coin_selection.rs | 5 ++++- 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/examples/compiler.rs b/examples/compiler.rs index e17feb3ad..2773545ee 100644 --- a/examples/compiler.rs +++ b/examples/compiler.rs @@ -35,7 +35,6 @@ use bdk::{KeychainKind, Wallet}; /// can be derived from the policy. /// /// This example demonstrates the interaction between a bdk wallet and miniscript policy. - fn main() -> Result<(), Box> { env_logger::init_from_env( env_logger::Env::default().filter_or(env_logger::DEFAULT_FILTER_ENV, "info"), diff --git a/src/database/mod.rs b/src/database/mod.rs index 27d6e4dbf..134cb6b77 100644 --- a/src/database/mod.rs +++ b/src/database/mod.rs @@ -214,6 +214,7 @@ pub(crate) trait DatabaseUtils: Database { impl DatabaseUtils for T {} #[cfg(test)] +#[allow(missing_docs)] pub mod test { use bitcoin::consensus::encode::deserialize; use bitcoin::consensus::serialize; diff --git a/src/keys/mod.rs b/src/keys/mod.rs index 140f7dfdc..ac7ff57aa 100644 --- a/src/keys/mod.rs +++ b/src/keys/mod.rs @@ -949,7 +949,7 @@ impl std::fmt::Display for KeyError { impl std::error::Error for KeyError {} #[cfg(test)] -pub mod test { +mod test { use bitcoin::bip32; use super::*; diff --git a/src/wallet/coin_selection.rs b/src/wallet/coin_selection.rs index e85e24443..0d35f7e10 100644 --- a/src/wallet/coin_selection.rs +++ b/src/wallet/coin_selection.rs @@ -119,8 +119,11 @@ use std::convert::TryInto; /// overridden #[cfg(not(test))] pub type DefaultCoinSelectionAlgorithm = BranchAndBoundCoinSelection; + +/// Default deterministic coin selection algorithm for testing used by [`TxBuilder`](super::tx_builder::TxBuilder) if not +/// overridden #[cfg(test)] -pub type DefaultCoinSelectionAlgorithm = LargestFirstCoinSelection; // make the tests more predictable +pub type DefaultCoinSelectionAlgorithm = LargestFirstCoinSelection; // Base weight of a Txin, not counting the weight needed for satisfying it. // prev_txid (32 bytes) + prev_vout (4 bytes) + sequence (4 bytes) From fa53884d214f47d5f64a95e5e1282b3bbfc3aca5 Mon Sep 17 00:00:00 2001 From: Steve Myers Date: Mon, 6 Jan 2025 11:29:17 -0600 Subject: [PATCH 6/9] ci: pin msrv dep version for rustls and hashbrown --- .github/workflows/cont_integration.yml | 4 ++-- .github/workflows/nightly_docs.yml | 4 +++- README.md | 4 ++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/.github/workflows/cont_integration.yml b/.github/workflows/cont_integration.yml index a7f12c393..bb9234097 100644 --- a/.github/workflows/cont_integration.yml +++ b/.github/workflows/cont_integration.yml @@ -64,8 +64,8 @@ jobs: cargo update -p regex --precise "1.7.3" cargo update -p security-framework-sys --precise "2.11.1" cargo update -p url --precise "2.5.0" - cargo update -p rustls@0.23.18 --precise "0.23.17" - cargo update -p hashbrown@0.15.1 --precise "0.15.0" + cargo update -p rustls@0.23.20 --precise "0.23.19" + cargo update -p hashbrown@0.15.2 --precise "0.15.0" - name: Build run: cargo build --features bitcoin/std,miniscript/std,${{ matrix.features }} --no-default-features - name: Clippy diff --git a/.github/workflows/nightly_docs.yml b/.github/workflows/nightly_docs.yml index 1156c9dcf..9eef21ce8 100644 --- a/.github/workflows/nightly_docs.yml +++ b/.github/workflows/nightly_docs.yml @@ -28,7 +28,9 @@ jobs: - name: Install Rust toolchain uses: dtolnay/rust-toolchain@nightly with: - components: clippy + components: clippy, rustfmt + - name: Cargo update + run: cargo update - name: Build docs run: cargo rustdoc --verbose --features=compiler,electrum,esplora,use-esplora-blocking,compact_filters,rpc,key-value-db,sqlite,all-keys,verify,hardware-signer -- --cfg docsrs -Dwarnings - name: Upload artifact diff --git a/README.md b/README.md index 1e68f70ff..2a33ec1a6 100644 --- a/README.md +++ b/README.md @@ -215,6 +215,6 @@ cargo update -p home --precise "0.5.5" cargo update -p regex --precise "1.7.3" cargo update -p security-framework-sys --precise "2.11.1" cargo update -p url --precise "2.5.0" -cargo update -p rustls@0.23.18 --precise "0.23.17" -cargo update -p hashbrown@0.15.1 --precise "0.15.0" +cargo update -p rustls@0.23.20 --precise "0.23.19" +cargo update -p hashbrown@0.15.2 --precise "0.15.0" ``` From f2e163206483dd0a6d19f339247ea963c64f4824 Mon Sep 17 00:00:00 2001 From: Steve Myers Date: Mon, 6 Jan 2025 13:23:15 -0600 Subject: [PATCH 7/9] ci: pin msrv dep version for ureq --- .github/workflows/cont_integration.yml | 1 + README.md | 1 + 2 files changed, 2 insertions(+) diff --git a/.github/workflows/cont_integration.yml b/.github/workflows/cont_integration.yml index bb9234097..e1472f91c 100644 --- a/.github/workflows/cont_integration.yml +++ b/.github/workflows/cont_integration.yml @@ -66,6 +66,7 @@ jobs: cargo update -p url --precise "2.5.0" cargo update -p rustls@0.23.20 --precise "0.23.19" cargo update -p hashbrown@0.15.2 --precise "0.15.0" + cargo update -p ureq --precise "2.10.1" - name: Build run: cargo build --features bitcoin/std,miniscript/std,${{ matrix.features }} --no-default-features - name: Clippy diff --git a/README.md b/README.md index 2a33ec1a6..446166f3c 100644 --- a/README.md +++ b/README.md @@ -217,4 +217,5 @@ cargo update -p security-framework-sys --precise "2.11.1" cargo update -p url --precise "2.5.0" cargo update -p rustls@0.23.20 --precise "0.23.19" cargo update -p hashbrown@0.15.2 --precise "0.15.0" +cargo update -p ureq --precise "2.10.1" ``` From 53fb49fd009d8634f96a231a29394c64aa93bf9c Mon Sep 17 00:00:00 2001 From: Steve Myers Date: Mon, 6 Jan 2025 14:08:43 -0600 Subject: [PATCH 8/9] ci(clippy): fix disallow ref to static mut https://doc.rust-lang.org/nightly/edition-guide/rust-2024/static-mut-references.html --- src/database/keyvalue.rs | 43 ++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/src/database/keyvalue.rs b/src/database/keyvalue.rs index 7c20b2194..6087fa670 100644 --- a/src/database/keyvalue.rs +++ b/src/database/keyvalue.rs @@ -405,12 +405,13 @@ impl BatchDatabase for Tree { #[cfg(test)] mod test { use lazy_static::lazy_static; + use std::sync::atomic::{AtomicUsize, Ordering}; use std::sync::{Arc, Condvar, Mutex, Once}; use std::time::{SystemTime, UNIX_EPOCH}; use sled::{Db, Tree}; - static mut COUNT: usize = 0; + static COUNT: AtomicUsize = AtomicUsize::new(0); lazy_static! { static ref DB: Arc<(Mutex>, Condvar)> = @@ -419,33 +420,31 @@ mod test { } fn get_tree() -> Tree { - unsafe { - let cloned = DB.clone(); - let (mutex, cvar) = &*cloned; + let cloned = DB.clone(); + let (mutex, cvar) = &*cloned; - INIT.call_once(|| { - let mut db = mutex.lock().unwrap(); + INIT.call_once(|| { + let mut db = mutex.lock().unwrap(); - let time = SystemTime::now().duration_since(UNIX_EPOCH).unwrap(); - let mut dir = std::env::temp_dir(); - dir.push(format!("mbw_{}", time.as_nanos())); + let time = SystemTime::now().duration_since(UNIX_EPOCH).unwrap(); + let mut dir = std::env::temp_dir(); + dir.push(format!("mbw_{}", time.as_nanos())); - *db = Some(sled::open(dir).unwrap()); - cvar.notify_all(); - }); + *db = Some(sled::open(dir).unwrap()); + cvar.notify_all(); + }); - let mut db = mutex.lock().unwrap(); - while !db.is_some() { - db = cvar.wait(db).unwrap(); - } + let mut db = mutex.lock().unwrap(); + while !db.is_some() { + db = cvar.wait(db).unwrap(); + } - COUNT += 1; + COUNT.fetch_add(1, Ordering::Relaxed); - db.as_ref() - .unwrap() - .open_tree(format!("tree_{}", COUNT)) - .unwrap() - } + db.as_ref() + .unwrap() + .open_tree(format!("tree_{}", COUNT.load(Ordering::Relaxed))) + .unwrap() } #[test] From 20100aabd54d507e01894993829b2968cee10f25 Mon Sep 17 00:00:00 2001 From: Steve Myers Date: Mon, 6 Jan 2025 14:18:08 -0600 Subject: [PATCH 9/9] ci: downgrade all workflows to ubuntu to 20.04 --- .github/workflows/code_coverage.yml | 2 +- .github/workflows/cont_integration.yml | 6 +++--- .github/workflows/nightly_docs.yml | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/code_coverage.yml b/.github/workflows/code_coverage.yml index 52bfb1ac1..5be04684b 100644 --- a/.github/workflows/code_coverage.yml +++ b/.github/workflows/code_coverage.yml @@ -14,7 +14,7 @@ jobs: Codecov: name: Code Coverage if: false # disabled - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 env: RUSTFLAGS: "-Cinstrument-coverage" RUSTDOCFLAGS: "-Cinstrument-coverage" diff --git a/.github/workflows/cont_integration.yml b/.github/workflows/cont_integration.yml index e1472f91c..605997c30 100644 --- a/.github/workflows/cont_integration.yml +++ b/.github/workflows/cont_integration.yml @@ -14,7 +14,7 @@ jobs: build-test: name: Build and test - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 strategy: matrix: rust: @@ -77,7 +77,7 @@ jobs: test-readme-examples: name: Test README.md examples - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 steps: - name: checkout uses: actions/checkout@v4 @@ -167,7 +167,7 @@ jobs: fmt: name: Rust fmt - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 steps: - name: Checkout uses: actions/checkout@v4 diff --git a/.github/workflows/nightly_docs.yml b/.github/workflows/nightly_docs.yml index 9eef21ce8..9301dad16 100644 --- a/.github/workflows/nightly_docs.yml +++ b/.github/workflows/nightly_docs.yml @@ -13,7 +13,7 @@ on: jobs: build_docs: name: Build docs - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 steps: - name: Checkout sources uses: actions/checkout@v4 @@ -43,7 +43,7 @@ jobs: name: 'Publish docs' if: github.ref == 'refs/heads/master' needs: [build_docs] - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 steps: - name: Checkout `bitcoindevkit.org` uses: actions/checkout@v4