Skip to content
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Bug Fixes

- Prevent writes of a stopped node, still retrying against VSS or started by its detached work, from overwriting the state of a node rebuilt on the same store: building a VSS store now waits for a node still running on the same store and wallet to stop and for its writes, retries included, to return, fails with `KVStoreSetupFailed` without replacing anything if they have not after 60 s, and otherwise drops the earlier store's writes from then on, failing all but channel monitor writes; a node whose store has been replaced fails to start with `PersistenceFailed`.
- Prevent the native SIGABRT `A Tokio 1.x context was found, but it is being shutdown.` when a node is released while background work is still stuck, e.g. in a VSS write after a timed-out stop: the runtime is now kept alive until that work ends instead of being shut down under it.
- Bump `lightning`, `lightning-liquidity`, `lightning-persister` and `lightning-transaction-sync` to 0.2.8 and `lightning-invoice` to 0.34.2.
- `bump_fee_by_rbf` now only replaces transactions this wallet built and broadcast itself, and returns `TransactionNotBroadcastByWallet` for any other txid.
Expand Down
53 changes: 47 additions & 6 deletions src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ use crate::io::utils::{
read_network_graph, read_node_metrics, read_payments_async, write_node_metrics,
EXTERNAL_PATHFINDING_SCORES_CACHE_KEY,
};
use crate::io::vss_store::VssStore;
use crate::io::vss_store::{StoreFence, VssStore};
use crate::io::{
self, EVENT_QUEUE_PERSISTENCE_KEY, EVENT_QUEUE_PERSISTENCE_PRIMARY_NAMESPACE,
EVENT_QUEUE_PERSISTENCE_SECONDARY_NAMESPACE, PAYMENT_INFO_PERSISTENCE_PRIMARY_NAMESPACE,
Expand Down Expand Up @@ -724,6 +724,12 @@ impl NodeBuilder {
/// Using VSS (or any remote persistence) may cause LDK to panic if persistence failures are
/// unrecoverable, i.e., if they remain unresolved after internal retries are exhausted.
///
/// Building waits for a [`Node`] still running on the same VSS store and wallet to stop and for
/// its writes to return, and fails with [`BuildError::KVStoreSetupFailed`] after 60 seconds.
/// Past that wait, also if building fails later, an earlier [`Node`] on that store drops its
/// remaining writes, failing all but its channel monitor writes, and its [`Node::start`] fails
/// with [`crate::Error::PersistenceFailed`]: build a new [`Node`] instead.
///
/// [VSS]: https://github.com/lightningdevkit/vss-server/blob/main/README.md
/// [LNURL-auth]: https://github.com/lnurl/luds/blob/luds/04.md
pub fn build_with_vss_store(
Expand Down Expand Up @@ -778,6 +784,12 @@ impl NodeBuilder {
/// Using VSS (or any remote persistence) may cause LDK to panic if persistence failures are
/// unrecoverable, i.e., if they remain unresolved after internal retries are exhausted.
///
/// Building waits for a [`Node`] still running on the same VSS store and wallet to stop and for
/// its writes to return, and fails with [`BuildError::KVStoreSetupFailed`] after 60 seconds.
/// Past that wait, also if building fails later, an earlier [`Node`] on that store drops its
/// remaining writes, failing all but its channel monitor writes, and its [`Node::start`] fails
/// with [`crate::Error::PersistenceFailed`]: build a new [`Node`] instead.
///
/// [VSS]: https://github.com/lightningdevkit/vss-server/blob/main/README.md
pub fn build_with_vss_store_and_fixed_headers(
&self, vss_url: String, store_id: String, fixed_headers: HashMap<String, String>,
Expand All @@ -797,6 +809,12 @@ impl NodeBuilder {
/// Using VSS (or any remote persistence) may cause LDK to panic if persistence failures are
/// unrecoverable, i.e., if they remain unresolved after internal retries are exhausted.
///
/// Building waits for a [`Node`] still running on the same VSS store and wallet to stop and for
/// its writes to return, and fails with [`BuildError::KVStoreSetupFailed`] after 60 seconds.
/// Past that wait, also if building fails later, an earlier [`Node`] on that store drops its
/// remaining writes, failing all but its channel monitor writes, and its [`Node::start`] fails
/// with [`crate::Error::PersistenceFailed`]: build a new [`Node`] instead.
///
/// [VSS]: https://github.com/lightningdevkit/vss-server/blob/main/README.md
pub fn build_with_vss_store_and_header_provider(
&self, vss_url: String, store_id: String, header_provider: Arc<dyn VssHeaderProvider>,
Expand Down Expand Up @@ -830,10 +848,12 @@ impl NodeBuilder {
let vss_seed_bytes: [u8; 32] = vss_xprv.private_key.secret_bytes();

let vss_store =
VssStore::new(vss_url, store_id, vss_seed_bytes, header_provider).map_err(|e| {
log_error!(logger, "Failed to setup VSS store: {}", e);
BuildError::KVStoreSetupFailed
})?;
VssStore::new(vss_url, store_id, vss_seed_bytes, header_provider, Arc::clone(&logger))
.map_err(|e| {
log_error!(logger, "Failed to setup VSS store: {}", e);
BuildError::KVStoreSetupFailed
})?;
let vss_store_fence = vss_store.fence();

build_with_store_internal(
config,
Expand All @@ -846,6 +866,7 @@ impl NodeBuilder {
runtime,
logger,
Arc::new(vss_store),
Some(vss_store_fence),
self.channel_data_migration.as_ref(),
)
}
Expand Down Expand Up @@ -881,6 +902,7 @@ impl NodeBuilder {
runtime,
logger,
kv_store,
None,
self.channel_data_migration.as_ref(),
)
}
Expand Down Expand Up @@ -1203,6 +1225,12 @@ impl ArcedNodeBuilder {
/// Using VSS (or any remote persistence) may cause LDK to panic if persistence failures are
/// unrecoverable, i.e., if they remain unresolved after internal retries are exhausted.
///
/// Building waits for a [`Node`] still running on the same VSS store and wallet to stop and for
/// its writes to return, and fails with [`BuildError::KVStoreSetupFailed`] after 60 seconds.
/// Past that wait, also if building fails later, an earlier [`Node`] on that store drops its
/// remaining writes, failing all but its channel monitor writes, and its [`Node::start`] fails
/// with [`crate::Error::PersistenceFailed`]: build a new [`Node`] instead.
///
/// [VSS]: https://github.com/lightningdevkit/vss-server/blob/main/README.md
/// [LNURL-auth]: https://github.com/lnurl/luds/blob/luds/04.md
pub fn build_with_vss_store(
Expand All @@ -1227,6 +1255,12 @@ impl ArcedNodeBuilder {
/// Using VSS (or any remote persistence) may cause LDK to panic if persistence failures are
/// unrecoverable, i.e., if they remain unresolved after internal retries are exhausted.
///
/// Building waits for a [`Node`] still running on the same VSS store and wallet to stop and for
/// its writes to return, and fails with [`BuildError::KVStoreSetupFailed`] after 60 seconds.
/// Past that wait, also if building fails later, an earlier [`Node`] on that store drops its
/// remaining writes, failing all but its channel monitor writes, and its [`Node::start`] fails
/// with [`crate::Error::PersistenceFailed`]: build a new [`Node`] instead.
///
/// [VSS]: https://github.com/lightningdevkit/vss-server/blob/main/README.md
pub fn build_with_vss_store_and_fixed_headers(
&self, vss_url: String, store_id: String, fixed_headers: HashMap<String, String>,
Expand All @@ -1248,6 +1282,12 @@ impl ArcedNodeBuilder {
/// Using VSS (or any remote persistence) may cause LDK to panic if persistence failures are
/// unrecoverable, i.e., if they remain unresolved after internal retries are exhausted.
///
/// Building waits for a [`Node`] still running on the same VSS store and wallet to stop and for
/// its writes to return, and fails with [`BuildError::KVStoreSetupFailed`] after 60 seconds.
/// Past that wait, also if building fails later, an earlier [`Node`] on that store drops its
/// remaining writes, failing all but its channel monitor writes, and its [`Node::start`] fails
/// with [`crate::Error::PersistenceFailed`]: build a new [`Node`] instead.
///
/// [VSS]: https://github.com/lightningdevkit/vss-server/blob/main/README.md
pub fn build_with_vss_store_and_header_provider(
&self, vss_url: String, store_id: String, header_provider: Arc<dyn VssHeaderProvider>,
Expand Down Expand Up @@ -1726,7 +1766,7 @@ fn build_with_store_internal(
liquidity_source_config: Option<&LiquiditySourceConfig>,
pathfinding_scores_sync_config: Option<&PathfindingScoresSyncConfig>,
async_payments_role: Option<AsyncPaymentsRole>, seed_bytes: [u8; 64], runtime: Runtime,
logger: Arc<Logger>, kv_store: Arc<DynStore>,
logger: Arc<Logger>, kv_store: Arc<DynStore>, vss_store_fence: Option<StoreFence>,
channel_data_migration: Option<&ChannelDataMigration>,
) -> Result<Node, BuildError> {
optionally_install_rustls_cryptoprovider();
Expand Down Expand Up @@ -2600,6 +2640,7 @@ fn build_with_store_internal(
pathfinding_scores_sync_url,
liquidity_source,
kv_store,
vss_store_fence,
logger,
_router: router,
scorer,
Expand Down
Loading