Skip to content

Commit dcf3903

Browse files
committed
Update LDK past v0.0.112 to include Future patch
- `0.0.112` introduced a bug where calls to `get_persistable_update_future` always return a `Future` which is `Ready`. - After some back-and-forth with Matt, the bug was resolved in lightningdevkit/rust-lightning#1851 - Although 1851 hasn't been merged yet, I went ahead and picked the changes into the `lexe-v0.0.112-with-fix` branch of our LDK fork, and changed the workspace root `Cargo.toml`s to use this patch. - One extra perk is that we now have early access to the `ChannelReady` event which is set to be released with `0.0.113`. - Once `0.0.113` is released, we should switch back to using the crates.io version of LDK.
1 parent b8a3a5c commit dcf3903

File tree

18 files changed

+128
-91
lines changed

18 files changed

+128
-91
lines changed

Cargo.lock

Lines changed: 9 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,15 @@ sgx-isa = { git = "https://github.com/lexe-tech/rust-sgx", branch = "lexe" }
2323
sgxs-loaders = { git = "https://github.com/lexe-tech/rust-sgx", branch = "lexe" }
2424
tokio = { git = "https://github.com/lexe-tech/tokio", branch = "tokio-sgx-1.21.2" }
2525

26+
# 0.0.112 introduced a bug which breaks our integration tests. The fix is
27+
# implemented in https://github.com/lightningdevkit/rust-lightning/pull/1851.
28+
# In the meantime, we have to use a git dependency until 0.0.113 is released.
29+
# TODO(max): Comment this section out once 0.0.113 is released
30+
lightning = { git = "https://github.com/lexe-tech/rust-lightning", branch = "lexe-v0.0.112-with-fix" }
31+
lightning-block-sync = { git = "https://github.com/lexe-tech/rust-lightning", branch = "lexe-v0.0.112-with-fix" }
32+
lightning-invoice = { git = "https://github.com/lexe-tech/rust-lightning", branch = "lexe-v0.0.112-with-fix" }
33+
lightning-net-tokio = { git = "https://github.com/lexe-tech/rust-lightning", branch = "lexe-v0.0.112-with-fix" }
34+
2635
# For debugging LDK or testing patches during local development
2736
# lightning = { path = "../ldk/lightning", features = ["max_level_trace"]}
2837
# lightning-block-sync = { path = "../ldk/lightning-block-sync", features = [ "rpc-client" ] }

common/Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ base64 = "0.13.0"
1919

2020
# --- LIGHTNING --- #
2121

22-
lightning = { version = "0.0.111", features = ["max_level_trace"] }
23-
# lightning-block-sync = { version = "0.0.111", features = [ "rpc-client" ] }
24-
lightning-invoice = { version = "0.19" }
25-
# lightning-net-tokio = { version = "0.0.111" }
22+
lightning = { version = "0.0.112", features = ["max_level_trace"] }
23+
# lightning-block-sync = { version = "0.0.112", features = [ "rpc-client" ] }
24+
lightning-invoice = { version = "0.20" }
25+
# lightning-net-tokio = { version = "0.0.112" }
2626

2727
# lightning = { git = "https://github.com/lexe-tech/rust-lightning", features = ["max_level_trace"], branch = "main" }
2828
# lightning-block-sync = { git = "https://github.com/lexe-tech/rust-lightning", features = [ "rpc-client" ], branch = "main" }

lexe-ln/Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ base64 = "0.13.0"
2626

2727
# --- LIGHTNING --- #
2828

29-
lightning = { version = "0.0.111", features = ["max_level_trace"] }
30-
lightning-block-sync = { version = "0.0.111", features = [ "rpc-client" ] }
31-
lightning-invoice = { version = "0.19" }
32-
lightning-net-tokio = { version = "0.0.111" }
29+
lightning = { version = "0.0.112", features = ["max_level_trace"] }
30+
lightning-block-sync = { version = "0.0.112", features = [ "rpc-client" ] }
31+
lightning-invoice = { version = "0.20" }
32+
lightning-net-tokio = { version = "0.0.112" }
3333

