Skip to content

Commit 057178c

Browse files
committed
node+cargo: Use single thread, remove LDK bgp
1 parent 073f00a commit 057178c

File tree

6 files changed

+24
-61
lines changed

6 files changed

+24
-61
lines changed

Cargo.lock

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

common/Cargo.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ bitcoin-bech32 = "0.12"
2222
# lightning-block-sync = { version = "0.0.108", features = [ "rpc-client" ] }
2323
# lightning-invoice = { version = "0.16" }
2424
# lightning-net-tokio = { version = "0.0.108" }
25-
# lightning-background-processor = { version = "0.0.108" }
2625
# lightning-rapid-gossip-sync = { version = "0.0.108" }
2726

2827
# TODO Switch to back to crates.io version after LDK with lightning-net-tokio
@@ -31,15 +30,13 @@ bitcoin-bech32 = "0.12"
3130
# lightning-block-sync = { git = "https://github.com/lexe-tech/rust-lightning", features = [ "rpc-client" ], branch = "net-tokio-connect-v0.0.108" }
3231
lightning-invoice = { git = "https://github.com/lexe-tech/rust-lightning", branch = "net-tokio-connect-v0.0.108" }
3332
# lightning-net-tokio = { git = "https://github.com/lexe-tech/rust-lightning", branch = "net-tokio-connect-v0.0.108" }
34-
# lightning-background-processor = { git = "https://github.com/lexe-tech/rust-lightning", branch = "net-tokio-connect-v0.0.108" }
3533
# lightning-rapid-gossip-sync = { git = "https://github.com/lexe-tech/rust-lightning", branch = "net-tokio-connect-v0.0.108" }
3634

3735
# NOTE For debugging and testing patches during local development
3836
# lightning = { path = "../../ldk/lightning", features = ["max_level_trace"]}
3937
# lightning-block-sync = { path = "../../ldk/lightning-block-sync", features = [ "rpc-client" ] }
4038
# lightning-invoice = { path = "../../ldk/lightning-invoice" }
4139
# lightning-net-tokio = { path = "../../ldk/lightning-net-tokio" }
42-
# lightning-background-processor = { path = "../../ldk/lightning-background-processor" }
4340
# lightning-rapid-gossip-sync = { path = "../../ldk/lightning-rapid-gossip-sync" }
4441

4542
# --- GENERAL --- #

node/Cargo.toml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ base64 = "0.13.0"
2929
# lightning-block-sync = { version = "0.0.108", features = [ "rpc-client" ] }
3030
# lightning-invoice = { version = "0.16" }
3131
# lightning-net-tokio = { version = "0.0.108" }
32-
# lightning-background-processor = { version = "0.0.108" }
3332
# lightning-rapid-gossip-sync = { version = "0.0.108" }
3433

