Commit graph

3403 commits

Author SHA1 Message Date
dependabot[bot]
d1d0189b2d
Bump codecov/codecov-action from 2 to 3
Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 2 to 3.
- [Release notes](https://github.com/codecov/codecov-action/releases)
- [Changelog](https://github.com/codecov/codecov-action/blob/master/CHANGELOG.md)
- [Commits](https://github.com/codecov/codecov-action/compare/v2...v3)

---
updated-dependencies:
- dependency-name: codecov/codecov-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-04-05 17:32:54 +00:00
Matt Corallo
44c0374ae6
Merge pull request #1409 from TheBlueMatt/2022-04-bindings-invoice-ders
Move lightning-invoice deser errors to lib.rs instead of `pub use`
2022-04-04 15:39:29 +00:00
Matt Corallo
ce5a9f528a Move lightning-invoice deser errors to lib.rs instead of pub use
Having public types in a private module is somewhat awkward from a
readability standpoint, but, more importantly, the bindings logic
has a relatively rough go of converting them - it doesn't implement
`pub use` as its "implement this function" logic is all within the
context of a module. We'd need to keep a set of re-exported things
to implement them when parsing modules...or we could just move two
enums from `de.rs` to `lib.rs` here, which is substantially less
work.
2022-04-04 13:19:41 +00:00
Matt Corallo
0a0f87c00f
Merge pull request #1397 from jkczyz/2022-03-release-0.0.106
Cut 0.0.106
2022-04-03 16:31:54 +00:00
Jeffrey Czyz
de8bb8d261
Bump crate versions to 0.0.106/invoice 0.14 2022-04-03 08:05:08 -05:00
Jeffrey Czyz
427fa99049
Update CHANGELOG for 0.0.106 2022-04-03 08:05:08 -05:00
Matt Corallo
af318312c5
Merge pull request #1399 from jkczyz/2022-03-scoring-tweaks
ProbabilisticScorer improvements
2022-04-02 01:50:55 +00:00
Jeffrey Czyz
5425b2b77e
Add an amount penalty to ProbabilisticScorer
The cost of large payments tends to be dominated by the channel fees. To
avoid this, add an amount penalty to ProbabilisticScorer with a user
configurable multiplier. The multiplier is applied for every 2^20th of
the amount weighted by the negative log10 of the channel's success
probability for the payment.
2022-04-01 15:52:10 -05:00
Jeffrey Czyz
5337f89d8b
Avoid retrying over recently failed channels
In ProbabilisticScorer, the channel liquidity balance is reduced
whenever a payment fails at the corresponding channel. The payment may
still be retried through the channel, however, because the liquidity
penalty is capped. Use u64::max_value instead in this situation to avoid
retrying over the same path. This effectively makes u64::max_value the
penalty for amounts exceeding the upper bound, as well.

As an edge case, avoid using u64::max_value on attempts where the amount
is equal to the effective capacity, which may be the HTLC maximum when
the channel capacity is unknown.
2022-04-01 15:52:10 -05:00
Matt Corallo
6b8ad4ec33
Merge pull request #1398 from jkczyz/2022-03-middle-hop-fix
Router fixes
2022-04-01 19:32:08 +00:00
Matt Corallo
8ddfe66046
Don't consider a path as having hit HTLC-min if it isn't sufficient
During the first pass of path finding, we seek a single path with the
exact payment amount, and only seek additional paths if (a) no single
path can carry the entire balance of the payment or (b) we found a good
path, but along the way we found candidate paths with the potential to
result in a lower total fee. This commit fixes the behavior of (b) -- we
were previously considering some paths to be candidates for a lower fee
when in fact they never would have worked. This caused us to re-run
Dijkstra's when it might not have been beneficial.
2022-03-31 21:36:22 -05:00
Jeffrey Czyz
f9cdf93da0
Select best route by lowest total cost
Selecting only by fees rather than cost (fees plus penalty) may result
in preferring higher cost routes over lower cost ones.
2022-03-31 21:36:18 -05:00
Jeffrey Czyz
30b6873d03
Correctly pick middle hop to victimize
For even-length paths, preferring a later hop avoids overly limiting the
possible paths on the next iteration.
2022-03-30 17:42:00 -05:00
Jeffrey Czyz
37a947bc36
Fix build warnings without grind_signatures 2022-03-30 17:41:42 -05:00
Jeffrey Czyz
aeeafed7d5
Merge pull request #1376 from jurvis/jurvis/persist-networkgraph
Persist NetworkGraph on removal of stale channels
2022-03-30 13:38:39 -07:00
Jurvis Tan
df2e60d101
Use common Persister for persistence tests 2022-03-29 19:38:41 -07:00
Jurvis Tan
6ebc739255
Move expected_bytes to check_persisted_data! macro 2022-03-29 19:38:40 -07:00
Jurvis Tan
afb7aa85cf
Add NetworkGraph persistence
Instead of creating a separate trait for persisting NetworkGraph, use and rename the existing ChannelManagerPersister to handle them both. persist_graph is then called on removal of stale channels and on exit.
2022-03-29 19:38:40 -07:00
Matt Corallo
7671ae5452
Merge pull request #1351 from TheBlueMatt/2022-03-scid-privacy
Implement the SCIDAlias Channel Type and provide SCID Privacy
2022-03-28 20:33:55 +00:00
Matt Corallo
952cee4a16 Add notes about SCID alias rotation to ChannelDetails docs 2022-03-28 14:24:16 +00:00
Matt Corallo
c47acd76e8 Drop the Writeable::encode_with_len method in non-test buidls
There's not a lot of reason to keep it given its used in one place
outside of tests, and this lets us clean up some of the byte_utils
calls that are still lying around.
2022-03-27 17:12:17 +00:00
Matt Corallo
d2256301e8 Use the correct SCID when failing HTLCs to aliased channels
When we fail an HTLC which was destined for a channel that the HTLC
sender didn't know the real SCID for, we should ensure we continue
to use the alias in the channel_update we provide them. Otherwise
we will leak the channel's real SCID to HTLC senders.
2022-03-27 17:12:17 +00:00
Matt Corallo
99b7219cfc Make all callsites to get_channel_update_for_unicast fallible
This reduces unwraps in channelmanager by a good bit, providing
robustness for the upcoming 0conf changes which allow SCIDs to be
missing after a channel is in use, making
`get_channel_update_for_unicast` more fallible.

This also serves as a useful refactor for the next commit,
consolidating the channel_update creation sites which are changed
in the next commit.
2022-03-27 17:12:17 +00:00
Matt Corallo
dc4e62da5d Add simple tests for our SCIDAlias implementation and negotiation 2022-03-27 17:12:17 +00:00
Matt Corallo
2eb6e1f741 Negotiate scid_alias for private channels based on a new config
Because negotiating `scid_alias` for all of our channels will cause
us to create channels which LDK versions prior to 0.0.106 do not
understand, we disable `scid_alias` negotiation by default.
2022-03-27 17:12:17 +00:00
Matt Corallo
5d652bfec8 Add support for the SCIDAlias feature bit in incoming channels
This does not, however, ever send the scid_alias feature bit for
outgoing channels, as that would cause the immediately prior
version of LDK to be unable to read channel data.
2022-03-27 17:12:17 +00:00
Matt Corallo
b42ebd892b Expose chan type in Event::OpenChannelRequest & ChannelDetails
As we add new supported channel types, inbound channels which use
new features may cause backwards-compatibility issues for clients.
If a new channel is opened using new features while a client still
wishes to ensure support for downgrading to a previous version of
LDK, that new channel may cause the `ChannelManager` to fail
deserialization due to unsupported feature flags.

By exposing the channel type flags to the user in channel requests,
users wishing to support downgrading to previous versions of LDK
can reject channels which use channel features which previous
versions of LDK do not understand.
2022-03-27 17:12:17 +00:00
Matt Corallo
41fb56b5be Bump check_commits CI job rustc to 1.57
1.51 (and other earlier versions of `rustc`) appear to refuse to
accept our documentation links due to a bogus failure to resolve
`ChannelTypeFeatures::supports_scid_privacy`.
2022-03-27 17:12:17 +00:00
Arik Sosman
6176e2f13f
Merge pull request #1388 from lightning-signer/2022-03-grind 2022-03-25 16:35:21 -07:00
valentinewallace
eb68b5fe9d
Merge pull request #1375 from jkczyz/2022-03-scorer-followup
ProbabilisticScorer optimizations
2022-03-25 17:01:46 -04:00
Matt Corallo
77cab14a7a
Merge pull request #1382 from TheBlueMatt/2022-03-gossip-queries-sucks
Fix gossip using `gossip_timestamp_filter` instead of queries
2022-03-25 19:49:37 +00:00
Devrandom
8d7b38fcf1 Add low_r signature grinding
default on, can be turned off via a feature gate
2022-03-25 20:34:02 +01:00
valentinewallace
eb50201ed5
Merge pull request #1381 from shamardy/2022-03-set-inbound-user-chan-id
Add `user_channel_id` to `accept_inbound_channel` method
2022-03-25 14:28:57 -04:00
Matt Corallo
1386a0c96b Fix gossip using gossip_timestamp_filter instead of queries
See large comment added for more details
2022-03-25 17:12:09 +00:00
Jeffrey Czyz
9596cc7110
Increase default liquidity_penalty_multiplier_msat
Using a larger multiplier gives more reasonable penalties for larger
success probabilities.
2022-03-25 11:31:04 -05:00
Jeffrey Czyz
c6348cb552
Move max penalty cap in ProbabilisticScorer
This reduce a branch in the 0 and u6::max_value cases.
2022-03-25 09:35:35 -05:00
Jeffrey Czyz
4ea18e3232
Fix overflow in ProbabilisticScorer
When a routing hint is given in an invoice, the effective capacity of
the channel is assumed to be infinite (i.e., u64::max_value) if the hop
is private. Adding 1 to this in the success probability calculation will
cause an overflow and ultimately an `index out of bounds panic` in
log10_times_1024. This was not an issue with using log10 because the use
of f64 would give infinite which casts to 0 for u64.
2022-03-25 09:16:22 -05:00
Jeffrey Czyz
5b36449c59
Add a base penalty to ProbabilisticScorer
ProbabilisticScorer tends to prefer longer routes to shorter ones. Make
the default scoring behavior include a customizable base penalty to
avoid longer routes.
2022-03-25 09:12:49 -05:00
Jeffrey Czyz
188f919a15
Don't serialize FixedPenaltyScorer parameters
Serializing scorer parameters makes it difficult to experiment with
different settings.
2022-03-25 08:53:19 -05:00
Omar Shamardy
edd4babb1c set user_channel_id in accept_inbound_channel fn
fix docs

edit user_channel_id docs for Event::ChannelClosed

review fixes
2022-03-25 05:39:58 +02:00
Matt Corallo
216225c00b
Merge pull request #1359 from tnull/2022-03-real-random-shuffle
Randomize candidate paths during route selection.
2022-03-24 23:13:12 +00:00
Matt Corallo
4e89e5741b
Merge pull request #1380 from TheBlueMatt/2022-03-skip-redundant-sig-checks
Skip `channel_update` signature checks if we have a newer state
2022-03-24 22:51:17 +00:00
Matt Corallo
63ca72e5b0 Skip channel_update signature checks if we have a newer state
`channel_update` messages already have their signatures checked
with the network graph write lock held, so there's no reason to
check the signatures before doing other quicker checks first,
including checking if we're already aware of a newer update for the
channel.

This reduces common-case CPU usage as `channel_update`s are sent
rather liberally over the p2p network to gossip them.
2022-03-24 17:21:30 +00:00
valentinewallace
4455143525
Merge pull request #1058 from TheBlueMatt/2021-08-fail-claimed-dust-htlc
Add a further test of HTLC failure after a claim occurrs.
2022-03-24 13:01:56 -04:00
Elias Rohrer
ff7ec0c645 Minor refactor for sort / add, and some nits.
- `sort_by_key` to `sort_unstable_by_key`
- `checked_add() .. max_value()` to `saturating_add()`
- Some typos and nits
2022-03-24 09:12:44 -06:00
Elias Rohrer
b11dcf9ba8 Randomize candidate paths during route selection. 2022-03-24 09:12:26 -06:00
Matt Corallo
305a0d9ac5 Add a further test of HTLC failure after a claim occurrs.
This adds a further test of 7e78fa660c
which I had lying around in my TODO list for a while.
2022-03-24 00:55:26 +00:00
Matt Corallo
f6fa8e9c5b
Merge pull request #1370 from TheBlueMatt/2022-03-pref-first-hop-chans
Avoid needless MPP on multiple channels to the same first-hop
2022-03-23 22:44:37 +00:00
Matt Corallo
fcfd683312
Merge pull request #1360 from tnull/2022-03-loopless-random-walks
Avoid looping CLTV shadow routes.
2022-03-23 21:40:25 +00:00
Matt Corallo
b010aeb5f1
Merge pull request #1326 from Psycho-Pirate/peers
Added option to send remote IP to peers
2022-03-23 21:02:17 +00:00