From 8fa171c01a9848e22db43b68d9d1a34dae2fccec Mon Sep 17 00:00:00 2001 From: Tommy Volk Date: Mon, 4 Nov 2024 21:51:36 -0600 Subject: [PATCH] chore(deps): bump esplora-client to v0.10 --- Cargo.lock | 223 +++++++++++++++++++++--- Cargo.toml | 3 +- devimint/src/external.rs | 8 +- fedimint-bitcoind/src/esplora.rs | 52 +++--- gateway/ln-gateway/src/lightning/ldk.rs | 5 +- 5 files changed, 224 insertions(+), 67 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 95bed4b9a30..54b16dfacd6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -286,6 +286,17 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b34d609dfbaf33d6889b2b7106d3ca345eacad44200913df5ba02bfd31d2ba9" +[[package]] +name = "async-channel" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81953c529336010edd6d8e358f886d9581267795c61b19475b71314bffa46d35" +dependencies = [ + "concurrent-queue", + "event-listener 2.5.3", + "futures-core", +] + [[package]] name = "async-channel" version = "2.3.1" @@ -311,13 +322,60 @@ dependencies = [ "pin-project-lite", ] +[[package]] +name = "async-executor" +version = "1.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30ca9a001c1e8ba5149f91a74362376cc6bc5b919d92d988668657bd570bdcec" +dependencies = [ + "async-task", + "concurrent-queue", + "fastrand", + "futures-lite", + "slab", +] + +[[package]] +name = "async-global-executor" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05b1b633a2115cd122d73b955eadd9916c18c8f510ec9cd1686404c60ad1c29c" +dependencies = [ + "async-channel 2.3.1", + "async-executor", + "async-io", + "async-lock", + "blocking", + "futures-lite", + "once_cell", +] + +[[package]] +name = "async-io" +version = "2.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "444b0228950ee6501b3568d3c93bf1176a1fdbc3b758dcd9475046d30f4dc7e8" +dependencies = [ + "async-lock", + "cfg-if", + "concurrent-queue", + "futures-io", + "futures-lite", + "parking", + "polling", + "rustix", + "slab", + "tracing", + "windows-sys 0.59.0", +] + [[package]] name = "async-lock" version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ff6e472cdea888a4bd64f342f09b3f50e1886d32afe8df3d663c01140b811b18" dependencies = [ - "event-listener", + "event-listener 5.2.0", "event-listener-strategy", "pin-project-lite", ] @@ -333,6 +391,32 @@ dependencies = [ "syn 2.0.86", ] +[[package]] +name = "async-std" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c634475f29802fde2b8f0b505b1bd00dfe4df7d4a000f0b36f7671197d5c3615" +dependencies = [ + "async-channel 1.9.0", + "async-global-executor", + "async-io", + "async-lock", + "crossbeam-utils", + "futures-channel", + "futures-core", + "futures-io", + "futures-lite", + "gloo-timers 0.3.0", + "kv-log-macro", + "log", + "memchr", + "once_cell", + "pin-project-lite", + "pin-utils", + "slab", + "wasm-bindgen-futures", +] + [[package]] name = "async-stream" version = "0.3.6" @@ -355,6 +439,12 @@ dependencies = [ "syn 2.0.86", ] +[[package]] +name = "async-task" +version = "4.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b75356056920673b02621b35afd0f7dda9306d03c79a30f5c56c44cf256e3de" + [[package]] name = "async-trait" version = "0.1.83" @@ -409,6 +499,12 @@ dependencies = [ "bytemuck", ] +[[package]] +name = "atomic-waker" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" + [[package]] name = "autocfg" version = "1.1.0" @@ -562,7 +658,7 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2c8d66485a3a2ea485c1913c4572ce0256067a5377ac8c75c4960e1cda98605f" dependencies = [ - "bitcoin-internals 0.3.0", + "bitcoin-internals", "bitcoin_hashes 0.14.0", ] @@ -765,7 +861,7 @@ dependencies = [ "base58ck", "base64 0.21.7", "bech32 0.11.0", - "bitcoin-internals 0.3.0", + "bitcoin-internals", "bitcoin-io", "bitcoin-units", "bitcoin_hashes 0.14.0", @@ -775,12 +871,6 @@ dependencies = [ "serde", ] -[[package]] -name = "bitcoin-internals" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f9997f8650dd818369931b5672a18dbef95324d0513aa99aae758de8ce86e5b" - [[package]] name = "bitcoin-internals" version = "0.3.0" @@ -808,7 +898,7 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5285c8bcaa25876d07f37e3d30c303f2609179716e11d688f51e8f1fe70063e2" dependencies = [ - "bitcoin-internals 0.3.0", + "bitcoin-internals", "serde", ] @@ -934,6 +1024,19 @@ dependencies = [ "generic-array", ] +[[package]] +name = "blocking" +version = "1.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "703f41c54fc768e63e091340b424302bb1c29ef4aa0c7f10fe849dfb114d29ea" +dependencies = [ + "async-channel 2.3.1", + "async-task", + "futures-io", + "futures-lite", + "piper", +] + [[package]] name = "bls12_381" version = "0.8.0" @@ -1689,7 +1792,7 @@ dependencies = [ "bitcoincore-rpc", "clap", "cln-rpc", - "esplora-client 0.6.0", + "esplora-client 0.10.0", "fedimint-api-client", "fedimint-bitcoind", "fedimint-build", @@ -1946,12 +2049,12 @@ dependencies = [ [[package]] name = "esplora-client" -version = "0.6.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0cb1f7f2489cce83bc3bd92784f9ba5271eeb6e729b975895fc541f78cbfcdca" +checksum = "9b546e91283ebfc56337de34e0cf814e3ad98083afde593b8e58495ee5355d0e" dependencies = [ - "bitcoin 0.30.2", - "bitcoin-internals 0.1.0", + "bitcoin 0.32.4", + "hex-conservative 0.2.1", "log", "reqwest 0.11.27", "serde", @@ -1959,10 +2062,11 @@ dependencies = [ [[package]] name = "esplora-client" -version = "0.9.0" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b546e91283ebfc56337de34e0cf814e3ad98083afde593b8e58495ee5355d0e" +checksum = "23be31c97b2e505ac6af0d72a201caead71298a957639061a10314f6d4860cd7" dependencies = [ + "async-std", "bitcoin 0.32.4", "hex-conservative 0.2.1", "log", @@ -1970,6 +2074,12 @@ dependencies = [ "serde", ] +[[package]] +name = "event-listener" +version = "2.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" + [[package]] name = "event-listener" version = "5.2.0" @@ -1987,7 +2097,7 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0f214dc438f977e6d4e3500aaa277f5ad94ca83fbbd9b1a15713ce2344ccc5a1" dependencies = [ - "event-listener", + "event-listener 5.2.0", "pin-project-lite", ] @@ -2133,7 +2243,7 @@ dependencies = [ "bitcoin 0.32.4", "bitcoincore-rpc", "electrum-client", - "esplora-client 0.6.0", + "esplora-client 0.10.0", "fedimint-core", "fedimint-logging", "hex", @@ -2567,7 +2677,7 @@ dependencies = [ "cln-plugin", "cln-rpc", "erased-serde", - "esplora-client 0.6.0", + "esplora-client 0.10.0", "fedimint-api-client", "fedimint-bip39", "fedimint-build", @@ -3040,7 +3150,7 @@ name = "fedimint-server" version = "0.5.0-alpha" dependencies = [ "anyhow", - "async-channel", + "async-channel 2.3.1", "async-trait", "base64 0.22.1", "bincode", @@ -3202,7 +3312,7 @@ dependencies = [ "derive_more", "digest", "educe", - "event-listener", + "event-listener 5.2.0", "fs-mistrust", "fslock", "futures", @@ -3614,6 +3724,19 @@ version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6" +[[package]] +name = "futures-lite" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f1fa2f9765705486b33fd2acf1577f8ec449c2ba1f318ae5447697b7c08d210" +dependencies = [ + "fastrand", + "futures-core", + "futures-io", + "parking", + "pin-project-lite", +] + [[package]] name = "futures-macro" version = "0.3.31" @@ -3928,6 +4051,12 @@ version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" +[[package]] +name = "hermit-abi" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fbf6a919d6cf397374f7dfeeea91d974c7c0a7221d0d0f4f20d859d329e53fcc" + [[package]] name = "hex" version = "0.4.3" @@ -4399,7 +4528,7 @@ version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f23ff5ef2b80d608d61efee834934d862cd92461afc0560dedf493e4c033738b" dependencies = [ - "hermit-abi", + "hermit-abi 0.3.9", "libc", "windows-sys 0.52.0", ] @@ -4611,6 +4740,15 @@ dependencies = [ "cpufeatures", ] +[[package]] +name = "kv-log-macro" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0de8b303297635ad57c9f5059fd9cee7a47f8e8daa09df0fcd07dd39fb22977f" +dependencies = [ + "log", +] + [[package]] name = "lazy_static" version = "1.5.0" @@ -4915,6 +5053,9 @@ name = "log" version = "0.4.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" +dependencies = [ + "value-bag", +] [[package]] name = "lru" @@ -5060,7 +5201,7 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4569e456d394deccd22ce1c1913e6ea0e54519f577285001215d33557431afe4" dependencies = [ - "hermit-abi", + "hermit-abi 0.3.9", "libc", "wasi", "windows-sys 0.52.0", @@ -5173,7 +5314,7 @@ version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" dependencies = [ - "hermit-abi", + "hermit-abi 0.3.9", "libc", ] @@ -5552,6 +5693,17 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" +[[package]] +name = "piper" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96c8c490f422ef9a4efd2cb5b42b76c8613d7e7dfc1caf667b8a3350a5acc066" +dependencies = [ + "atomic-waker", + "fastrand", + "futures-io", +] + [[package]] name = "pkcs1" version = "0.7.5" @@ -5607,6 +5759,21 @@ dependencies = [ "plotters-backend", ] +[[package]] +name = "polling" +version = "3.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc2790cd301dec6cd3b7a025e4815cf825724a51c98dccfe6a3e55f05ffb6511" +dependencies = [ + "cfg-if", + "concurrent-queue", + "hermit-abi 0.4.0", + "pin-project-lite", + "rustix", + "tracing", + "windows-sys 0.59.0", +] + [[package]] name = "postage" version = "0.5.0" @@ -8445,6 +8612,12 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" +[[package]] +name = "value-bag" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ef4c4aa54d5d05a279399bfa921ec387b7aba77caf7a682ae8d86785b8fdad2" + [[package]] name = "vcpkg" version = "0.2.15" diff --git a/Cargo.toml b/Cargo.toml index 54ec4c27731..5adfc91d479 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -104,8 +104,7 @@ criterion = "0.5.1" devimint = { path = "./devimint", version = "=0.5.0-alpha" } electrum-client = { version = "0.18.0", features = ["use-rustls"] } erased-serde = "0.4" -esplora-client = { version = "0.6.0", default-features = false, features = [ - "async", +esplora-client = { version = "0.10.0", default-features = false, features = [ "async-https-rustls", ] } fedimintd = { path = "./fedimintd", version = "=0.5.0-alpha" } diff --git a/devimint/src/external.rs b/devimint/src/external.rs index 9101904a79c..00fc955fef0 100644 --- a/devimint/src/external.rs +++ b/devimint/src/external.rs @@ -12,9 +12,7 @@ use bitcoincore_rpc::jsonrpc::error::RpcError; use bitcoincore_rpc::RpcApi; use cln_rpc::primitives::{Amount as ClnRpcAmount, AmountOrAny}; use cln_rpc::ClnRpc; -use fedimint_core::bitcoin_migration::{ - bitcoin30_to_bitcoin32_txid, bitcoin32_to_bitcoin30_sha256_hash, -}; +use fedimint_core::bitcoin_migration::bitcoin32_to_bitcoin30_sha256_hash; use fedimint_core::encoding::Encodable; use fedimint_core::task::jit::{JitTry, JitTryAnyhow}; use fedimint_core::task::{block_in_place, block_on, sleep, timeout}; @@ -1045,9 +1043,7 @@ pub async fn open_channels_between_gateways( let mut is_missing_any_txids = false; for txid_or in &channel_funding_txids { if let Some(txid) = txid_or { - bitcoind - .poll_get_transaction(bitcoin30_to_bitcoin32_txid(txid)) - .await?; + bitcoind.poll_get_transaction(*txid).await?; } else { is_missing_any_txids = true; } diff --git a/fedimint-bitcoind/src/esplora.rs b/fedimint-bitcoind/src/esplora.rs index 24d4ef373e6..6888aded63f 100644 --- a/fedimint-bitcoind/src/esplora.rs +++ b/fedimint-bitcoind/src/esplora.rs @@ -3,9 +3,7 @@ use std::collections::HashMap; use anyhow::{bail, format_err}; use bitcoin::{BlockHash, Network, ScriptBuf, Transaction, Txid}; use fedimint_core::bitcoin_migration::{ - bitcoin30_to_bitcoin32_block_hash, bitcoin30_to_bitcoin32_tx, - bitcoin32_to_bitcoin30_block_hash, bitcoin32_to_bitcoin30_script_buf, - bitcoin32_to_bitcoin30_tx, bitcoin32_to_bitcoin30_txid, + bitcoin32_to_bitcoin30_block_header, bitcoin32_to_bitcoin30_partial_merkle_tree, }; use fedimint_core::envs::BitcoinRpcConfig; use fedimint_core::task::TaskHandle; @@ -76,16 +74,15 @@ impl IBitcoindRpc for EsploraClient { } async fn get_block_hash(&self, height: u64) -> anyhow::Result { - Ok(bitcoin30_to_bitcoin32_block_hash( - &self.client.get_block_hash(u32::try_from(height)?).await?, - )) + Ok(self.client.get_block_hash(u32::try_from(height)?).await?) } async fn get_fee_rate(&self, confirmation_target: u16) -> anyhow::Result> { - let fee_estimates: HashMap = self.client.get_fee_estimates().await?; + let fee_estimates: HashMap = self.client.get_fee_estimates().await?; let fee_rate_vb = - esplora_client::convert_fee_rate(confirmation_target.into(), fee_estimates)?; + esplora_client::convert_fee_rate(confirmation_target.into(), fee_estimates) + .unwrap_or(1.0); let fee_rate_kvb = fee_rate_vb * 1_000f32; @@ -95,24 +92,20 @@ impl IBitcoindRpc for EsploraClient { } async fn submit_transaction(&self, transaction: Transaction) { - let _ = self - .client - .broadcast(&bitcoin32_to_bitcoin30_tx(&transaction)) - .await - .map_err(|error| { - // `esplora-client` v0.6.0 only surfaces HTTP error codes, which prevents us - // from detecting errors for transactions already submitted. - // TODO: Suppress `esplora-client` already submitted errors when client is - // updated - // https://github.com/fedimint/fedimint/issues/3732 - info!(?error, "Error broadcasting transaction"); - }); + let _ = self.client.broadcast(&transaction).await.map_err(|error| { + // `esplora-client` v0.6.0 only surfaces HTTP error codes, which prevents us + // from detecting errors for transactions already submitted. + // TODO: Suppress `esplora-client` already submitted errors when client is + // updated + // https://github.com/fedimint/fedimint/issues/3732 + info!(?error, "Error broadcasting transaction"); + }); } async fn get_tx_block_height(&self, txid: &Txid) -> anyhow::Result> { Ok(self .client - .get_tx_status(&bitcoin32_to_bitcoin30_txid(txid)) + .get_tx_status(txid) .await? .block_height .map(u64::from)) @@ -124,10 +117,7 @@ impl IBitcoindRpc for EsploraClient { block_hash: &BlockHash, block_height: u64, ) -> anyhow::Result { - let tx_status = self - .client - .get_tx_status(&bitcoin32_to_bitcoin30_txid(txid)) - .await?; + let tx_status = self.client.get_tx_status(txid).await?; let is_in_block_height = tx_status .block_height @@ -138,7 +128,7 @@ impl IBitcoindRpc for EsploraClient { "Tx has a block height without a block hash" ))?; anyhow::ensure!( - bitcoin32_to_bitcoin30_block_hash(block_hash) == tx_block_hash, + block_hash == &tx_block_hash, "Block height for block hash does not match expected height" ); } @@ -157,10 +147,10 @@ impl IBitcoindRpc for EsploraClient { ) -> anyhow::Result> { let transactions = self .client - .scripthash_txs(&bitcoin32_to_bitcoin30_script_buf(script), None) + .scripthash_txs(script, None) .await? .into_iter() - .map(|tx| bitcoin30_to_bitcoin32_tx(&tx.to_tx())) + .map(|tx| tx.to_tx()) .collect::>(); Ok(transactions) @@ -169,13 +159,13 @@ impl IBitcoindRpc for EsploraClient { async fn get_txout_proof(&self, txid: Txid) -> anyhow::Result { let proof = self .client - .get_merkle_block(&bitcoin32_to_bitcoin30_txid(&txid)) + .get_merkle_block(&txid) .await? .ok_or(format_err!("No merkle proof found"))?; Ok(TxOutProof { - block_header: proof.header, - merkle_proof: proof.txn, + block_header: bitcoin32_to_bitcoin30_block_header(&proof.header), + merkle_proof: bitcoin32_to_bitcoin30_partial_merkle_tree(&proof.txn), }) } diff --git a/gateway/ln-gateway/src/lightning/ldk.rs b/gateway/ln-gateway/src/lightning/ldk.rs index 5cf706bf36b..675db699050 100644 --- a/gateway/ln-gateway/src/lightning/ldk.rs +++ b/gateway/ln-gateway/src/lightning/ldk.rs @@ -9,7 +9,6 @@ use bitcoin_hashes::Hash; use fedimint_bip39::Mnemonic; use fedimint_core::bitcoin_migration::{ bitcoin30_to_bitcoin32_invoice, bitcoin30_to_bitcoin32_payment_preimage, - bitcoin32_to_bitcoin30_txid, }; use fedimint_core::task::{TaskGroup, TaskHandle}; use fedimint_core::{Amount, BitcoinAmountOrAll}; @@ -181,7 +180,7 @@ impl GatewayLdkClient { async fn outpoint_to_scid(&self, funding_txo: OutPoint) -> anyhow::Result { let block_height = self .esplora_client - .get_merkle_proof(&bitcoin32_to_bitcoin30_txid(&funding_txo.txid)) + .get_merkle_proof(&funding_txo.txid) .await? .ok_or(anyhow::anyhow!("Failed to get merkle proof"))? .block_height; @@ -198,7 +197,7 @@ impl GatewayLdkClient { .txdata .iter() .enumerate() - .find(|(_, tx)| tx.txid() == bitcoin32_to_bitcoin30_txid(&funding_txo.txid)) + .find(|(_, tx)| tx.compute_txid() == funding_txo.txid) .ok_or(anyhow::anyhow!("Failed to find transaction"))? .0 as u32;