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
6 changes: 2 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# 0.7.0-rc.12 (Synonym Fork)
# 0.7.0-rc.13 (Synonym Fork)

## Bug Fixes
- Fixed duplicate payment events (`PaymentReceived`, `PaymentSuccessful`, `PaymentFailed`) being
Expand All @@ -13,12 +13,10 @@
- `RuntimeSyncIntervals::battery_saving()` preset (5min onchain, 2min lightning, 30min fees)
- Minimum 10-second interval enforced for all values
- Returns `BackgroundSyncNotEnabled` error if manual sync mode was configured at build time
- Optimized startup performance by parallelizing VSS reads and caching network graph locally:
- Optimized startup performance by parallelizing VSS reads:
- Parallelized early reads (node_metrics, payments, wallet)
- Parallelized channel monitors and scorer reads
- Parallelized tail reads (output_sweeper, event_queue, peer_store)
- Added `LocalGraphStore` to redirect network graph persistence to local storage instead of VSS
- Network graph is regenerable via RGS, so local-only storage avoids slow remote reads
- Added `claimable_on_close_sats` field to `ChannelDetails` struct. This field contains the
amount (in satoshis) that would be claimable if the channel were force-closed now, computed
from the channel monitor's `ClaimableOnChannelClose` balance. Returns `None` if no monitor
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ldk-node"
version = "0.7.0-rc.12"
version = "0.7.0-rc.13"
authors = ["Elias Rohrer <dev@tnull.de>"]
homepage = "https://lightningdevkit.org/"
license = "MIT OR Apache-2.0"
Expand Down
4 changes: 2 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

import PackageDescription

let tag = "v0.7.0-rc.12"
let checksum = "1f1a7ec3b1d1c75d3249f46fe272a8a65d84444d591d555517bb8904778d8551"
let tag = "v0.7.0-rc.13"
let checksum = "31d9d85d9a5d48fa47cebaf24aad3710432ea3368b35ba19efda582768d48265"
let url = "https://github.com/synonymdev/ldk-node/releases/download/\(tag)/LDKNodeFFI.xcframework.zip"

let package = Package(
Expand Down
2 changes: 1 addition & 1 deletion bindings/kotlin/ldk-node-android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ org.gradle.jvmargs=-Xmx1536m
android.useAndroidX=true
android.enableJetifier=true
kotlin.code.style=official
libraryVersion=0.7.0-rc.12
libraryVersion=0.7.0-rc.13
Binary file not shown.
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion bindings/kotlin/ldk-node-jvm/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
org.gradle.jvmargs=-Xmx1536m
kotlin.code.style=official
libraryVersion=0.7.0-rc.12
libraryVersion=0.7.0-rc.13
2 changes: 1 addition & 1 deletion bindings/python/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "ldk_node"
version = "0.7.0-rc.12"
version = "0.7.0-rc.13"
authors = [
{ name="Elias Rohrer", email="dev@tnull.de" },
]
Expand Down
25 changes: 12 additions & 13 deletions src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1529,19 +1529,18 @@ fn build_with_store_internal(
}

// Initialize the network graph
let network_graph = match io::utils::read_network_graph_from_local_cache(
&config.storage_dir_path,
Arc::clone(&logger),
) {
Ok(graph) => Arc::new(graph),
Err(e) => {
// Local cache not found or invalid - create empty graph, RGS will populate it
if e.kind() != std::io::ErrorKind::NotFound {
log_trace!(logger, "Local network graph cache invalid: {}", e);
}
Arc::new(Graph::new(config.network.into(), Arc::clone(&logger)))
},
};
let network_graph =
match io::utils::read_network_graph(Arc::clone(&kv_store), Arc::clone(&logger)) {
Ok(graph) => Arc::new(graph),
Err(e) => {
if e.kind() == std::io::ErrorKind::NotFound {
Arc::new(Graph::new(config.network.into(), Arc::clone(&logger)))
} else {
log_error!(logger, "Failed to read network graph from store: {}", e);
return Err(BuildError::ReadFailed);
}
},
};

// Read channel monitors and scorer data in parallel
let (monitors_result, scorer_data_res, external_scores_data_res) = {
Expand Down
167 changes: 0 additions & 167 deletions src/io/local_graph_store.rs

This file was deleted.

1 change: 0 additions & 1 deletion src/io/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

//! Objects and traits for data persistence.

pub(crate) mod local_graph_store;
pub mod sqlite_store;
#[cfg(test)]
pub(crate) mod test_utils;
Expand Down
41 changes: 13 additions & 28 deletions src/io/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ use lightning::routing::gossip::NetworkGraph;
use lightning::routing::scoring::ChannelLiquidities;
use lightning::util::persist::{
KVStore, KVStoreSync, KVSTORE_NAMESPACE_KEY_ALPHABET, KVSTORE_NAMESPACE_KEY_MAX_LEN,
SCORER_PERSISTENCE_PRIMARY_NAMESPACE, SCORER_PERSISTENCE_SECONDARY_NAMESPACE,
NETWORK_GRAPH_PERSISTENCE_KEY, NETWORK_GRAPH_PERSISTENCE_PRIMARY_NAMESPACE,
NETWORK_GRAPH_PERSISTENCE_SECONDARY_NAMESPACE, SCORER_PERSISTENCE_PRIMARY_NAMESPACE,
SCORER_PERSISTENCE_SECONDARY_NAMESPACE,
};
use lightning::util::ser::{Readable, ReadableArgs, Writeable};
use lightning_types::string::PrintableString;
Expand All @@ -46,7 +48,6 @@ use crate::wallet::ser::{ChangeSetDeserWrapper, ChangeSetSerWrapper};
use crate::{Error, NodeMetrics, PaymentDetails};

pub const EXTERNAL_PATHFINDING_SCORES_CACHE_KEY: &str = "external_pathfinding_scores_cache";
pub const NETWORK_GRAPH_LOCAL_CACHE_FILENAME: &str = "network_graph_cache";

/// Generates a random [BIP 39] mnemonic with the specified word count.
///
Expand Down Expand Up @@ -159,41 +160,25 @@ where
}
}

