Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,17 @@ default = []
#lightning-liquidity = { version = "0.2.0", features = ["std"] }
#lightning-macros = { version = "0.2.0" }

lightning = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "5bf0d1e2427d759fc1ba4108ddc7e9b32e8bacfc", features = ["std"] }
lightning-types = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "5bf0d1e2427d759fc1ba4108ddc7e9b32e8bacfc" }
lightning-invoice = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "5bf0d1e2427d759fc1ba4108ddc7e9b32e8bacfc", features = ["std"] }
lightning-net-tokio = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "5bf0d1e2427d759fc1ba4108ddc7e9b32e8bacfc" }
lightning-persister = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "5bf0d1e2427d759fc1ba4108ddc7e9b32e8bacfc", features = ["tokio"] }
lightning-background-processor = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "5bf0d1e2427d759fc1ba4108ddc7e9b32e8bacfc" }
lightning-rapid-gossip-sync = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "5bf0d1e2427d759fc1ba4108ddc7e9b32e8bacfc" }
lightning-block-sync = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "5bf0d1e2427d759fc1ba4108ddc7e9b32e8bacfc", features = ["rest-client", "rpc-client", "tokio"] }
lightning-transaction-sync = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "5bf0d1e2427d759fc1ba4108ddc7e9b32e8bacfc", features = ["esplora-async-https", "time", "electrum-rustls-ring"] }
lightning-liquidity = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "5bf0d1e2427d759fc1ba4108ddc7e9b32e8bacfc", features = ["std"] }
lightning-macros = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "5bf0d1e2427d759fc1ba4108ddc7e9b32e8bacfc" }
lightning = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "1c730c8a16e28cc8e0c4817717ee63c97abcf4b0", features = ["std"] }
lightning-types = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "1c730c8a16e28cc8e0c4817717ee63c97abcf4b0" }
lightning-invoice = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "1c730c8a16e28cc8e0c4817717ee63c97abcf4b0", features = ["std"] }
lightning-net-tokio = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "1c730c8a16e28cc8e0c4817717ee63c97abcf4b0" }
lightning-persister = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "1c730c8a16e28cc8e0c4817717ee63c97abcf4b0", features = ["tokio"] }
lightning-background-processor = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "1c730c8a16e28cc8e0c4817717ee63c97abcf4b0" }
lightning-rapid-gossip-sync = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "1c730c8a16e28cc8e0c4817717ee63c97abcf4b0" }
lightning-block-sync = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "1c730c8a16e28cc8e0c4817717ee63c97abcf4b0", features = ["rest-client", "rpc-client", "tokio"] }
lightning-transaction-sync = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "1c730c8a16e28cc8e0c4817717ee63c97abcf4b0", features = ["esplora-async-https", "time", "electrum-rustls-ring"] }
lightning-liquidity = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "1c730c8a16e28cc8e0c4817717ee63c97abcf4b0", features = ["std"] }
lightning-macros = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "1c730c8a16e28cc8e0c4817717ee63c97abcf4b0" }

bdk_chain = { version = "0.23.0", default-features = false, features = ["std"] }
bdk_esplora = { version = "0.22.0", default-features = false, features = ["async-https-rustls", "tokio"]}
Expand Down Expand Up @@ -78,13 +78,13 @@ log = { version = "0.4.22", default-features = false, features = ["std"]}
vss-client = { package = "vss-client-ng", version = "0.4" }
prost = { version = "0.11.6", default-features = false}
#bitcoin-payment-instructions = { version = "0.6" }
bitcoin-payment-instructions = { git = "https://github.com/tnull/bitcoin-payment-instructions", branch = "2025-12-ldk-node-base" }
bitcoin-payment-instructions = { git = "https://github.com/tnull/bitcoin-payment-instructions", rev = "a9ad849a0eb7b155a688d713de6d9010cb48f073" }

[target.'cfg(windows)'.dependencies]
winapi = { version = "0.3", features = ["winbase"] }

[dev-dependencies]
lightning = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "5bf0d1e2427d759fc1ba4108ddc7e9b32e8bacfc", features = ["std", "_test_utils"] }
lightning = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "1c730c8a16e28cc8e0c4817717ee63c97abcf4b0", features = ["std", "_test_utils"] }
proptest = "1.0.0"
regex = "1.5.6"
criterion = { version = "0.7.0", features = ["async_tokio"] }
Expand Down
1 change: 0 additions & 1 deletion bindings/ldk_node.udl
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,6 @@ dictionary NodeStatus {
u64? latest_rgs_snapshot_timestamp;
u64? latest_pathfinding_scores_sync_timestamp;
u64? latest_node_announcement_broadcast_timestamp;
u32? latest_channel_monitor_archival_height;
};

