Skip to content

Commit

Permalink
Merge pull request #1118 from get10101/fix/snappy-protocols
Browse files Browse the repository at this point in the history
Check for new DLC-related messages 25 times more often
  • Loading branch information
luckysori authored Aug 21, 2023
2 parents 03e0b84 + 2f7c4cd commit 8ba8462
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 35 deletions.
7 changes: 4 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

- Add support for push notifications
- Added new setting to coordinator to configure max channel size to traders
- Add support for push notifications.
- Added new setting to coordinator to configure max channel size to traders.
- Speed up DLC channel setup and settlement by checking for messages more often.

## [1.2.0] - 2023-08-04

- Automatically retry spendable outputs if not successfully published
- Automatically retry spendable outputs if not successfully published.
- Permit the closure of the LN-DLC channel in any intermediate state.

## [1.1.0] - 2023-07-27
Expand Down
26 changes: 13 additions & 13 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 12 additions & 12 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@ resolver = "2"

[patch.crates-io]
# We should usually track the `feature/ln-dlc-channels[-10101]` branch
dlc-manager = { git = "https://github.com/p2pderivatives/rust-dlc", rev = "78a8b46" }
dlc-messages = { git = "https://github.com/p2pderivatives/rust-dlc", rev = "78a8b46" }
dlc = { git = "https://github.com/p2pderivatives/rust-dlc", rev = "78a8b46" }
dlc-sled-storage-provider = { git = "https://github.com/p2pderivatives/rust-dlc", rev = "78a8b46" }
p2pd-oracle-client = { git = "https://github.com/p2pderivatives/rust-dlc", rev = "78a8b46" }
dlc-trie = { git = "https://github.com/p2pderivatives/rust-dlc", rev = "78a8b46" }
simple-wallet = { git = "https://github.com/p2pderivatives/rust-dlc", rev = "78a8b46" }
dlc-manager = { git = "https://github.com/p2pderivatives/rust-dlc", rev = "22b7052" }
dlc-messages = { git = "https://github.com/p2pderivatives/rust-dlc", rev = "22b7052" }
dlc = { git = "https://github.com/p2pderivatives/rust-dlc", rev = "22b7052" }
dlc-sled-storage-provider = { git = "https://github.com/p2pderivatives/rust-dlc", rev = "22b7052" }
p2pd-oracle-client = { git = "https://github.com/p2pderivatives/rust-dlc", rev = "22b7052" }
dlc-trie = { git = "https://github.com/p2pderivatives/rust-dlc", rev = "22b7052" }
simple-wallet = { git = "https://github.com/p2pderivatives/rust-dlc", rev = "22b7052" }

# We should usually track the `split-tx-experiment[-10101]` branch
lightning = { git = "https://github.com/p2pderivatives/rust-lightning/", rev = "26db9546" }
lightning-background-processor = { git = "https://github.com/p2pderivatives/rust-lightning/", rev = "26db9546" }
lightning-transaction-sync = { git = "https://github.com/p2pderivatives/rust-lightning/", rev = "26db9546" }
lightning-net-tokio = { git = "https://github.com/p2pderivatives/rust-lightning/", rev = "26db9546" }
lightning-persister = { git = "https://github.com/p2pderivatives/rust-lightning/", rev = "26db9546" }
lightning = { git = "https://github.com/p2pderivatives/rust-lightning/", rev = "420d961d" }
lightning-background-processor = { git = "https://github.com/p2pderivatives/rust-lightning/", rev = "420d961d" }
lightning-transaction-sync = { git = "https://github.com/p2pderivatives/rust-lightning/", rev = "420d961d" }
lightning-net-tokio = { git = "https://github.com/p2pderivatives/rust-lightning/", rev = "420d961d" }
lightning-persister = { git = "https://github.com/p2pderivatives/rust-lightning/", rev = "420d961d" }

rust-bitcoin-coin-selection = { git = "https://github.com/p2pderivatives/rust-bitcoin-coin-selection" }
2 changes: 1 addition & 1 deletion coordinator/src/bin/coordinator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ use tokio::task::spawn_blocking;
use tracing::metadata::LevelFilter;

const PROCESS_PROMETHEUS_METRICS: Duration = Duration::from_secs(10);
const PROCESS_INCOMING_DLC_MESSAGES_INTERVAL: Duration = Duration::from_secs(5);
const PROCESS_INCOMING_DLC_MESSAGES_INTERVAL: Duration = Duration::from_millis(200);
const EXPIRED_POSITION_SYNC_INTERVAL: Duration = Duration::from_secs(300);
const CLOSED_POSITION_SYNC_INTERVAL: Duration = Duration::from_secs(30);
const UNREALIZED_PNL_SYNC_INTERVAL: Duration = Duration::from_secs(600);
Expand Down
10 changes: 9 additions & 1 deletion coordinator/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,14 @@ impl Node {

#[autometrics]
pub fn process_incoming_dlc_messages(&self) {
if !self
.inner
.dlc_message_handler
.has_pending_messages_to_process()
{
return;
}

let messages = self
.inner
.dlc_message_handler
Expand All @@ -398,7 +406,7 @@ impl Node {
tracing::error!(
from = %node_id,
kind = %msg_name,
"Failed to process message: {e:#}"
"Failed to process DLC message: {e:#}"
);
}
}
Expand Down
8 changes: 4 additions & 4 deletions mobile/native/src/ln_dlc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,7 @@ pub mod channel_status;

pub use channel_status::ChannelStatus;

static NODE: Storage<Arc<Node>> = Storage::new();

const PROCESS_INCOMING_MESSAGES_INTERVAL: Duration = Duration::from_secs(5);
const PROCESS_INCOMING_DLC_MESSAGES_INTERVAL: Duration = Duration::from_millis(200);
const UPDATE_WALLET_HISTORY_INTERVAL: Duration = Duration::from_secs(5);
const CHECK_OPEN_ORDERS_INTERVAL: Duration = Duration::from_secs(60);

Expand All @@ -80,6 +78,8 @@ const CHECK_OPEN_ORDERS_INTERVAL: Duration = Duration::from_secs(60);
/// exact fee will be know.
pub const FUNDING_TX_WEIGHT_ESTIMATE: u64 = 220;

static NODE: Storage<Arc<Node>> = Storage::new();

pub async fn refresh_wallet_info() -> Result<()> {
let node = NODE.get();
let wallet = node.inner.wallet();
Expand Down Expand Up @@ -226,7 +226,7 @@ pub fn run(data_dir: String, seed_dir: String, runtime: &Runtime) -> Result<()>
spawn_blocking(move || node.process_incoming_dlc_messages())
.await
.expect("To spawn blocking thread");
tokio::time::sleep(PROCESS_INCOMING_MESSAGES_INTERVAL).await;
tokio::time::sleep(PROCESS_INCOMING_DLC_MESSAGES_INTERVAL).await;
}
}
});
Expand Down
10 changes: 9 additions & 1 deletion mobile/native/src/ln_dlc/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,14 @@ impl Node {
}

pub fn process_incoming_dlc_messages(&self) {
if !self
.inner
.dlc_message_handler
.has_pending_messages_to_process()
{
return;
}

let messages = self
.inner
.dlc_message_handler
Expand All @@ -114,7 +122,7 @@ impl Node {
tracing::error!(
from = %node_id,
kind = %msg_name,
"Failed to process message: {e:#}"
"Failed to process DLC message: {e:#}"
);
}
}
Expand Down

0 comments on commit 8ba8462

Please sign in to comment.