Skip to content

Commit 7febd5b

Browse files
authored
Merge branch 'lightningdevkit:main' into main
2 parents 1969bb7 + d355ce1 commit 7febd5b

File tree

39 files changed

+922
-312
lines changed

39 files changed

+922
-312
lines changed

.github/workflows/build.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ jobs:
168168
done
169169
# check no-std compatibility across dependencies
170170
cd no-std-check
171-
cargo check --verbose --color always
171+
cargo check --verbose --color always --features lightning-transaction-sync
172172
- name: Build no-std-check on Rust ${{ matrix.toolchain }} for ARM Embedded
173173
if: "matrix.build-no-std && matrix.platform == 'ubuntu-latest'"
174174
run: |

CHANGELOG.md

+114
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,117 @@
1+
# 0.0.114 - Mar 3, 2023 - "Faster Async BOLT12 Retries"
2+
3+
## API Updates
4+
* `InvoicePayer` has been removed and its features moved directly into
5+
`ChannelManager`. As such it now requires a simplified `Router` and supports
6+
`send_payment_with_retry` (and friends). `ChannelManager::retry_payment` was
7+
removed in favor of the automated retries. Invoice payment utilities in
8+
`lightning-invoice` now call the new code (#1812, #1916, #1929, #2007, etc).
9+
* `Sign`/`BaseSign` has been renamed `ChannelSigner`, with `EcdsaChannelSigner`
10+
split out in anticipation of future schnorr/taproot support (#1967).
11+
* The catch-all `KeysInterface` was split into `EntropySource`, `NodeSigner`,
12+
and `SignerProvider`. `KeysManager` implements all three (#1910, #1930).
13+
* `KeysInterface::get_node_secret` is now `KeysManager::get_node_secret_key`
14+
and is no longer required for external signers (#1951, #2070).
15+
* A `lightning-transaction-sync` crate has been added which implements keeping
16+
LDK in sync with the chain via an esplora server (#1870). Note that it can
17+
only be used on nodes that *never* ran a previous version of LDK.
18+
* `Score` is updated in `BackgroundProcessor` instead of via `Router` (#1996).
19+
* `ChainAccess::get_utxo` (now `UtxoAccess`) can now be resolved async (#1980).
20+
* BOLT12 `Offer`, `InvoiceRequest`, `Invoice` and `Refund` structs as well as
21+
associated builders have been added. Such invoices cannot yet be paid due to
22+
missing support for blinded path payments (#1927, #1908, #1926).
23+
* A `lightning-custom-message` crate has been added to make combining multiple
24+
custom messages into one enum/handler easier (#1832).
25+
* `Event::PaymentPathFailure` is now generated for failure to send an HTLC
26+
over the first hop on our local channel (#2014, #2043).
27+
* `lightning-net-tokio` no longer requires an `Arc` on `PeerManager` (#1968).
28+
* `ChannelManager::list_recent_payments` was added (#1873).
29+
* `lightning-background-processor` `std` is now optional in async mode (#1962).
30+
* `create_phantom_invoice` can now be used in `no-std` (#1985).
31+
* The required final CLTV delta on inbound payments is now configurable (#1878)
32+
* bitcoind RPC error code and message are now surfaced in `block-sync` (#2057).
33+
* Get `historical_estimated_channel_liquidity_probabilities` was added (#1961).
34+
* `ChannelManager::fail_htlc_backwards_with_reason` was added (#1948).
35+
* Macros which implement serialization using TLVs or straight writing of struct
36+
fields are now public (#1823, #1976, #1977).
37+
38+
## Backwards Compatibility
39+
* Any inbound payments with a custom final CLTV delta will be rejected by LDK
40+
if you downgrade prior to receipt (#1878).
41+
* `Event::PaymentPathFailed::network_update` will always be `None` if an
42+
0.0.114-generated event is read by a prior version of LDK (#2043).
43+
* `Event::PaymentPathFailed::all_paths_removed` will always be false if an
44+
0.0.114-generated event is read by a prior version of LDK. Users who rely on
45+
it to determine payment retries should migrate to `Event::PaymentFailed`, in
46+
a separate release prior to upgrading to LDK 0.0.114 if downgrading is
47+
supported (#2043).
48+
49+
## Performance Improvements
50+
* Channel data is now stored per-peer and channel updates across multiple
51+
peers can be operated on simultaneously (#1507).
52+
* Routefinding is roughly 1.5x faster (#1799).
53+
* Deserializing a `NetworkGraph` is roughly 6x faster (#2016).
54+
* Memory usage for a `NetworkGraph` has been reduced substantially (#2040).
55+
* `KeysInterface::get_secure_random_bytes` is roughly 200x faster (#1974).
56+
57+
## Bug Fixes
58+
* Fixed a bug where a delay in processing a `PaymentSent` event longer than the
59+
time taken to persist a `ChannelMonitor` update, when occurring immediately
60+
prior to a crash, may result in the `PaymentSent` event being lost (#2048).
61+
* Fixed spurious rejections of rapid gossip sync data when the graph has been
62+
updated by other means between gossip syncs (#2046).
63+
* Fixed a panic in `KeysManager` when the high bit of `starting_time_nanos`
64+
is set (#1935).
65+
* Resolved an issue where the `ChannelManager::get_persistable_update_future`
66+
future would fail to wake until a second notification occurs (#2064).
67+
* Resolved a memory leak when using `ChannelManager::send_probe` (#2037).
68+
* Fixed a deadlock on some platforms at least when using async `ChannelMonitor`
69+
updating (#2006).
70+
* Removed debug-only assertions which were reachable in threaded code (#1964).
71+
* In some cases when payment sending fails on our local channel retries no
72+
longer take the same path and thus never succeed (#2014).
73+
* Retries for spontaneous payments have been fixed (#2002).
74+
* Return an `Err` if `lightning-persister` fails to read the directory listing
75+
rather than panicing (#1943).
76+
* `peer_disconnected` will now never be called without `peer_connected` (#2035)
77+
78+
## Security
79+
0.0.114 fixes several denial-of-service vulnerabilities which are reachable from
80+
untrusted input from channel counterparties or in deployments accepting inbound
81+
connections or channels. It also fixes a denial-of-service vulnerability in rare
82+
cases in the route finding logic.
83+
* The number of pending un-funded channels as well as peers without funded
84+
channels is now limited to avoid denial of service (#1988).
85+
* A second `channel_ready` message received immediately after the first could
86+
lead to a spurious panic (#2071). This issue was introduced with 0conf
87+
support in LDK 0.0.107.
88+
* A division-by-zero issue was fixed in the `ProbabilisticScorer` if the amount
89+
being sent (including previous-hop fees) is equal to a channel's capacity
90+
while walking the graph (#2072). The division-by-zero was introduced with
91+
historical data tracking in LDK 0.0.112.
92+
93+
In total, this release features 130 files changed, 21457 insertions, 10113
94+
deletions in 343 commits from 18 authors, in alphabetical order:
95+
* Alec Chen
96+
* Allan Douglas R. de Oliveira
97+
* Andrei
98+
* Arik Sosman
99+
* Daniel Granhão
100+
* Duncan Dean
101+
* Elias Rohrer
102+
* Jeffrey Czyz
103+
* John Cantrell
104+
* Kurtsley
105+
* Matt Corallo
106+
* Max Fang
107+
* Omer Yacine
108+
* Valentine Wallace
109+
* Viktor Tigerström
110+
* Wilmer Paulino
111+
* benthecarman
112+
* jurvis
113+
114+
1115
# 0.0.113 - Dec 16, 2022 - "Big Movement Intercepted"
2116

3117
## API Updates

Cargo.toml

+11-5
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,20 @@ exclude = [
1616
"no-std-check",
1717
]
1818

19-
# Our tests do actual crypto and lots of work, the tradeoff for -O1 is well worth it.
20-
# Ideally we would only do this in profile.test, but profile.test only applies to
21-
# the test binary, not dependencies, which means most of the critical code still
22-
# gets compiled as -O0. See
19+
# Our tests do actual crypto and lots of work, the tradeoff for -O2 is well
20+
# worth it. Note that we only apply optimizations to dependencies, not workspace
21+
# crates themselves.
2322
# https://doc.rust-lang.org/cargo/reference/profiles.html#profile-selection
23+
[profile.dev.package."*"]
24+
opt-level = 2
25+
26+
# It appears some minimal optimizations are required to inline many std methods
27+
# and reduce the otherwise-substantial time spent in std self-checks. We do so
28+
# here but ensure we keep LTO disabled as otherwise we're re-optimizing all our
29+
# dependencies every time we make any local changes.
2430
[profile.dev]
2531
opt-level = 1
26-
panic = "abort"
32+
lto = "off"
2733

2834
[profile.release]
2935
opt-level = 3

fuzz/src/full_stack.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ use lightning::ln::msgs::{self, DecodeError};
4242
use lightning::ln::script::ShutdownScript;
4343
use lightning::routing::gossip::{P2PGossipSync, NetworkGraph};
4444
use lightning::routing::utxo::UtxoLookup;
45-
use lightning::routing::router::{find_route, InFlightHtlcs, PaymentParameters, Route, RouteHop, RouteParameters, Router};
45+
use lightning::routing::router::{find_route, InFlightHtlcs, PaymentParameters, Route, RouteParameters, Router};
4646
use lightning::routing::scoring::FixedPenaltyScorer;
4747
use lightning::util::config::UserConfig;
4848
use lightning::util::errors::APIError;

fuzz/src/router.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use lightning::ln::msgs;
1717
use lightning::routing::gossip::{NetworkGraph, RoutingFees};
1818
use lightning::routing::utxo::{UtxoFuture, UtxoLookup, UtxoLookupError, UtxoResult};
1919
use lightning::routing::router::{find_route, PaymentParameters, RouteHint, RouteHintHop, RouteParameters};
20-
use lightning::routing::scoring::FixedPenaltyScorer;
20+
use lightning::routing::scoring::ProbabilisticScorer;
2121
use lightning::util::config::UserConfig;
2222
use lightning::util::ser::Readable;
2323

@@ -292,7 +292,7 @@ pub fn do_test<Out: test_logger::Output>(data: &[u8], out: Out) {
292292
}]));
293293
}
294294
}
295-
let scorer = FixedPenaltyScorer::with_penalty(0);
295+
let scorer = ProbabilisticScorer::new(Default::default(), &net_graph, &logger);
296296
let random_seed_bytes: [u8; 32] = [get_slice!(1)[0]; 32];
297297
for target in node_pks.iter() {
298298
let final_value_msat = slice_to_be64(get_slice!(8));

lightning-background-processor/Cargo.toml

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "lightning-background-processor"
3-
version = "0.0.113"
3+
version = "0.0.114"
44
authors = ["Valentine Wallace <[email protected]>"]
55
license = "MIT OR Apache-2.0"
66
repository = "http://github.com/lightningdevkit/rust-lightning"
@@ -21,11 +21,11 @@ default = ["std"]
2121

2222
[dependencies]
2323
bitcoin = { version = "0.29.0", default-features = false }
24-
lightning = { version = "0.0.113", path = "../lightning", default-features = false }
25-
lightning-rapid-gossip-sync = { version = "0.0.113", path = "../lightning-rapid-gossip-sync", default-features = false }
24+
lightning = { version = "0.0.114", path = "../lightning", default-features = false }
25+
lightning-rapid-gossip-sync = { version = "0.0.114", path = "../lightning-rapid-gossip-sync", default-features = false }
2626
futures-util = { version = "0.3", default-features = false, features = ["async-await-macro"], optional = true }
2727

2828
[dev-dependencies]
29-
lightning = { version = "0.0.113", path = "../lightning", features = ["_test_utils"] }
30-
lightning-invoice = { version = "0.21.0", path = "../lightning-invoice" }
31-
lightning-persister = { version = "0.0.113", path = "../lightning-persister" }
29+
lightning = { version = "0.0.114", path = "../lightning", features = ["_test_utils"] }
30+
lightning-invoice = { version = "0.22.0", path = "../lightning-invoice" }
31+
lightning-persister = { version = "0.0.114", path = "../lightning-persister" }

lightning-background-processor/src/lib.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ use lightning::routing::gossip::{NetworkGraph, P2PGossipSync};
3333
use lightning::routing::utxo::UtxoLookup;
3434
use lightning::routing::router::Router;
3535
use lightning::routing::scoring::{Score, WriteableScore};
36-
use lightning::util::events::{Event, EventHandler, EventsProvider, PathFailure};
36+
use lightning::util::events::{Event, PathFailure};
37+
#[cfg(feature = "std")]
38+
use lightning::util::events::{EventHandler, EventsProvider};
3739
use lightning::util::logger::Logger;
3840
use lightning::util::persist::Persister;
3941
use lightning_rapid_gossip_sync::RapidGossipSync;

lightning-block-sync/Cargo.toml

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "lightning-block-sync"
3-
version = "0.0.113"
3+
version = "0.0.114"
44
authors = ["Jeffrey Czyz", "Matt Corallo"]
55
license = "MIT OR Apache-2.0"
66
repository = "http://github.com/lightningdevkit/rust-lightning"
@@ -19,13 +19,13 @@ rpc-client = [ "serde", "serde_json", "chunked_transfer" ]
1919

2020
[dependencies]
2121
bitcoin = "0.29.0"
22-
lightning = { version = "0.0.113", path = "../lightning" }
22+
lightning = { version = "0.0.114", path = "../lightning" }
2323
futures-util = { version = "0.3" }
2424
tokio = { version = "1.0", features = [ "io-util", "net", "time" ], optional = true }
2525
serde = { version = "1.0", features = ["derive"], optional = true }
2626
serde_json = { version = "1.0", optional = true }
2727
chunked_transfer = { version = "1.4", optional = true }
2828

2929
[dev-dependencies]
30-
lightning = { version = "0.0.113", path = "../lightning", features = ["_test_utils"] }
30+
lightning = { version = "0.0.114", path = "../lightning", features = ["_test_utils"] }
3131
tokio = { version = "~1.14", features = [ "macros", "rt" ] }

lightning-block-sync/src/lib.rs

+3
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,9 @@ impl BlockSourceError {
132132
}
133133

134134
/// Converts the error into the underlying error.
135+
///
136+
/// May contain an [`std::io::Error`] from the [`BlockSource`]. See implementations for further
137+
/// details, if any.
135138
pub fn into_inner(self) -> Box<dyn std::error::Error + Send + Sync> {
136139
self.error
137140
}

lightning-block-sync/src/rpc.rs

+33-3
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,31 @@ use serde_json;
1313

1414
use std::convert::TryFrom;
1515
use std::convert::TryInto;
16+
use std::error::Error;
17+
use std::fmt;
1618
use std::sync::atomic::{AtomicUsize, Ordering};
1719

20+
/// An error returned by the RPC server.
21+
#[derive(Debug)]
22+
pub struct RpcError {
23+
/// The error code.
24+
pub code: i64,
25+
/// The error message.
26+
pub message: String,
27+
}
28+
29+
impl fmt::Display for RpcError {
30+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
31+
write!(f, "RPC error {}: {}", self.code, self.message)
32+
}
33+
}
34+
35+
impl Error for RpcError {}
36+
1837
/// A simple RPC client for calling methods using HTTP `POST`.
38+
///
39+
/// Implements [`BlockSource`] and may return an `Err` containing [`RpcError`]. See
40+
/// [`RpcClient::call_method`] for details.
1941
pub struct RpcClient {
2042
basic_auth: String,
2143
endpoint: HttpEndpoint,
@@ -38,6 +60,9 @@ impl RpcClient {
3860
}
3961

4062
/// Calls a method with the response encoded in JSON format and interpreted as type `T`.
63+
///
64+
/// When an `Err` is returned, [`std::io::Error::into_inner`] may contain an [`RpcError`] if
65+
/// [`std::io::Error::kind`] is [`std::io::ErrorKind::Other`].
4166
pub async fn call_method<T>(&self, method: &str, params: &[serde_json::Value]) -> std::io::Result<T>
4267
where JsonResponse: TryFrom<Vec<u8>, Error = std::io::Error> + TryInto<T, Error = std::io::Error> {
4368
let host = format!("{}:{}", self.endpoint.host(), self.endpoint.port());
@@ -69,8 +94,11 @@ impl RpcClient {
6994
let error = &response["error"];
7095
if !error.is_null() {
7196
// TODO: Examine error code for a more precise std::io::ErrorKind.
72-
let message = error["message"].as_str().unwrap_or("unknown error");
73-
return Err(std::io::Error::new(std::io::ErrorKind::Other, message));
97+
let rpc_error = RpcError {
98+
code: error["code"].as_i64().unwrap_or(-1),
99+
message: error["message"].as_str().unwrap_or("unknown error").to_string()
100+
};
101+
return Err(std::io::Error::new(std::io::ErrorKind::Other, rpc_error));
74102
}
75103

76104
let result = &mut response["result"];
@@ -163,7 +191,9 @@ mod tests {
163191
match client.call_method::<u64>("getblock", &[invalid_block_hash]).await {
164192
Err(e) => {
165193
assert_eq!(e.kind(), std::io::ErrorKind::Other);
166-
assert_eq!(e.get_ref().unwrap().to_string(), "invalid parameter");
194+
let rpc_error: Box<RpcError> = e.into_inner().unwrap().downcast().unwrap();
195+
assert_eq!(rpc_error.code, -8);
196+
assert_eq!(rpc_error.message, "invalid parameter");
167197
},
168198
Ok(_) => panic!("Expected error"),
169199
}

lightning-custom-message/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "lightning-custom-message"
3-
version = "0.0.113"
3+
version = "0.0.114"
44
authors = ["Jeffrey Czyz"]
55
license = "MIT OR Apache-2.0"
66
repository = "http://github.com/lightningdevkit/rust-lightning"
@@ -15,4 +15,4 @@ rustdoc-args = ["--cfg", "docsrs"]
1515

1616
[dependencies]
1717
bitcoin = "0.29.0"
18-
lightning = { version = "0.0.113", path = "../lightning" }
18+
lightning = { version = "0.0.114", path = "../lightning" }

lightning-invoice/Cargo.toml

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "lightning-invoice"
33
description = "Data structures to parse and serialize BOLT11 lightning invoices"
4-
version = "0.21.0"
4+
version = "0.22.0"
55
authors = ["Sebastian Geisler <[email protected]>"]
66
documentation = "https://docs.rs/lightning-invoice/"
77
license = "MIT OR Apache-2.0"
@@ -21,14 +21,14 @@ std = ["bitcoin_hashes/std", "num-traits/std", "lightning/std", "bech32/std"]
2121

2222
[dependencies]
2323
bech32 = { version = "0.9.0", default-features = false }
24-
lightning = { version = "0.0.113", path = "../lightning", default-features = false }
24+
lightning = { version = "0.0.114", path = "../lightning", default-features = false }
2525
secp256k1 = { version = "0.24.0", default-features = false, features = ["recovery", "alloc"] }
2626
num-traits = { version = "0.2.8", default-features = false }
2727
bitcoin_hashes = { version = "0.11", default-features = false }
2828
hashbrown = { version = "0.8", optional = true }
2929
serde = { version = "1.0.118", optional = true }
3030

3131
[dev-dependencies]
32-
lightning = { version = "0.0.113", path = "../lightning", default-features = false, features = ["_test_utils"] }
32+
lightning = { version = "0.0.114", path = "../lightning", default-features = false, features = ["_test_utils"] }
3333
hex = "0.4"
3434
serde_json = { version = "1"}

lightning-net-tokio/Cargo.toml

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "lightning-net-tokio"
3-
version = "0.0.113"
3+
version = "0.0.114"
44
authors = ["Matt Corallo"]
55
license = "MIT OR Apache-2.0"
66
repository = "https://github.com/lightningdevkit/rust-lightning/"
@@ -16,9 +16,9 @@ rustdoc-args = ["--cfg", "docsrs"]
1616

1717
[dependencies]
1818
bitcoin = "0.29.0"
19-
lightning = { version = "0.0.113", path = "../lightning" }
19+
lightning = { version = "0.0.114", path = "../lightning" }
2020
tokio = { version = "1.0", features = [ "io-util", "macros", "rt", "sync", "net", "time" ] }
2121

2222
[dev-dependencies]
2323
tokio = { version = "~1.14", features = [ "io-util", "macros", "rt", "rt-multi-thread", "sync", "net", "time" ] }
24-
lightning = { version = "0.0.113", path = "../lightning", features = ["_test_utils"] }
24+
lightning = { version = "0.0.114", path = "../lightning", features = ["_test_utils"] }

lightning-persister/Cargo.toml

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "lightning-persister"
3-
version = "0.0.113"
3+
version = "0.0.114"
44
authors = ["Valentine Wallace", "Matt Corallo"]
55
license = "MIT OR Apache-2.0"
66
repository = "https://github.com/lightningdevkit/rust-lightning/"
@@ -18,11 +18,11 @@ _bench_unstable = ["lightning/_bench_unstable"]
1818

1919
[dependencies]
2020
bitcoin = "0.29.0"
21-
lightning = { version = "0.0.113", path = "../lightning" }
21+
lightning = { version = "0.0.114", path = "../lightning" }
2222
libc = "0.2"
2323

2424
[target.'cfg(windows)'.dependencies]
2525
winapi = { version = "0.3", features = ["winbase"] }
2626

2727
[dev-dependencies]
28-
lightning = { version = "0.0.113", path = "../lightning", features = ["_test_utils"] }
28+
lightning = { version = "0.0.114", path = "../lightning", features = ["_test_utils"] }

0 commit comments

Comments
 (0)