dictionary BestBlock {
Expand Down
10 changes: 1 addition & 9 deletions src/chain/bitcoind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use lightning_block_sync::{
};
use serde::Serialize;

use super::{periodically_archive_fully_resolved_monitors, WalletSyncStatus};
use super::WalletSyncStatus;
use crate::config::{
BitcoindRestClientConfig, Config, FEE_RATE_CACHE_UPDATE_TIMEOUT_SECS, TX_BROADCAST_TIMEOUT_SECS,
};
Expand Down Expand Up @@ -414,14 +414,6 @@ impl BitcoindChainSource {
now.elapsed().unwrap().as_millis()
);
*self.latest_chain_tip.write().unwrap() = Some(tip);

periodically_archive_fully_resolved_monitors(
&*channel_manager,
&*chain_monitor,
&*self.kv_store,
&*self.logger,
&*self.node_metrics,
)?;
},
Ok(_) => {},
Err(e) => {
Expand Down
10 changes: 1 addition & 9 deletions src/chain/electrum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use lightning::chain::{Confirm, Filter, WatchedOutput};
use lightning::util::ser::Writeable;
use lightning_transaction_sync::ElectrumSyncClient;

use super::{periodically_archive_fully_resolved_monitors, WalletSyncStatus};
use super::WalletSyncStatus;
use crate::config::{
Config, ElectrumSyncConfig, BDK_CLIENT_STOP_GAP, BDK_WALLET_SYNC_TIMEOUT_SECS,
FEE_RATE_CACHE_UPDATE_TIMEOUT_SECS, LDK_WALLET_SYNC_TIMEOUT_SECS, TX_BROADCAST_TIMEOUT_SECS,
Expand Down Expand Up @@ -241,14 +241,6 @@ impl ElectrumChainSource {
locked_node_metrics.latest_lightning_wallet_sync_timestamp = unix_time_secs_opt;
write_node_metrics(&*locked_node_metrics, &*self.kv_store, &*self.logger)?;
}

periodically_archive_fully_resolved_monitors(
&*channel_manager,
&*chain_monitor,
&*self.kv_store,
&*self.logger,
&*self.node_metrics,
)?;
}

res
Expand Down
10 changes: 1 addition & 9 deletions src/chain/esplora.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use lightning::chain::{Confirm, Filter, WatchedOutput};
use lightning::util::ser::Writeable;
use lightning_transaction_sync::EsploraSyncClient;

use super::{periodically_archive_fully_resolved_monitors, WalletSyncStatus};
use super::WalletSyncStatus;
use crate::config::{
Config, EsploraSyncConfig, BDK_CLIENT_CONCURRENCY, BDK_CLIENT_STOP_GAP,
BDK_WALLET_SYNC_TIMEOUT_SECS, DEFAULT_ESPLORA_CLIENT_TIMEOUT_SECS,
Expand Down Expand Up @@ -261,14 +261,6 @@ impl EsploraChainSource {
unix_time_secs_opt;
write_node_metrics(&*locked_node_metrics, &*self.kv_store, &*self.logger)?;
}

periodically_archive_fully_resolved_monitors(
&*channel_manager,
&*chain_monitor,
&*self.kv_store,
&*self.logger,
&*self.node_metrics,
)?;
Ok(())
},
Err(e) => {
Expand Down
22 changes: 1 addition & 21 deletions src/chain/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,9 @@ use crate::chain::electrum::ElectrumChainSource;
use crate::chain::esplora::EsploraChainSource;
use crate::config::{
BackgroundSyncConfig, BitcoindRestClientConfig, Config, ElectrumSyncConfig, EsploraSyncConfig,
RESOLVED_CHANNEL_MONITOR_ARCHIVAL_INTERVAL, WALLET_SYNC_INTERVAL_MINIMUM_SECS,
WALLET_SYNC_INTERVAL_MINIMUM_SECS,
};
use crate::fee_estimator::OnchainFeeEstimator;
use crate::io::utils::write_node_metrics;
use crate::logger::{log_debug, log_info, log_trace, LdkLogger, Logger};
use crate::runtime::Runtime;
use crate::types::{Broadcaster, ChainMonitor, ChannelManager, DynStore, Sweeper, Wallet};
Expand Down Expand Up @@ -486,22 +485,3 @@ impl Filter for ChainSource {
}
}
}

fn periodically_archive_fully_resolved_monitors(
channel_manager: &ChannelManager, chain_monitor: &ChainMonitor, kv_store: &DynStore,
logger: &Logger, node_metrics: &RwLock<NodeMetrics>,
) -> Result<(), Error> {
let mut locked_node_metrics = node_metrics.write().unwrap();
let cur_height = channel_manager.current_best_block().height;
let should_archive = locked_node_metrics
.latest_channel_monitor_archival_height
.as_ref()
.map_or(true, |h| cur_height >= h + RESOLVED_CHANNEL_MONITOR_ARCHIVAL_INTERVAL);

if should_archive {
chain_monitor.archive_fully_resolved_channel_monitors();
locked_node_metrics.latest_channel_monitor_archival_height = Some(cur_height);
write_node_metrics(&*locked_node_metrics, kv_store, logger)?;
}
Ok(())
}
3 changes: 0 additions & 3 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,6 @@ pub(crate) const BDK_CLIENT_CONCURRENCY: usize = 4;
// The timeout after which we abandon retrying failed payments.
pub(crate) const LDK_PAYMENT_RETRY_TIMEOUT: Duration = Duration::from_secs(10);