/// Read a previously persisted [`NetworkGraph`] from a local cache file.
pub(crate) fn read_network_graph_from_local_cache<L: Deref + Clone>(
storage_dir_path: &str, logger: L,
/// Read a previously persisted [`NetworkGraph`] from the store.
pub(crate) fn read_network_graph<L: Deref + Clone>(
kv_store: Arc<DynStore>, logger: L,
) -> Result<NetworkGraph<L>, std::io::Error>
where
L::Target: LdkLogger,
{
let data = read_network_graph_bytes_from_local_cache(storage_dir_path)?;
let mut reader = Cursor::new(data);
let mut reader = Cursor::new(KVStoreSync::read(
&*kv_store,
NETWORK_GRAPH_PERSISTENCE_PRIMARY_NAMESPACE,
NETWORK_GRAPH_PERSISTENCE_SECONDARY_NAMESPACE,
NETWORK_GRAPH_PERSISTENCE_KEY,
)?);
NetworkGraph::read(&mut reader, logger.clone()).map_err(|e| {
log_error!(logger, "Failed to deserialize NetworkGraph from local cache: {}", e);
log_error!(logger, "Failed to deserialize NetworkGraph: {}", e);
std::io::Error::new(std::io::ErrorKind::InvalidData, "Failed to deserialize NetworkGraph")
})
}

/// Read raw bytes from the local network graph cache file.
/// Used by LocalGraphStore to intercept KVStore reads.
pub(crate) fn read_network_graph_bytes_from_local_cache(
storage_dir_path: &str,
) -> Result<Vec<u8>, std::io::Error> {
let cache_path = format!("{}/{}", storage_dir_path, NETWORK_GRAPH_LOCAL_CACHE_FILENAME);
fs::read(&cache_path)
}

/// Write raw bytes to the local network graph cache file.
/// Used by LocalGraphStore to intercept KVStore writes.
pub(crate) fn write_network_graph_to_local_cache_bytes(
storage_dir_path: &str, data: &[u8],
) -> Result<(), std::io::Error> {
// Ensure the storage directory exists
fs::create_dir_all(storage_dir_path)?;
let cache_path = format!("{}/{}", storage_dir_path, NETWORK_GRAPH_LOCAL_CACHE_FILENAME);
fs::write(&cache_path, data)
}

/// Persist external pathfinding scores to the cache.
pub(crate) async fn write_external_pathfinding_scores_to_cache<L: Deref>(
kv_store: Arc<DynStore>, data: &ChannelLiquidities, logger: L,
Expand Down
7 changes: 1 addition & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -570,12 +570,7 @@ impl Node {
));

// Setup background processing
// Wrap the kv_store with LocalGraphStore to redirect network graph persistence to local storage
let background_persister: Arc<DynStore> =
Arc::new(io::local_graph_store::LocalGraphStore::new(
Arc::clone(&self.kv_store),
self.config.storage_dir_path.clone(),
));
let background_persister = Arc::clone(&self.kv_store);
let background_event_handler = Arc::clone(&event_handler);
let background_chain_mon = Arc::clone(&self.chain_monitor);
let background_chan_man = Arc::clone(&self.channel_manager);
Expand Down