From: Arik Sosman Date: Mon, 24 Jun 2024 18:36:13 +0000 (-0400) Subject: Upgrade LDK to 0.0.124. X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=8219e5d119011f53983e733dd29e166860a5d90e;p=rapid-gossip-sync-server Upgrade LDK to 0.0.124. --- diff --git a/Cargo.toml b/Cargo.toml index 1fee6cd..671d41a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,18 +4,18 @@ version = "0.1.0" edition = "2021" [dependencies] -bitcoin = "0.30" -hex-conservative = "0.2" -lightning = { version = "0.0.123" } -lightning-block-sync = { version = "0.0.123", features=["rest-client"] } -lightning-net-tokio = { version = "0.0.123" } +bitcoin = "0.32.2" +hex-conservative = "0.2.1" +lightning = { version = "0.0.124" } +lightning-block-sync = { version = "0.0.124", features=["rest-client"] } +lightning-net-tokio = { version = "0.0.124" } tokio = { version = "1.25", features = ["full"] } tokio-postgres = { version = "=0.7.5" } futures = "0.3" [dev-dependencies] -lightning = { version = "0.0.123", features = ["_test_utils"] } -lightning-rapid-gossip-sync = { version = "0.0.123" } +lightning = { version = "0.0.124", features = ["_test_utils"] } +lightning-rapid-gossip-sync = { version = "0.0.124" } [profile.dev] panic = "abort" diff --git a/src/config.rs b/src/config.rs index a302fb7..6220fc1 100644 --- a/src/config.rs +++ b/src/config.rs @@ -1,10 +1,10 @@ use crate::hex_utils; use std::env; -use std::io::Cursor; use std::net::{SocketAddr, ToSocketAddrs}; use std::time::Duration; +use bitcoin::io::Cursor; use bitcoin::Network; use bitcoin::hashes::hex::FromHex; use bitcoin::secp256k1::PublicKey; @@ -223,7 +223,7 @@ pub(crate) async fn upgrade_db(schema: i32, client: &mut tokio_postgres::Client) let announcement: Vec = row.get("announcement_signed"); let tx_ref = &tx; updates.push(async move { - let scid = ChannelAnnouncement::read(&mut Cursor::new(announcement)).unwrap().contents.short_channel_id as i64; + let scid = ChannelAnnouncement::read(&mut Cursor::new(&announcement)).unwrap().contents.short_channel_id as i64; assert!(scid > 0); // Will roll over in some 150 years or so tx_ref.execute("UPDATE channel_announcements SET short_channel_id = $1 WHERE id = $2", &[&scid, &id]).await.unwrap(); }); diff --git a/src/lookup.rs b/src/lookup.rs index 302268b..9a584c4 100644 --- a/src/lookup.rs +++ b/src/lookup.rs @@ -1,9 +1,10 @@ use std::collections::{BTreeMap, HashMap, HashSet}; -use std::io::Cursor; use std::ops::Deref; use std::sync::Arc; use std::time::{Instant, SystemTime, UNIX_EPOCH}; +use bitcoin::io::Cursor; + use lightning::ln::msgs::{ChannelAnnouncement, ChannelUpdate, NodeAnnouncement, SocketAddress, UnsignedChannelAnnouncement, UnsignedChannelUpdate}; use lightning::routing::gossip::{NetworkGraph, NodeId}; use lightning::util::ser::Readable; @@ -160,7 +161,7 @@ pub(super) async fn fetch_channel_announcements(delta_set: &mut DeltaS while let Some(row_res) = pinned_rows.next().await { let current_announcement_row = row_res.unwrap(); let blob: Vec = current_announcement_row.get("announcement_signed"); - let mut readable = Cursor::new(blob); + let mut readable = Cursor::new(&blob); let unsigned_announcement = ChannelAnnouncement::read(&mut readable).unwrap().contents; let scid = unsigned_announcement.short_channel_id; @@ -287,7 +288,7 @@ pub(super) async fn fetch_channel_announcements(delta_set: &mut DeltaS if seen < reminder_threshold_timestamp as u32 { let blob: Vec = current_row.get("blob_signed"); - let mut readable = Cursor::new(blob); + let mut readable = Cursor::new(&blob); let unsigned_channel_update = ChannelUpdate::read(&mut readable).unwrap().contents; let scid = unsigned_channel_update.short_channel_id; @@ -365,7 +366,7 @@ pub(super) async fn fetch_channel_updates(delta_set: &mut DeltaSet, cl let direction: bool = current_reference.get("direction"); let seen = current_reference.get::<_, i64>("seen") as u32; let blob: Vec = current_reference.get("blob_signed"); - let mut readable = Cursor::new(blob); + let mut readable = Cursor::new(&blob); let unsigned_channel_update = ChannelUpdate::read(&mut readable).unwrap().contents; let scid = unsigned_channel_update.short_channel_id; @@ -415,7 +416,7 @@ pub(super) async fn fetch_channel_updates(delta_set: &mut DeltaSet, cl let direction: bool = intermediate_update.get("direction"); let current_seen_timestamp = intermediate_update.get::<_, i64>("seen") as u32; let blob: Vec = intermediate_update.get("blob_signed"); - let mut readable = Cursor::new(blob); + let mut readable = Cursor::new(&blob); let unsigned_channel_update = ChannelUpdate::read(&mut readable).unwrap().contents; let scid = unsigned_channel_update.short_channel_id; @@ -451,7 +452,7 @@ pub(super) async fn fetch_channel_updates(delta_set: &mut DeltaSet, cl // determine mutations if let Some(last_seen_update) = update_delta.last_update_before_seen.as_ref() { - if unsigned_channel_update.flags != last_seen_update.update.flags { + if unsigned_channel_update.channel_flags != last_seen_update.update.channel_flags { update_delta.mutated_properties.flags = true; } if unsigned_channel_update.cltv_expiry_delta != last_seen_update.update.cltv_expiry_delta { @@ -498,7 +499,7 @@ pub(super) async fn fetch_node_updates(client: &Client, last_sync_time let seen = current_reference.get::<_, i64>("seen") as u32; let blob: Vec = current_reference.get("announcement_signed"); - let mut readable = Cursor::new(blob); + let mut readable = Cursor::new(&blob); let unsigned_node_announcement = NodeAnnouncement::read(&mut readable).unwrap().contents; let node_id = unsigned_node_announcement.node_id; @@ -541,7 +542,7 @@ pub(super) async fn fetch_node_updates(client: &Client, last_sync_time let current_seen_timestamp = intermediate_update.get::<_, i64>("seen") as u32; let blob: Vec = intermediate_update.get("announcement_signed"); - let mut readable = Cursor::new(blob); + let mut readable = Cursor::new(&blob); let unsigned_node_announcement = NodeAnnouncement::read(&mut readable).unwrap().contents; let node_id = unsigned_node_announcement.node_id; diff --git a/src/persistence.rs b/src/persistence.rs index 04c6b9a..0db3091 100644 --- a/src/persistence.rs +++ b/src/persistence.rs @@ -226,8 +226,8 @@ impl GossipPersister where L::Target: Logger { let timestamp = update.contents.timestamp as i64; - let direction = (update.contents.flags & 1) == 1; - let disable = (update.contents.flags & 2) > 0; + let direction = (update.contents.channel_flags & 1) == 1; + let disable = (update.contents.channel_flags & 2) > 0; let cltv_expiry_delta = update.contents.cltv_expiry_delta as i32; let htlc_minimum_msat = update.contents.htlc_minimum_msat as i64; @@ -281,7 +281,7 @@ impl GossipPersister where L::Target: Logger { ×tamp, #[cfg(test)] &_seen_timestamp, - &(update.contents.flags as i16), + &(update.contents.channel_flags as i16), &direction, &disable, &cltv_expiry_delta, diff --git a/src/serialization.rs b/src/serialization.rs index a527b45..74c92ca 100644 --- a/src/serialization.rs +++ b/src/serialization.rs @@ -93,7 +93,7 @@ impl UpdateSerialization { fn flags(&self) -> u8 { match self { UpdateSerialization::Full(latest_update)| - UpdateSerialization::Incremental(latest_update, _) => latest_update.flags, + UpdateSerialization::Incremental(latest_update, _) => latest_update.channel_flags, UpdateSerialization::Reminder(_, flags) => *flags, } } diff --git a/src/tests/mod.rs b/src/tests/mod.rs index 7290e6e..2e0e0c1 100644 --- a/src/tests/mod.rs +++ b/src/tests/mod.rs @@ -118,7 +118,8 @@ fn generate_update(scid: u64, direction: bool, timestamp: u32, expiry_delta: u16 chain_hash: genesis_hash(), short_channel_id: scid, timestamp, - flags: 0 | flag_mask, + message_flags: 0, + channel_flags: flag_mask, cltv_expiry_delta: expiry_delta, htlc_minimum_msat: min_msat, htlc_maximum_msat: max_msat,