From 117221e9eed92fd197822b82a25de094b79cfafd Mon Sep 17 00:00:00 2001 From: Antoine Poinsot Date: Tue, 27 Jun 2023 17:01:27 +0200 Subject: [PATCH 1/7] Bump lianad MSRV to 1.54 Now that the latest Debian stable was released with 1.63. --- .github/workflows/main.yml | 5 ++--- CONTRIBUTING.md | 6 +++++- doc/BUILD.md | 5 +---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d4e5a32c..d612e9fb 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -22,7 +22,7 @@ jobs: strategy: matrix: toolchain: - - 1.48 + - 1.54 - nightly os: - ubuntu-latest @@ -42,8 +42,7 @@ jobs: if: matrix.os == 'windows-latest' run: cargo test --verbose --no-default-features - name: Test on Rust ${{ matrix.toolchain }} (non Windows) - # See issue https://github.com/wizardsardine/liana/issues/69 - if: matrix.os != 'windows-latest' && (matrix.os != 'macOS-latest' || matrix.toolchain != '1.48') + if: matrix.os != 'windows-latest' run: cargo test --verbose --color always -- --nocapture linter_gui: diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 228df938..412a5809 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -66,7 +66,11 @@ query). ## Minimum Supported Rust Version -`lianad` should always compile and pass tests using **Rust 1.48**. +`lianad` should always compile and pass tests using **Rust 1.54**. The rationale behind this is +support something reasonable, and preferably supported by all of: +- [Guix](https://guix.gnu.org/) +- Popular distributions' packages (especially Debian which is the most conservative) +- [Mrustc](https://github.com/thepowersgang/mrustc) ## Style diff --git a/doc/BUILD.md b/doc/BUILD.md index 214274bd..98fcc3cf 100644 --- a/doc/BUILD.md +++ b/doc/BUILD.md @@ -8,10 +8,7 @@ this repository. They are pinned in a [`Cargo.lock`](../Cargo.lock) file at the We take security very seriously, and toolchain is a big part of that. We are moderatly conservative with dependencies and aim to target reasonable compiler versions that have had time to mature (ie that had the chance to be reviewed and distributed by third parties, as well as tested by the -community). The minimum supported Rust version for `lianad` currently is `1.48`, that is the -version of [`rustc` shipped in Debian stable](https://packages.debian.org/stable/rustc). (It is also -inferior to the latest version of `rustc` supported by -[`mrustc`](https://github.com/thepowersgang/mrustc/) at the time of writing, `1.54`). +community). The minimum supported Rust version for `lianad` currently is `1.54`. If you want to not only build the daemon but the whole wallet including the GUI, you'll unfortunately have to use a more recent `cargo`. The minimum version supported by the GUI at the From b2f95ada585fb04c3d82d9419d33affebd9eaccc Mon Sep 17 00:00:00 2001 From: Antoine Poinsot Date: Tue, 27 Jun 2023 17:17:47 +0200 Subject: [PATCH 2/7] commands: take advantage of 1.48 compat riddance --- src/commands/mod.rs | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/src/commands/mod.rs b/src/commands/mod.rs index 37c6486e..f125bf70 100644 --- a/src/commands/mod.rs +++ b/src/commands/mod.rs @@ -293,12 +293,10 @@ impl DaemonControl { /// Get a list of all known coins. pub fn list_coins(&self) -> ListCoinsResult { let mut db_conn = self.db.connection(); - #[allow(clippy::iter_kv_map)] // Because Rust 1.48 let coins: Vec = db_conn .coins(CoinType::All) - // Can't use into_values as of Rust 1.48 - .into_iter() - .map(|(_, coin)| { + .into_values() + .map(|coin| { let Coin { amount, outpoint, @@ -728,15 +726,12 @@ impl DaemonControl { let timelock = timelock.unwrap_or_else(|| self.config.main_descriptor.first_timelock_value()); let height_delta: i32 = timelock.try_into().expect("Must fit, it's a u16"); - let sweepable_coins = db_conn - .coins(CoinType::Unspent) - .into_iter() - .filter(|(_, c)| { - // We are interested in coins available at the *next* block - c.block_info - .map(|b| current_height + 1 >= b.height + height_delta) - .unwrap_or(false) - }); + let sweepable_coins = db_conn.coins(CoinType::Unspent).into_values().filter(|c| { + // We are interested in coins available at the *next* block + c.block_info + .map(|b| current_height + 1 >= b.height + height_delta) + .unwrap_or(false) + }); // Fill-in the transaction inputs and PSBT inputs information. Record the value // that is fed to the transaction while doing so, to compute the fees afterward. @@ -744,7 +739,7 @@ impl DaemonControl { let txin_sat_vb = self.config.main_descriptor.max_sat_vbytes(); let mut sat_vb = 0; let mut spent_txs = HashMap::new(); - for (_, coin) in sweepable_coins { + for coin in sweepable_coins { in_value += coin.amount; psbt.unsigned_tx.input.push(bitcoin::TxIn { previous_output: coin.outpoint, From c20c05cee7b25fe6bc9a638b48a14a4430185edc Mon Sep 17 00:00:00 2001 From: Antoine Poinsot Date: Tue, 27 Jun 2023 17:21:09 +0200 Subject: [PATCH 3/7] ci: upgrade lianad clippy to 1.70 --- .github/workflows/main.yml | 2 +- src/bitcoin/d/mod.rs | 7 ++++--- src/bitcoin/mod.rs | 7 ++++--- src/database/mod.rs | 7 ++++--- src/database/sqlite/mod.rs | 17 +++++++++-------- 5 files changed, 22 insertions(+), 18 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d612e9fb..9005cff6 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -9,7 +9,7 @@ jobs: - uses: actions/checkout@v1 - uses: actions-rs/toolchain@v1 with: - toolchain: 1.67.1 + toolchain: 1.70.0 components: rustfmt, clippy override: true - name: rustfmt diff --git a/src/bitcoin/d/mod.rs b/src/bitcoin/d/mod.rs index e3ef8b3d..8ed12a0a 100644 --- a/src/bitcoin/d/mod.rs +++ b/src/bitcoin/d/mod.rs @@ -1,6 +1,7 @@ -///! Implementation of the Bitcoin interface using bitcoind. -///! -///! We use the RPC interface and a watchonly descriptor wallet. +//! Implementation of the Bitcoin interface using bitcoind. +//! +//! We use the RPC interface and a watchonly descriptor wallet. + mod utils; use crate::{ bitcoin::{Block, BlockChainTip}, diff --git a/src/bitcoin/mod.rs b/src/bitcoin/mod.rs index 9aa2732e..2c9e5e7b 100644 --- a/src/bitcoin/mod.rs +++ b/src/bitcoin/mod.rs @@ -1,6 +1,7 @@ -///! Interface to the Bitcoin network. -///! -///! Broadcast transactions, poll for new unspent coins, gather fee estimates. +//! Interface to the Bitcoin network. +//! +//! Broadcast transactions, poll for new unspent coins, gather fee estimates. + pub mod d; pub mod poller; diff --git a/src/database/mod.rs b/src/database/mod.rs index 699cd5d8..dd08ede0 100644 --- a/src/database/mod.rs +++ b/src/database/mod.rs @@ -1,6 +1,7 @@ -///! Database interface for Liana. -///! -///! Record wallet metadata, spent and unspent coins, ongoing transactions. +//! Database interface for Liana. +//! +//! Record wallet metadata, spent and unspent coins, ongoing transactions. + pub mod sqlite; use crate::{ diff --git a/src/database/sqlite/mod.rs b/src/database/sqlite/mod.rs index dd0ede38..523fc7a2 100644 --- a/src/database/sqlite/mod.rs +++ b/src/database/sqlite/mod.rs @@ -1,11 +1,12 @@ -///! Implementation of the database interface using SQLite. -///! -///! We use a bundled SQLite that is compiled with SQLITE_THREADSAFE. Sqlite.org states: -///! > Multi-thread. In this mode, SQLite can be safely used by multiple threads provided that -///! > no single database connection is used simultaneously in two or more threads. -///! -///! We leverage SQLite's `unlock_notify` feature to synchronize writes accross connection. More -///! about it at https://sqlite.org/unlock_notify.html. +//! Implementation of the database interface using SQLite. +//! +//! We use a bundled SQLite that is compiled with SQLITE_THREADSAFE. Sqlite.org states: +//! > Multi-thread. In this mode, SQLite can be safely used by multiple threads provided that +//! > no single database connection is used simultaneously in two or more threads. +//! +//! We leverage SQLite's `unlock_notify` feature to synchronize writes accross connection. More +//! about it at https://sqlite.org/unlock_notify.html. + pub mod schema; mod utils; From 5d7a1b4fe5de2a1247f3f0445a87c575e71b129f Mon Sep 17 00:00:00 2001 From: Antoine Poinsot Date: Wed, 28 Jun 2023 10:39:14 +0200 Subject: [PATCH 4/7] Update serde dependencies --- Cargo.lock | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9a76c036..12d8682f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -411,18 +411,18 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.145" +version = "1.0.147" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "728eb6351430bccb993660dfffc5a72f91ccc1295abaa8ce19b27ebe4f75568b" +checksum = "d193d69bae983fc11a79df82342761dfbf28a99fc8d203dca4c3c1b590948965" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.145" +version = "1.0.147" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81fa1584d3d1bcacd84c277a0dfe21f5b0f6accf4a23d04d4c6d61f1af522b4c" +checksum = "4f1d362ca8fc9c3e3a7484440752472d68a6caa98f1ab81d99b5dfe517cec852" dependencies = [ "proc-macro2", "quote", @@ -431,9 +431,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.87" +version = "1.0.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ce777b7b150d76b9cf60d28b55f5847135a003f7d7350c6be7a773508ce7d45" +checksum = "46266871c240a00b8f503b877622fe33430b3c7d963bdc0f2adc511e54a1eae3" dependencies = [ "itoa", "ryu", From 1271b646fb87b5d45bd001c616dda4ee1dd37bed Mon Sep 17 00:00:00 2001 From: Antoine Poinsot Date: Wed, 28 Jun 2023 10:43:30 +0200 Subject: [PATCH 5/7] Update backtrace dependency --- Cargo.lock | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 12d8682f..fa54d838 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,9 +4,9 @@ version = 3 [[package]] name = "addr2line" -version = "0.17.0" +version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9ecd88a8c8378ca913a680cd98f0f13ac67383d35993f86c90a70e3f137816b" +checksum = "a76fd60b23679b7d19bd066031410fb7e458ccc5e958eb5c325888ce4baedc97" dependencies = [ "gimli", ] @@ -30,9 +30,9 @@ dependencies = [ [[package]] name = "backtrace" -version = "0.3.66" +version = "0.3.67" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cab84319d616cfb654d03394f38ab7e6f0919e181b1b57e1fd15e7fb4077d9a7" +checksum = "233d376d6d185f2a3093e58f283f60f880315b6c60075b01f36b3b85154564ca" dependencies = [ "addr2line", "cc", @@ -174,9 +174,9 @@ dependencies = [ [[package]] name = "gimli" -version = "0.26.2" +version = "0.27.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22030e2c5a68ec659fde1e949a745124b48e6fa8b045b7ed5bd1fe4ccc5c4e5d" +checksum = "b6c80984affa11d98d1b88b66ac8853f143217b399d3c74116778ff8fdb4ed2e" [[package]] name = "hashbrown" @@ -278,18 +278,18 @@ dependencies = [ [[package]] name = "miniz_oxide" -version = "0.5.4" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96590ba8f175222643a85693f33d26e9c8a015f599c216509b1a6894af675d34" +checksum = "b275950c28b37e794e8c55d88aeb5e139d0ce23fdbbeda68f8d7174abdf9e8fa" dependencies = [ "adler", ] [[package]] name = "object" -version = "0.29.0" +version = "0.30.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21158b2c33aa6d4561f1c0a6ea283ca92bc54802a93b263e910746d679a7eb53" +checksum = "03b4680b86d9cfafba8fc491dc9b6df26b68cf40e9e6cd73909194759a63c385" dependencies = [ "memchr", ] From 9b17d7029ff6e80eb177bf8d04efb85cdefa21ef Mon Sep 17 00:00:00 2001 From: Antoine Poinsot Date: Wed, 28 Jun 2023 11:01:29 +0200 Subject: [PATCH 6/7] Update rusqlite to 0.27 The release is >1yo but they keep breaking the MSRV so we can't get the fixes without upgrading to a bleeding edge compiler... This upgrades the bundled SQLite to version 3.38, which had quite some patch releases but no issue that should be relevant to us. https://sqlite.org/releaselog/3_38_0.html Full rusqlite changelog available here: https://github.com/rusqlite/rusqlite/releases/tag/v0.27.0. --- Cargo.lock | 8 ++++---- Cargo.toml | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fa54d838..1e010e04 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -243,9 +243,9 @@ checksum = "99227334921fae1a979cf0bfdfcc6b3e5ce376ef57e16fb6fb3ea2ed6095f80c" [[package]] name = "libsqlite3-sys" -version = "0.23.0" +version = "0.24.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4ecc4273169aeb654a26ba8c7e087947caad92c9d121886eafa6446d4ebe138" +checksum = "898745e570c7d0453cc1fbc4a701eb6c662ed54e8fec8b7d14be137ebeeb9d14" dependencies = [ "cc", "pkg-config", @@ -364,9 +364,9 @@ dependencies = [ [[package]] name = "rusqlite" -version = "0.26.3" +version = "0.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ba4d3462c8b2e4d7f4fcfcf2b296dc6b65404fbbc7b63daa37fd485c149daf7" +checksum = "85127183a999f7db96d1a976a309eebbfb6ea3b0b400ddd8340190129de6eb7a" dependencies = [ "bitflags", "fallible-iterator", diff --git a/Cargo.toml b/Cargo.toml index 7cda4520..155524d7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -44,9 +44,9 @@ fern = "0.6" # to work with our custom panic hook. backtrace = "0.3" -# Pinned to this version because they broke the MSRV in 0.27... +# Pinned to this version because they keep breaking their MSRV in point releases... # FIXME: this is unfortunate, we don't receive the updates (sometimes critical) from SQLite. -rusqlite = { version = "0.26.3", features = ["bundled", "unlock_notify"] } +rusqlite = { version = "0.27", features = ["bundled", "unlock_notify"] } # To talk to bitcoind jsonrpc = "0.12" From b53236f9dd29e36a7c31dc8cbe138204e4674a71 Mon Sep 17 00:00:00 2001 From: Antoine Poinsot Date: Wed, 28 Jun 2023 11:17:00 +0200 Subject: [PATCH 7/7] Update libc wrapper and getrandom For getrandom it's mostly updates to support new platforms, but also an added fallback when one system RNG isn't available on some platforms. See https://github.com/rust-random/getrandom/blob/master/CHANGELOG.md --- Cargo.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1e010e04..337e954a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -163,9 +163,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.8" +version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31" +checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427" dependencies = [ "cfg-if", "libc", @@ -237,9 +237,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.140" +version = "0.2.147" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99227334921fae1a979cf0bfdfcc6b3e5ce376ef57e16fb6fb3ea2ed6095f80c" +checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" [[package]] name = "libsqlite3-sys"