// The interval (in block height) after which we retry archiving fully resolved channel monitors.
pub(crate) const RESOLVED_CHANNEL_MONITOR_ARCHIVAL_INTERVAL: u32 = 6;

// The time in-between peer reconnection attempts.
pub(crate) const PEER_RECONNECTION_INTERVAL: Duration = Duration::from_secs(60);

Expand Down
12 changes: 6 additions & 6 deletions src/io/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ use std::sync::Mutex;

use lightning::events::ClosureReason;
use lightning::ln::functional_test_utils::{
check_closed_event, connect_block, create_announced_chan_between_nodes, create_chanmon_cfgs,
create_dummy_block, create_network, create_node_cfgs, create_node_chanmgrs, send_payment,
TestChanMonCfg,
check_added_monitors, check_closed_event, connect_block, create_announced_chan_between_nodes,
create_chanmon_cfgs, create_dummy_block, create_network, create_node_cfgs,
create_node_chanmgrs, send_payment, TestChanMonCfg,
};
use lightning::util::persist::{
KVStore, KVStoreSync, MonitorUpdatingPersister, KVSTORE_NAMESPACE_KEY_MAX_LEN,
};
use lightning::util::test_utils;
use lightning::{check_added_monitors, check_closed_broadcast, io};
use lightning::{check_closed_broadcast, io};
use rand::distr::Alphanumeric;
use rand::{rng, Rng};

Expand Down Expand Up @@ -333,7 +333,7 @@ pub(crate) fn do_test_store<K: KVStoreSync + Sync>(store_0: &K, store_1: &K) {
100000,
);
check_closed_broadcast!(nodes[0], true);
check_added_monitors!(nodes[0], 1);
check_added_monitors(&nodes[0], 1);

let node_txn = nodes[0].tx_broadcaster.txn_broadcast();
assert_eq!(node_txn.len(), 1);
Expand All @@ -345,7 +345,7 @@ pub(crate) fn do_test_store<K: KVStoreSync + Sync>(store_0: &K, store_1: &K) {
let reason = ClosureReason::CommitmentTxConfirmed;
let node_id_0 = nodes[0].node.get_our_node_id();
check_closed_event(&nodes[1], 1, reason, &[node_id_0], 100000);
check_added_monitors!(nodes[1], 1);
check_added_monitors(&nodes[1], 1);

// Make sure everything is persisted as expected after close.
check_persisted_data!(persister_0_max_pending_updates * 2 * EXPECTED_UPDATES_PER_PAYMENT + 1);
Expand Down
12 changes: 2 additions & 10 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -728,8 +728,6 @@ impl Node {
locked_node_metrics.latest_pathfinding_scores_sync_timestamp;
let latest_node_announcement_broadcast_timestamp =
locked_node_metrics.latest_node_announcement_broadcast_timestamp;
let latest_channel_monitor_archival_height =
locked_node_metrics.latest_channel_monitor_archival_height;

NodeStatus {
is_running,
Expand All @@ -740,7 +738,6 @@ impl Node {
latest_rgs_snapshot_timestamp,
latest_pathfinding_scores_sync_timestamp,
latest_node_announcement_broadcast_timestamp,
latest_channel_monitor_archival_height,
}
}

Expand Down Expand Up @@ -1806,10 +1803,6 @@ pub struct NodeStatus {
///
/// Will be `None` if we have no public channels or we haven't broadcasted yet.
pub latest_node_announcement_broadcast_timestamp: Option<u64>,
/// The block height when we last archived closed channel monitor data.
///
/// Will be `None` if we haven't archived any monitors of closed channels yet.
pub latest_channel_monitor_archival_height: Option<u32>,
}

/// Status fields that are persisted across restarts.
Expand All @@ -1821,7 +1814,6 @@ pub(crate) struct NodeMetrics {
latest_rgs_snapshot_timestamp: Option<u32>,
latest_pathfinding_scores_sync_timestamp: Option<u64>,
latest_node_announcement_broadcast_timestamp: Option<u64>,
latest_channel_monitor_archival_height: Option<u32>,
}

impl Default for NodeMetrics {
Expand All @@ -1833,7 +1825,6 @@ impl Default for NodeMetrics {
latest_rgs_snapshot_timestamp: None,
latest_pathfinding_scores_sync_timestamp: None,
latest_node_announcement_broadcast_timestamp: None,
latest_channel_monitor_archival_height: None,
}
}
}
Expand All @@ -1845,7 +1836,8 @@ impl_writeable_tlv_based!(NodeMetrics, {
(4, latest_fee_rate_cache_update_timestamp, option),
(6, latest_rgs_snapshot_timestamp, option),
(8, latest_node_announcement_broadcast_timestamp, option),
(10, latest_channel_monitor_archival_height, option),
// 10 used to be latest_channel_monitor_archival_height
(10, _legacy_latest_channel_monitor_archival_height, (legacy, Option<u32>, |_: &NodeMetrics| None::<Option<u32>> )),
});

pub(crate) fn total_anchor_channels_reserve_sats(
Expand Down
Loading