From de5185a8ad3f6fcfc2545620b42e7b7480496ea3 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Wed, 13 Mar 2024 14:28:26 +0000 Subject: [PATCH] Bump LDK to 0.0.121/rust-bitcoin 0.30, bumping MSRV to 1.63 Co-authored-by: Arik Sosman --- .github/workflows/build.yml | 2 +- Cargo.toml | 13 +++++++------ src/config.rs | 17 +++++++++++++---- src/tests/mod.rs | 6 +++--- src/tracking.rs | 13 +++++++------ src/types.rs | 4 ++-- 6 files changed, 33 insertions(+), 22 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7a614ec..33d5239 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -18,7 +18,7 @@ jobs: matrix: toolchain: - stable - - 1.56.0 + - 1.63.0 - beta runs-on: ubuntu-latest steps: diff --git a/Cargo.toml b/Cargo.toml index 7e6ce0f..ee31730 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,17 +4,18 @@ version = "0.1.0" edition = "2021" [dependencies] -bitcoin = "0.29" -lightning = { version = "0.0.118" } -lightning-block-sync = { version = "0.0.118", features=["rest-client"] } -lightning-net-tokio = { version = "0.0.118" } +bitcoin = "0.30" +hex-conservative = "0.2" +lightning = { version = "0.0.121" } +lightning-block-sync = { version = "0.0.121", features=["rest-client"] } +lightning-net-tokio = { version = "0.0.121" } tokio = { version = "1.25", features = ["full"] } tokio-postgres = { version = "=0.7.5" } futures = "0.3" [dev-dependencies] -lightning = { version = "0.0.118", features = ["_test_utils"] } -lightning-rapid-gossip-sync = { version = "0.0.118" } +lightning = { version = "0.0.121", features = ["_test_utils"] } +lightning-rapid-gossip-sync = { version = "0.0.121" } [profile.dev] panic = "abort" diff --git a/src/config.rs b/src/config.rs index 4318a72..ae5b2d1 100644 --- a/src/config.rs +++ b/src/config.rs @@ -336,24 +336,33 @@ fn resolve_peer_info(peer_info: &str) -> Result<(PublicKey, SocketAddr), &str> { #[cfg(test)] mod tests { use super::*; - use bitcoin::hashes::hex::ToHex; + use hex_conservative::DisplayHex; use std::str::FromStr; #[test] fn test_resolve_peer_info() { let wallet_of_satoshi = "035e4ff418fc8b5554c5d9eea66396c227bd429a3251c8cbc711002ba215bfc226@170.75.163.209:9735"; let (pubkey, socket_address) = resolve_peer_info(wallet_of_satoshi).unwrap(); - assert_eq!(pubkey.serialize().to_hex(), "035e4ff418fc8b5554c5d9eea66396c227bd429a3251c8cbc711002ba215bfc226"); + assert_eq!( + pubkey.serialize().to_lower_hex_string(), + "035e4ff418fc8b5554c5d9eea66396c227bd429a3251c8cbc711002ba215bfc226" + ); assert_eq!(socket_address.to_string(), "170.75.163.209:9735"); let ipv6 = "033d8656219478701227199cbd6f670335c8d408a92ae88b962c49d4dc0e83e025@[2001:db8::1]:80"; let (pubkey, socket_address) = resolve_peer_info(ipv6).unwrap(); - assert_eq!(pubkey.serialize().to_hex(), "033d8656219478701227199cbd6f670335c8d408a92ae88b962c49d4dc0e83e025"); + assert_eq!( + pubkey.serialize().to_lower_hex_string(), + "033d8656219478701227199cbd6f670335c8d408a92ae88b962c49d4dc0e83e025" + ); assert_eq!(socket_address.to_string(), "[2001:db8::1]:80"); let localhost = "033d8656219478701227199cbd6f670335c8d408a92ae88b962c49d4dc0e83e025@localhost:9735"; let (pubkey, socket_address) = resolve_peer_info(localhost).unwrap(); - assert_eq!(pubkey.serialize().to_hex(), "033d8656219478701227199cbd6f670335c8d408a92ae88b962c49d4dc0e83e025"); + assert_eq!( + pubkey.serialize().to_lower_hex_string(), + "033d8656219478701227199cbd6f670335c8d408a92ae88b962c49d4dc0e83e025" + ); let socket_address = socket_address.to_string(); assert!(socket_address == "127.0.0.1:9735" || socket_address == "[::1]:9735"); } diff --git a/src/tests/mod.rs b/src/tests/mod.rs index ef25ef0..cbacca6 100644 --- a/src/tests/mod.rs +++ b/src/tests/mod.rs @@ -9,8 +9,8 @@ use bitcoin::Network; use bitcoin::secp256k1::ecdsa::Signature; use bitcoin::secp256k1::{Secp256k1, SecretKey}; use bitcoin::hashes::Hash; -use bitcoin::hashes::hex::ToHex; use bitcoin::hashes::sha256d::Hash as Sha256dHash; +use hex_conservative::DisplayHex; use lightning::ln::features::ChannelFeatures; use lightning::ln::msgs::{ChannelAnnouncement, ChannelUpdate, UnsignedChannelAnnouncement, UnsignedChannelUpdate}; use lightning::routing::gossip::{NetworkGraph, NodeId}; @@ -121,9 +121,9 @@ impl SchemaSanitizer { let thread_id = thread::current().id(); let preimage = format!("{:?}-{}", thread_id, timestamp_nanos); println!("test schema preimage: {}", preimage); - let suffix = Sha256dHash::hash(preimage.as_bytes()).into_inner().to_hex(); + let suffix = Sha256dHash::hash(preimage.as_bytes()).encode(); // the schema must start with a letter - let schema = format!("test_{}_{}", timestamp_seconds, suffix); + let schema = format!("test_{}_{}", timestamp_seconds, suffix.as_hex()); *suffix_option = Some(schema); }); diff --git a/src/tracking.rs b/src/tracking.rs index c8d6bac..901339c 100644 --- a/src/tracking.rs +++ b/src/tracking.rs @@ -5,8 +5,8 @@ use std::ops::Deref; use std::sync::Arc; use std::time::{Duration, Instant}; -use bitcoin::hashes::hex::ToHex; use bitcoin::secp256k1::PublicKey; +use hex_conservative::display::DisplayHex; use lightning::ln::peer_handler::{ ErroringMessageHandler, IgnoringMessageHandler, MessageHandler, PeerManager, }; @@ -167,7 +167,8 @@ async fn connect_peer(current_peer: (P // we seek to find out if the first connection attempt was successful let (sender, mut receiver) = mpsc::channel::(1); tokio::spawn(async move { - log_info!(logger, "Connecting to peer {}@{}...", current_peer.0.to_hex(), current_peer.1.to_string()); + let current_peer_pubkey_hex = current_peer.0.serialize().to_lower_hex_string(); + log_info!(logger, "Connecting to peer {}@{}...", current_peer_pubkey_hex, current_peer.1); let mut is_first_iteration = true; loop { if let Some(disconnection_future) = lightning_net_tokio::connect_outbound( @@ -175,21 +176,21 @@ async fn connect_peer(current_peer: (P current_peer.0, current_peer.1, ).await { - log_info!(logger, "Connected to peer {}@{}!", current_peer.0.to_hex(), current_peer.1.to_string()); + log_info!(logger, "Connected to peer {}@{}!", current_peer_pubkey_hex, current_peer.1); if is_first_iteration { sender.send(true).await.unwrap(); } disconnection_future.await; - log_warn!(logger, "Disconnected from peer {}@{}", current_peer.0.to_hex(), current_peer.1.to_string()); + log_warn!(logger, "Disconnected from peer {}@{}", current_peer_pubkey_hex, current_peer.1); } else { - log_warn!(logger, "Failed to connect to peer {}@{}!", current_peer.0.to_hex(), current_peer.1.to_string()); + log_warn!(logger, "Failed to connect to peer {}@{}!", current_peer_pubkey_hex, current_peer.1); if is_first_iteration { sender.send(false).await.unwrap(); } } is_first_iteration = false; tokio::time::sleep(Duration::from_secs(10)).await; - log_warn!(logger, "Reconnecting to peer {}@{}...", current_peer.0.to_hex(), current_peer.1.to_string()); + log_warn!(logger, "Reconnecting to peer {}@{}...", current_peer_pubkey_hex, current_peer.1); } }); diff --git a/src/types.rs b/src/types.rs index 93527a4..0c6c9b2 100644 --- a/src/types.rs +++ b/src/types.rs @@ -29,7 +29,7 @@ impl RGSSLogger { } impl Logger for RGSSLogger { - fn log(&self, record: &Record) { + fn log(&self, record: Record) { let threshold = config::log_level(); if record.level < threshold { return; @@ -84,7 +84,7 @@ pub mod tests { } impl Logger for TestLogger { - fn log(&self, record: &Record) { + fn log(&self, record: Record) { *self.lines.lock().unwrap().entry((record.module_path.to_string(), format!("{}", record.args))).or_insert(0) += 1; println!("{:<5} {} [{} : {}, {}] {}", record.level.to_string(), self.id, record.module_path, record.file, record.line, record.args); } -- 2.39.5