3534
# TODO Switch to back to crates.io version after LDK with lightning-net-tokio
@@ -38,15 +37,13 @@ lightning = { git = "https://github.com/lexe-tech/rust-lightning", features = ["
3837
lightning-block-sync = { git = "https://github.com/lexe-tech/rust-lightning", features = [ "rpc-client" ], branch = "net-tokio-connect-v0.0.108" }
3938
lightning-invoice = { git = "https://github.com/lexe-tech/rust-lightning", branch = "net-tokio-connect-v0.0.108" }
4039
lightning-net-tokio = { git = "https://github.com/lexe-tech/rust-lightning", branch = "net-tokio-connect-v0.0.108" }
41-
lightning-background-processor = { git = "https://github.com/lexe-tech/rust-lightning", branch = "net-tokio-connect-v0.0.108" }
4240
lightning-rapid-gossip-sync = { git = "https://github.com/lexe-tech/rust-lightning", branch = "net-tokio-connect-v0.0.108" }
4341

4442
# NOTE For debugging and testing patches during local development
4543
# lightning = { path = "../../ldk/lightning", features = ["max_level_trace"]}
4644
# lightning-block-sync = { path = "../../ldk/lightning-block-sync", features = [ "rpc-client" ] }
4745
# lightning-invoice = { path = "../../ldk/lightning-invoice" }
4846
# lightning-net-tokio = { path = "../../ldk/lightning-net-tokio" }
49-
# lightning-background-processor = { path = "../../ldk/lightning-background-processor" }
5047
# lightning-rapid-gossip-sync = { path = "../../ldk/lightning-rapid-gossip-sync" }
5148

5249
# ---UTILITIES--- #
@@ -105,7 +102,6 @@ tokio = { version = "=1.15.0", default-features = false, features = [
105102
"macros",
106103
"net",
107104
"rt",
108-
"rt-multi-thread",
109105
"sync",
110106
"time"
111107
] }
@@ -120,7 +116,6 @@ tokio = { version = "=1.15.0", default-features = false, features = [
120116
"io-util",
121117
"macros",
122118
"rt",
123-
"rt-multi-thread",
124119
"sync",
125120
"test-util", # Used to pause time in inactivity_timer::tests
126121
"time"
@@ -136,4 +131,5 @@ proptest = "1"
136131
# stack size (in bytes) for each thread, the default stack size is 0x20000.
137132
stack-size=0x200000
138133
# Gotcha: Don't forget to count the main thread when counting number of threads
139-
threads=7
134+
# We only need 1 thread at the moment
135+
threads=1

node/src/cli/mod.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,7 @@ impl Args {
2121
pub fn run(self) -> anyhow::Result<()> {
2222
match self.cmd {
2323
NodeCommand::Start(args) => {
24-
// TODO(phlip9): set runtime max_blocking_threads and
25-
// worker_threads to a reasonable value, then match that value
26-
// in the Cargo.toml SGX metadata.
27-
let rt = tokio::runtime::Builder::new_multi_thread()
24+
let rt = tokio::runtime::Builder::new_current_thread()
2825
.enable_all()
2926
.build()
3027
.expect("Failed to build tokio runtime");

node/src/command/test/mod.rs

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
1-
//! Command tests.
2-
//!
3-
//! Note that all tests which call `CommandTestHarness::init()` must use a
4-
//! multi-threaded runtime, since `LexeNode::init()` starts the
5-
//! `BackgroundProcessor` which requires its own OS thread. A single worker
6-
//! thread should be enough.
7-
81
use std::net::SocketAddr;
92
use std::str::FromStr;
103
use std::sync::Arc;
@@ -189,7 +182,7 @@ impl CommandTestHarness {
189182
}
190183

191184
/// Tests that a node can initialize, sync, and shutdown.
192-
#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
185+
#[tokio::test]
193186
async fn init_sync_shutdown() {
194187
let mut args = default_args();
195188
args.shutdown_after_sync_if_no_activity = true;
@@ -199,7 +192,7 @@ async fn init_sync_shutdown() {
199192
}
200193

201194
/// Tests the node_info handler.
202-
#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
195+
#[tokio::test]
203196
async fn node_info() {
204197
let args = default_args();
205198
let h = CommandTestHarness::init(args).await;
@@ -208,7 +201,7 @@ async fn node_info() {
208201
}
209202

210203
/// Tests the list_channels handler.
211-
#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
204+
#[tokio::test]
212205
async fn list_channels() {
213206
let args = default_args();
214207
let h = CommandTestHarness::init(args).await;
@@ -217,7 +210,7 @@ async fn list_channels() {
217210
}
218211

219212
/// Tests connecting two nodes to each other.
220-
#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
213+
#[tokio::test]
221214
async fn connect_peer() {
222215
let args1 = default_args_for_user(UserPk::from_i64(1));
223216
let args2 = default_args_for_user(UserPk::from_i64(2));
@@ -266,7 +259,7 @@ async fn connect_peer() {
266259
}
267260

268261
/// Tests opening a channel
269-
#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
262+
#[tokio::test]
270263
async fn open_channel() {
271264
let mut args1 = default_args_for_user(UserPk::from_i64(1));
272265
let mut args2 = default_args_for_user(UserPk::from_i64(2));

node/src/lexe/persister.rs

Lines changed: 16 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -414,18 +414,14 @@ impl Persist<SignerType> for InnerPersister {
414414
);
415415

416416
// Run an async fn inside a sync fn inside a Tokio runtime
417-
tokio::task::block_in_place(|| {
418-
Handle::current()
419-
.block_on(async move { self.api.create_file(cm_file).await })
420-
})
421-
.map(|_| ())
422-
.map_err(|e| {
423-
// Even though this is a temporary failure that can be retried,
424-
// we should still log it
425-
error!("Could not persist new channel monitor: {:#}", e);
426-
// TODO(max): After the async dance this failure should be permanent
427-
ChannelMonitorUpdateErr::TemporaryFailure
428-
})
417+
Handle::current()
418+
.block_on(async move { self.api.create_file(cm_file).await })
419+
.map(|_| ())
420+
.map_err(|e| {
421+
// TODO(max): Implement durability then make this err permanent
422+
error!("Could not persist new channel monitor: {:#}", e);
423+
ChannelMonitorUpdateErr::TemporaryFailure
424+
})
429425
}
430426

431427
fn update_persisted_channel(
@@ -451,17 +447,13 @@ impl Persist<SignerType> for InnerPersister {
451447
);
452448

453449
// Run an async fn inside a sync fn inside a Tokio runtime
454-
tokio::task::block_in_place(|| {
455-
Handle::current()
456-
.block_on(async move { self.api.upsert_file(cm_file).await })
457-
})
458-
.map(|_| ())
459-
.map_err(|e| {
460-
// Even though this is a temporary failure that can be retried,
461-
// we should still log it
462-
error!("Could not update persisted channel monitor: {:#}", e);
463-
// TODO(max): After the async dance this failure should be permanent
464-
ChannelMonitorUpdateErr::TemporaryFailure
465-
})
450+
Handle::current()
451+
.block_on(async move { self.api.upsert_file(cm_file).await })
452+
.map(|_| ())
453+
.map_err(|e| {
454+
// TODO(max): Implement durability then make this err permanent
455+
error!("Could not update persisted channel monitor: {:#}", e);
456+
ChannelMonitorUpdateErr::TemporaryFailure
457+
})
466458
}
467459
}

0 commit comments

Comments
 (0)