]> git.bitcoin.ninja Git - rapid-gossip-sync-server/commitdiff
Upgrade LDK to 0.0.124.
authorArik Sosman <git@arik.io>
Mon, 24 Jun 2024 18:36:13 +0000 (14:36 -0400)
committerArik Sosman <git@arik.io>
Wed, 18 Sep 2024 17:07:23 +0000 (10:07 -0700)
Cargo.toml
src/config.rs
src/lookup.rs
src/persistence.rs
src/serialization.rs
src/tests/mod.rs

index 1fee6cd2a8fdf71fb9d593a5e13732a2ef665543..671d41abc2867d138df763a23fa77ec537b4c1f7 100644 (file)
@@ -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"
index a302fb7019829d3d3850e5f0dff843b77d02ba79..6220fc1017bf510e812e0233a3ba275d923a4193 100644 (file)
@@ -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<u8> = 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();
                                });
index 302268b0057c9846ec075595c58e44d334d1b0c5..9a584c41ba47bb2f63fe3f608010de1be1b250d2 100644 (file)
@@ -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<L: Deref>(delta_set: &mut DeltaS
        while let Some(row_res) = pinned_rows.next().await {
                let current_announcement_row = row_res.unwrap();
                let blob: Vec<u8> = 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<L: Deref>(delta_set: &mut DeltaS
 
                        if seen < reminder_threshold_timestamp as u32 {
                                let blob: Vec<u8> = 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<L: Deref>(delta_set: &mut DeltaSet, cl
                let direction: bool = current_reference.get("direction");
                let seen = current_reference.get::<_, i64>("seen") as u32;
                let blob: Vec<u8> = 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<L: Deref>(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<u8> = 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<L: Deref>(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<L: Deref>(client: &Client, last_sync_time
 
                let seen = current_reference.get::<_, i64>("seen") as u32;
                let blob: Vec<u8> = 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<L: Deref>(client: &Client, last_sync_time
 
                let current_seen_timestamp = intermediate_update.get::<_, i64>("seen") as u32;
                let blob: Vec<u8> = 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;
index 04c6b9a0c4076cab725b90b5a4ec769718d183a0..0db3091beba7dd465db84754f47ac9c8eaed064b 100644 (file)
@@ -226,8 +226,8 @@ impl<L: Deref> GossipPersister<L> 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<L: Deref> GossipPersister<L> where L::Target: Logger {
                                                                &timestamp,
                                                                #[cfg(test)]
                                                                        &_seen_timestamp,
-                                                               &(update.contents.flags as i16),
+                                                               &(update.contents.channel_flags as i16),
                                                                &direction,
                                                                &disable,
                                                                &cltv_expiry_delta,
index a527b45c824b3202d5501693ae7f5d520175f6e1..74c92ca39ffcdfad5e06cdce5e6ab71a6b769981 100644 (file)
@@ -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,
                }
        }
index 7290e6e177ea83d54ce12532a30752ed65bdb77e..2e0e0c12850410bbc55f0ea31243efd356016f7a 100644 (file)
@@ -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,