3434
# lightning = { git = "https://github.com/lexe-tech/rust-lightning", features = # ["max_level_trace"], branch = "main" }
3535
# lightning-block-sync = { git = "https://github.com/lexe-tech/rust-lightning", # features = [ "rpc-client" ], branch = "main" }

lexe-ln/src/alias.rs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ pub type P2PGossipSyncType = P2PGossipSync<
4949
>;
5050

5151
pub type LexeChannelManagerType<PERSISTER> = ChannelManager<
52-
SignerType,
5352
Arc<LexeChainMonitorType<PERSISTER>>,
5453
Arc<BroadcasterType>,
5554
LexeKeysManager,
@@ -61,7 +60,7 @@ pub type ProbabilisticScorerType =
6160
ProbabilisticScorer<Arc<NetworkGraphType>, LexeTracingLogger>;
6261

6362
pub type OnionMessengerType =
64-
OnionMessenger<SignerType, LexeKeysManager, LexeTracingLogger>;
63+
OnionMessenger<LexeKeysManager, LexeTracingLogger, IgnoringMessageHandler>;
6564

6665
pub type LexePeerManagerType<CHANNEL_MANAGER> = PeerManager<
6766
SocketDescriptor,
@@ -74,17 +73,16 @@ pub type LexePeerManagerType<CHANNEL_MANAGER> = PeerManager<
7473

7574
pub type PaymentInfoStorageType = Arc<Mutex<HashMap<PaymentHash, PaymentInfo>>>;
7675

77-
pub type RouterType = DefaultRouter<Arc<NetworkGraphType>, LexeTracingLogger>;
78-
79-
// TODO(max): Expand this further to InvoicePayerUsingTime?
80-
pub type LexeInvoicePayerType<CHANNEL_MANAGER, EVENT_HANDLER> = InvoicePayer<
81-
CHANNEL_MANAGER,
82-
RouterType,
83-
Arc<Mutex<ProbabilisticScorerType>>,
76+
pub type RouterType = DefaultRouter<
77+
Arc<NetworkGraphType>,
8478
LexeTracingLogger,
85-
EVENT_HANDLER,
79+
Arc<Mutex<ProbabilisticScorerType>>,
8680
>;
8781

82+
// TODO(max): Expand this further to InvoicePayerUsingTime?
83+
pub type LexeInvoicePayerType<CHANNEL_MANAGER, EVENT_HANDLER> =
84+
InvoicePayer<CHANNEL_MANAGER, RouterType, LexeTracingLogger, EVENT_HANDLER>;
85+
8886
/// This is the tuple that LDK impl'd `Listen` for
8987
pub type ChannelMonitorListenerType = (
9088
ChannelMonitorType,

lexe-ln/src/background_processor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ impl LexeBackgroundProcessor {
9292
_ = ng_timer.tick() => {
9393
debug!("Pruning and persisting network graph");
9494
let network_graph = gossip_sync.network_graph();
95-
network_graph.remove_stale_channels();
95+
network_graph.remove_stale_channels_and_tracking();
9696
let persist_res = persister
9797
.persist_graph(network_graph)
9898
.await;

lexe-ln/src/bitcoind/mod.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ use std::sync::Arc;
55
use std::time::Duration;
66

77
use anyhow::{ensure, Context};
8-
use bitcoin::blockdata::block::Block;
98
use bitcoin::blockdata::transaction::Transaction;
109
use bitcoin::consensus::encode;
1110
use bitcoin::hash_types::{BlockHash, Txid};
@@ -19,7 +18,7 @@ use lightning::chain::chaininterface::{
1918
use lightning_block_sync::http::HttpEndpoint;
2019
use lightning_block_sync::rpc::RpcClient;
2120
use lightning_block_sync::{
22-
AsyncBlockSourceResult, BlockHeaderData, BlockSource,
21+
AsyncBlockSourceResult, BlockData, BlockHeaderData, BlockSource,
2322
};
2423
use tokio::time;
2524
use tracing::{debug, error};
@@ -287,7 +286,7 @@ impl BlockSource for LexeBitcoind {
287286
fn get_block<'a>(
288287
&'a self,
289288
header_hash: &'a BlockHash,
290-
) -> AsyncBlockSourceResult<'a, Block> {
289+
) -> AsyncBlockSourceResult<'a, BlockData> {
291290
debug!("get_block() called for {header_hash}");
292291
Box::pin(async move { self.rpc_client.get_block(header_hash).await })
293292
}

lexe-ln/src/command.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use tracing::info;
1313
use crate::alias::{LexeInvoicePayerType, PaymentInfoStorageType};
1414
use crate::invoice::{HTLCStatus, LxPaymentError, MillisatAmount, PaymentInfo};
1515
use crate::keys_manager::LexeKeysManager;
16+
use crate::logger::LexeTracingLogger;
1617
use crate::traits::{
1718
LexeChannelManager, LexeEventHandler, LexePeerManager, LexePersister,
1819
};
@@ -50,6 +51,7 @@ where
5051
pub fn get_invoice<CM, PS>(
5152
channel_manager: CM,
5253
keys_manager: LexeKeysManager,
54+
logger: LexeTracingLogger,
5355
inbound_payments: PaymentInfoStorageType,
5456
network: Network,
5557
req: GetInvoiceRequest,
@@ -64,6 +66,7 @@ where
6466
let invoice = lightning_invoice::utils::create_invoice_from_channelmanager(
6567
&channel_manager,
6668
keys_manager,
69+
logger,
6770
currency,
6871
req.amt_msat,
6972
"lexe-node".to_string(),

lexe-ln/src/event.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ use lightning::util::events::Event;
33
// TODO(max): Perhaps we should upstream this as a Display impl?
44
pub fn get_event_name(event: &Event) -> &'static str {
55
match event {
6+
Event::OpenChannelRequest { .. } => "open channel request",
67
Event::FundingGenerationReady { .. } => "funding generation ready",
8+
Event::ChannelReady { .. } => "channel ready",
79
Event::PaymentReceived { .. } => "payment received",
810
Event::PaymentClaimed { .. } => "payment claimed",
911
Event::PaymentSent { .. } => "payment sent",
@@ -17,7 +19,6 @@ pub fn get_event_name(event: &Event) -> &'static str {
1719
Event::PaymentForwarded { .. } => "payment forwarded",
1820
Event::ChannelClosed { .. } => "channel closed",
1921
Event::DiscardFunding { .. } => "discard funding",
20-
Event::OpenChannelRequest { .. } => "open channel request",
2122
Event::HTLCHandlingFailed { .. } => "HTLC handling failed",
2223
}
2324
}

lexe-ln/src/sync.rs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ use std::collections::HashMap;
22
use std::marker::PhantomData;
33
use std::sync::Arc;
44

5-
use anyhow::{anyhow, Context};
5+
use anyhow::{anyhow, bail, Context};
66
use bitcoin::blockdata::block::BlockHeader;
77
use bitcoin::BlockHash;
88
use common::cli::Network;
99
use common::shutdown::ShutdownChannel;
1010
use common::task::LxTask;
1111
use lightning::chain::transaction::{OutPoint, TransactionData};
12-
use lightning::chain::{Listen, Watch};
12+
use lightning::chain::{ChannelMonitorUpdateStatus, Listen, Watch};
1313
use lightning_block_sync::poll::{ChainPoller, ValidatedBlockHeader};
1414
use lightning_block_sync::{init as block_sync_init, SpvClient};
1515
use tokio::sync::mpsc;
@@ -243,12 +243,15 @@ where
243243
if let LxListener::ChannelMonitor(cmcl) = chain_listener.listener {
244244
let (channel_monitor, funding_outpoint) =
245245
cmcl.into_monitor_and_outpoint();
246-
chain_monitor
247-
.watch_channel(funding_outpoint, channel_monitor)
248-
.map_err(|e| anyhow!("{e:?}"))
249-
.context(
250-
"Couldn't pass channel monitor to chain monitor",
251-
)?;
246+
let status = chain_monitor
247+
.watch_channel(funding_outpoint, channel_monitor);
248+
match status {
249+
ChannelMonitorUpdateStatus::Completed => {}
250+
ChannelMonitorUpdateStatus::InProgress => {}
251+
ChannelMonitorUpdateStatus::PermanentFailure => {
252+
bail!("Channel monitor update permanently failed")
253+
}
254+
}
252255
}
253256
}
254257

0 commit comments

Comments
 (0)