]> git.bitcoin.ninja Git - rust-lightning/log
rust-lightning
2 years agoMerge pull request #1463 from TheBlueMatt/2022-05-lol-more-underflow
valentinewallace [Thu, 5 May 2022 00:36:03 +0000 (20:36 -0400)]
Merge pull request #1463 from TheBlueMatt/2022-05-lol-more-underflow

Reject outbound channels if the total reserve is larger than funding

2 years agoMerge pull request #1449 from TheBlueMatt/2022-04-fix-remote_ip_race
Matt Corallo [Wed, 4 May 2022 20:29:38 +0000 (20:29 +0000)]
Merge pull request #1449 from TheBlueMatt/2022-04-fix-remote_ip_race

[lightning-net-tokio] Fix race-y unwrap fetching peer socket address

2 years agoMerge pull request #1430 from vincenzopalazzo/macros/channel_reestablish_v2
Matt Corallo [Wed, 4 May 2022 18:48:19 +0000 (18:48 +0000)]
Merge pull request #1430 from vincenzopalazzo/macros/channel_reestablish_v2

send warning when we receive a old commitment transaction

2 years agoMerge pull request #1416 from jurvis/jurvis/persist-scorer
Jeffrey Czyz [Wed, 4 May 2022 13:28:06 +0000 (08:28 -0500)]
Merge pull request #1416 from jurvis/jurvis/persist-scorer

Add utils to persist scorer in BackgroundProcessor

2 years agosend warning when we receive a old commitment transaction
Vincenzo Palazzo [Wed, 4 May 2022 07:23:05 +0000 (09:23 +0200)]
send warning when we receive a old commitment transaction

During a `channel_reestablish` now we send a warning message when we receive a old commitment transaction from the peer.

In addition, this commit include the update of functional test to make sure that the receiver will generate warn messages.

Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
2 years agoMerge pull request #1461 from TheBlueMatt/2022-05-unconf-0-not-half
valentinewallace [Wed, 4 May 2022 00:44:42 +0000 (20:44 -0400)]
Merge pull request #1461 from TheBlueMatt/2022-05-unconf-0-not-half

Force-close channels on reorg only if the funding is unconfirmed

2 years agoMerge pull request #1444 from ViktorTigerstrom/2022-04-use-counterparty-htlc-max...
Matt Corallo [Tue, 3 May 2022 22:44:26 +0000 (22:44 +0000)]
Merge pull request #1444 from ViktorTigerstrom/2022-04-use-counterparty-htlc-max-for-chan-updates

Set `ChannelUpdate` `htlc_maximum_msat` using the peer's value

2 years agoSet last_prune_call outside of persistence block
Jurvis Tan [Tue, 3 May 2022 22:29:11 +0000 (15:29 -0700)]
Set last_prune_call outside of persistence block

2 years agoAdd utils to persist scorer in BackgroundProcessor
Jurvis Tan [Thu, 28 Apr 2022 05:16:38 +0000 (22:16 -0700)]
Add utils to persist scorer in BackgroundProcessor

move last_prune_call back

2 years agoAdd correct `ChannelUpdate` `htlc_maximum_msat` test
Viktor Tigerström [Tue, 26 Apr 2022 22:43:06 +0000 (00:43 +0200)]
Add correct `ChannelUpdate` `htlc_maximum_msat` test

2 years agoSet `ChannelUpdate` `htlc_maximum_msat` using the peer's value
Viktor Tigerström [Thu, 21 Apr 2022 22:02:27 +0000 (00:02 +0200)]
Set `ChannelUpdate` `htlc_maximum_msat` using the peer's value

Use the `counterparty_max_htlc_value_in_flight_msat` value, and not the
`holder_max_htlc_value_in_flight_msat` value when creating the
`htlc_maximum_msat` value for `ChannelUpdate` messages.

BOLT 7 specifies that the field MUST be less than or equal to
`max_htlc_value_in_flight_msat` received from the peer, which we
currently are not guaranteed to adhere to by using the holder value.

2 years agoAdd test for configurable in-flight limit
Viktor Tigerström [Tue, 26 Apr 2022 22:39:52 +0000 (00:39 +0200)]
Add test for configurable in-flight limit

2 years agoMake our in-flight limit percentage configurable
Viktor Tigerström [Tue, 26 Apr 2022 22:37:45 +0000 (00:37 +0200)]
Make our in-flight limit percentage configurable

Add a config field
`ChannelHandshakeConfig::max_inbound_htlc_value_in_flight_percent_of_channel`
which sets the percentage of the channel value we cap the total value of
outstanding inbound HTLCs to.

This field can be set to a value between 1-100, where the value
corresponds to the percent of the channel value in whole percentages.

Note that:
* If configured to another value than the default value 10, any new
channels created with the non default value will cause versions of LDK
prior to 0.0.104 to refuse to read the `ChannelManager`.

* This caps the total value for inbound HTLCs in-flight only, and
there's currently no way to configure the cap for the total value of
outbound HTLCs in-flight.

* The requirements for your node being online to ensure the safety of
HTLC-encumbered funds are different from the non-HTLC-encumbered funds.
This makes this an important knob to restrict exposure to loss due to
being offline for too long. See
`ChannelHandshakeConfig::our_to_self_delay` and
`ChannelConfig::cltv_expiry_delta` for more information.

Default value: 10.
Minimum value: 1, any values less than 1 will be treated as 1 instead.
Maximum value: 100, any values larger than 100 will be treated as 100
instead.

2 years agoMerge pull request #1452 from tnull/2022-04-honor-gossip-timestamp-filters
Matt Corallo [Tue, 3 May 2022 19:16:29 +0000 (19:16 +0000)]
Merge pull request #1452 from tnull/2022-04-honor-gossip-timestamp-filters

Initiate gossip sync only after receiving GossipTimestampFilter.

2 years agoTweak `test_unconf_chan` to test that we don't prematurely close 2022-05-unconf-0-not-half
Matt Corallo [Mon, 2 May 2022 15:07:20 +0000 (15:07 +0000)]
Tweak `test_unconf_chan` to test that we don't prematurely close

2 years agoMerge pull request #1460 from TheBlueMatt/2022-04-liquidity-log
Matt Corallo [Tue, 3 May 2022 16:53:10 +0000 (16:53 +0000)]
Merge pull request #1460 from TheBlueMatt/2022-04-liquidity-log

Provide a utility to log the ProbabilisticScorer's contents

2 years agoInitiate sync only after receiving `GossipTimestampFilter`.
Elias Rohrer [Tue, 3 May 2022 07:13:09 +0000 (09:13 +0200)]
Initiate sync only after receiving `GossipTimestampFilter`.

2 years agoReject outbound channels if the total reserve is larger than funding 2022-05-lol-more-underflow
Matt Corallo [Mon, 2 May 2022 20:45:17 +0000 (20:45 +0000)]
Reject outbound channels if the total reserve is larger than funding

In 2826af75a5761859dedcddc870de0753ae4ecde4 we fixed a fuzz crash
in which the total reserve values in a channel were greater than
the funding amount, checked when an incoming channel is accepted.

This, however, did not fix the same issue for outbound channels,
where a peer can accept a channel with a nonsense reserve value in
the `accept_channel` message. The `full_stack_target` fuzzer
eventually found its way into the same issue, which this resolves.

Thanks (again) to Chaincode Labs for providing the fuzzing
resources which found this bug!

2 years agoMerge pull request #1447 from andozw/seana.20220422.avoid-storing-FinalOnionHopData
Matt Corallo [Mon, 2 May 2022 20:21:44 +0000 (20:21 +0000)]
Merge pull request #1447 from andozw/seana.20220422.avoid-storing-FinalOnionHopData

Avoid storing a full FinalOnionHopData in OnionPayload::Invoice

2 years agoProvide a utility to log the ProbabilisticScorer's contents 2022-04-liquidity-log
Matt Corallo [Thu, 28 Apr 2022 22:32:52 +0000 (22:32 +0000)]
Provide a utility to log the ProbabilisticScorer's contents

I wrote this when debugging a user's scorer and figured it may be
useful upstream.

2 years agoAvoid storing a full FinalOnionHopData in OnionPayload::Invoice
Matt Corallo [Thu, 28 Apr 2022 17:10:04 +0000 (10:10 -0700)]
Avoid storing a full FinalOnionHopData in OnionPayload::Invoice

We only use it to check the amount when processing MPP parts, but
store the full object (including new payment metadata) in it.
Because we now store the amount in the parent structure, there is
no need for it at all in the `OnionPayload`. Sadly, for
serialization compatibility, we need it to continue to exist, at
least temporarily, but we can avoid populating the new fields in
that case.

2 years agoStore total payment amount in ClaimableHTLC explicitly
Matt Corallo [Tue, 21 Dec 2021 22:10:43 +0000 (22:10 +0000)]
Store total payment amount in ClaimableHTLC explicitly

...instead of accessing it via the `OnionPayload::Invoice` form.
This may be useful if we add MPP keysend support, but is directly
useful to allow us to drop `FinalOnionHopData` from `OnionPayload`.

2 years agoPass FinalOnionHopData to payment verify by reference, not clone
Matt Corallo [Tue, 21 Dec 2021 20:21:34 +0000 (20:21 +0000)]
Pass FinalOnionHopData to payment verify by reference, not clone

2 years agoAdd a test for socket connection races 2022-04-fix-remote_ip_race
Matt Corallo [Mon, 25 Apr 2022 18:39:28 +0000 (18:39 +0000)]
Add a test for socket connection races

Sadly this does not reproduce the issue fixed in the previous
commit.

2 years agoForce-close channels on reorg only if the funding is unconfirmed
Matt Corallo [Mon, 2 May 2022 02:51:50 +0000 (02:51 +0000)]
Force-close channels on reorg only if the funding is unconfirmed

Currently, if a channel's funding is locked in and then later
reorg'd back to half of the channel's minimum-depth we will
immediately force-close the channel. However, this can happen at
the fork-point while processing a reorg, and generally reorgs do
not reduce the block height at all, making this a rather useless
endeavor.

Ideally we'd never auto-force-close channels at all due to a reorg,
instead simply marking it as inactive until the funding
transaction is re-confirmed (or allowing the user to attempt to
force-close or force-closing once we're confident we have
completed reorg processing if we're at risk of losing funds
already received in the channel).

Sadly, we currently do not support changing a channel's SCID and
updating our SCID maps, so we cannot yet remove the automated
force-close logic. Still, there is no reason to do it until a
funding transaction has been removed from the chain.

This implements that change - only force-closeing once a channel's
funding transaction has been reorg'd out (still potentially at a
reorg's fork point). This continues to imply a 1-confirmation
channel will always be force-closed after a reorg of the funding
transaction, and will imply a similar behavior with 0-conf
channels.

2 years agoMerge pull request #1451 from TheBlueMatt/2022-04-moar-mpp-fail-test
Matt Corallo [Fri, 29 Apr 2022 19:50:37 +0000 (19:50 +0000)]
Merge pull request #1451 from TheBlueMatt/2022-04-moar-mpp-fail-test

Add test coverage for failure of inconsistent MPP parts

2 years agoMerge pull request #1454 from TheBlueMatt/2022-04-fuzz-underflow
Matt Corallo [Thu, 28 Apr 2022 21:56:49 +0000 (21:56 +0000)]
Merge pull request #1454 from TheBlueMatt/2022-04-fuzz-underflow

Reject channels if the total reserves are larger than the funding

2 years agoMerge pull request #1425 from valentinewallace/2021-04-wumbo
Matt Corallo [Thu, 28 Apr 2022 21:14:19 +0000 (21:14 +0000)]
Merge pull request #1425 from valentinewallace/2021-04-wumbo

Wumbo!

2 years agoCorrect error when a peer opens a channel with a huge push_msat 2022-04-fuzz-underflow
Matt Corallo [Thu, 28 Apr 2022 19:46:22 +0000 (19:46 +0000)]
Correct error when a peer opens a channel with a huge push_msat

The calculation uses the reserve, so we should mention it in the
error we send to our peers.

2 years agoReject channels if the total reserves are larger than the funding
Matt Corallo [Thu, 28 Apr 2022 19:46:13 +0000 (19:46 +0000)]
Reject channels if the total reserves are larger than the funding

The `full_stack_target` fuzzer managed to find a subtraction
underflow in the new `Channel::get_htlc_maximum` function where we
subtract both sides' reserve values from the channel funding. Such
a channel is obviously completely useless, so we should reject it
during opening instead of integer-underflowing later.

Thanks to Chaincode Labs for providing the fuzzing resources which
found this bug!

2 years agoEnable wumbo channels to be created
Valentine Wallace [Fri, 15 Apr 2022 22:10:39 +0000 (18:10 -0400)]
Enable wumbo channels to be created

Also redefine MAX_FUNDING_SATOSHIS_NO_WUMBO to no longer be off-by-one.

2 years agoconfig: add max_funding_satoshis to enforce for inbound channels
Valentine Wallace [Fri, 15 Apr 2022 21:34:59 +0000 (17:34 -0400)]
config: add max_funding_satoshis to enforce for inbound channels

and a bonus grammar fix

2 years agoAdd test coverage for failure of inconsistent MPP parts 2022-04-moar-mpp-fail-test
Matt Corallo [Mon, 25 Apr 2022 22:51:02 +0000 (22:51 +0000)]
Add test coverage for failure of inconsistent MPP parts

When we receive multiple HTLCs which claim to be a part of the same
MPP but which are inconsistent for some reason, we should fail the
inconsistent HTLCs but keep the first HTLCs up until the first
inconsistency.

This works, but it turns out there was no test coverage, so we add
some here.

2 years agoAdd a `get_route!()` macro for tests which only need a route
Matt Corallo [Mon, 25 Apr 2022 23:00:39 +0000 (23:00 +0000)]
Add a `get_route!()` macro for tests which only need a route

2 years agoMerge pull request #1435 from TheBlueMatt/2022-04-1126-first-step
Matt Corallo [Thu, 28 Apr 2022 02:43:04 +0000 (02:43 +0000)]
Merge pull request #1435 from TheBlueMatt/2022-04-1126-first-step

2 years agoConsolidate Channel balance fetching into one fn returning struct 2022-04-1126-first-step
Matt Corallo [Wed, 27 Apr 2022 16:11:47 +0000 (16:11 +0000)]
Consolidate Channel balance fetching into one fn returning struct

Some simple code motion to clean up how channel balances get
fetched.

2 years agoMerge pull request #1405 from TheBlueMatt/2022-04-log-scoring
valentinewallace [Wed, 27 Apr 2022 16:34:08 +0000 (12:34 -0400)]
Merge pull request #1405 from TheBlueMatt/2022-04-log-scoring

Log as channel liquidities are/not updated in ProbabilisticScorer

2 years agoMerge pull request #1453 from TheBlueMatt/2022-04-listen-filtered-blocks
valentinewallace [Wed, 27 Apr 2022 16:25:30 +0000 (12:25 -0400)]
Merge pull request #1453 from TheBlueMatt/2022-04-listen-filtered-blocks

Expand `chain::Listen` trivially to accept filtered block data

2 years agoMerge pull request #1421 from TheBlueMatt/2022-04-less-gossip-trace-spam
Matt Corallo [Wed, 27 Apr 2022 15:59:48 +0000 (15:59 +0000)]
Merge pull request #1421 from TheBlueMatt/2022-04-less-gossip-trace-spam

Log gossip query msgs at GOSSIP instead of TRACE as they're huge

2 years agoExplicitly log a warning when a payment failed on the first hop 2022-04-log-scoring
Matt Corallo [Sun, 3 Apr 2022 17:11:37 +0000 (17:11 +0000)]
Explicitly log a warning when a payment failed on the first hop

2 years agoExpand `chain::Listen` trivially to accept filtered block data 2022-04-listen-filtered-blocks
Matt Corallo [Tue, 26 Apr 2022 15:03:39 +0000 (15:03 +0000)]
Expand `chain::Listen` trivially to accept filtered block data

The `chain::Listen` interface provides a block-connection-based
alternative to the `chain::Confirm` interface, which supports
providing transaction data at a time separate from the block
connection time.

For users who are downloading the full headers tree (e.g. from a
node over the Bitcoin P2P protocol) but who are not downloading
full blocks (e.g. because they're using BIP 157/158 filtering)
there is no API that matches exactly their event stream -
`chain::Listen` requries full blocks for each block,
`chain::Confirm` requires breaking each connection event into two
calls.

Given its incredibly trivial to take a `TransactionData` in
addition to a `Block` in `chain::Listen` we do so here, adding a
default-implementation `block_connected` which simply creates the
`TransactionData`, which ultimately all of the `chain::Listen`
implementations currently do anyway.

Closes #1128.

2 years agoMerge pull request #1436 from TheBlueMatt/2022-04-event-process-try-lock
valentinewallace [Tue, 26 Apr 2022 17:02:29 +0000 (13:02 -0400)]
Merge pull request #1436 from TheBlueMatt/2022-04-event-process-try-lock

Reorder the BP loop to make manager persistence more reliable

2 years agoReorder the BP loop to make manager persistence more reliable 2022-04-event-process-try-lock
Matt Corallo [Thu, 21 Apr 2022 02:30:16 +0000 (02:30 +0000)]
Reorder the BP loop to make manager persistence more reliable

The main loop of the background processor has this line:
`peer_manager.process_events(); // Note that this may block on ChannelManager's locking`
which does, indeed, sometimes block waiting on the `ChannelManager`
to finish whatever its doing. Specifically, its the only place in
the background processor loop that we block waiting on the
`ChannelManager`, so if the `ChannelManager` is relatively busy, we
may end up being blocked there most of the time.

This should be fine, except today we had a user who's node was
particularly slow in processing some channel updates, resulting in
the background processor being blocked there (as expected). Then,
when the channel updates were completed (and persisted) the next
thing the background processor did was hand the user events to
process, creating yet more channel updates. Ultimately, the users'
node crashed before finishing the event processing. This left us
with an updated monitor on disk and an outdated manager, and they
lost the channel on startup.

Here we simply move the above quoted line to after the normal event
processing, ensuring the next thing we do after blocking on
`ChannelManager` locks is persist the manager, prior to event
handling.

2 years agoMerge pull request #1448 from TheBlueMatt/2022-04-fix-warnings
valentinewallace [Mon, 25 Apr 2022 18:48:07 +0000 (14:48 -0400)]
Merge pull request #1448 from TheBlueMatt/2022-04-fix-warnings

Fix several "unused" warnings introduced in #1417

2 years agochannel: refactor max funding consts
Valentine Wallace [Fri, 15 Apr 2022 21:31:20 +0000 (17:31 -0400)]
channel: refactor max funding consts

MAX_FUNDING_SATOSHIS will no longer be accurately named once wumbo is merged.
Also, we'll want to check that wumbo channels don't exceed the total bitcoin supply

2 years agochannelmanager: remove bogus panic warning from docs
Valentine Wallace [Fri, 15 Apr 2022 21:24:23 +0000 (17:24 -0400)]
channelmanager: remove bogus panic warning from docs

2 years agoSort `Event` variants somewhat more sensibly
Matt Corallo [Mon, 18 Apr 2022 15:39:47 +0000 (15:39 +0000)]
Sort `Event` variants somewhat more sensibly

2 years agoSeparate `ChannelDetails`' outbound capacity from the next HTLC max
Matt Corallo [Sat, 16 Apr 2022 20:07:34 +0000 (20:07 +0000)]
Separate `ChannelDetails`' outbound capacity from the next HTLC max

`ChannelDetails::outbound_capacity_msat` describes the total amount
available for sending across several HTLCs, basically just our
balance minus the reserve value maintained by our counterparty.
However, when routing we use it to guess the maximum amount we can
send in a single additional HTLC, which it is not.

There are numerous reasons why our balance may not match the amount
we can send in a single HTLC, whether the HTLC in-flight limit, the
channe's HTLC maximum, or our feerate buffer.

This commit splits the `outbound_capacity_msat` field into two -
`outbound_capacity_msat` and `outbound_htlc_limit_msat`, setting us
up for correctly handling our next-HTLC-limit in the future.

This also addresses the first of the reasons why the values may
not match - the max-in-flight limit. The inaccuracy is ultimately
tracked as #1126.

2 years ago[lightning-net-tokio] Fix race-y unwrap fetching peer socket address
Matt Corallo [Sun, 24 Apr 2022 20:57:53 +0000 (20:57 +0000)]
[lightning-net-tokio] Fix race-y unwrap fetching peer socket address

I recently saw the following panic on one of my test nodes:

```
thread 'tokio-runtime-worker' panicked at 'called `Result::unwrap()`
    on an `Err` value: Os { code: 107, kind: NotConnected, message:
    "Transport endpoint is not connected" }',
    rust-lightning/lightning-net-tokio/src/lib.rs:250:38
```

Presumably what happened is somehow the connection was closed in
between us accepting it and us going to start processing it. While
this is a somewhat surprising race, its clearly reachable. The fix
proposed here is quite trivial - simply don't `unwrap` trying to
fetch our peer's socket address, instead treat the peer address as
`None` and discover the disconnection later when we go to read.

2 years agoFix several "unused" warnings introduced in #1417 2022-04-fix-warnings
Matt Corallo [Sun, 24 Apr 2022 16:03:26 +0000 (16:03 +0000)]
Fix several "unused" warnings introduced in #1417

2 years agoMerge pull request #1378 from ViktorTigerstrom/2022-03-include-htlc-min-max
Matt Corallo [Thu, 21 Apr 2022 18:09:20 +0000 (18:09 +0000)]
Merge pull request #1378 from ViktorTigerstrom/2022-03-include-htlc-min-max

Include htlc min/max for ChannelDetails and ChannelCounterparty

2 years agoAdd htlc min/max to create invoice functions
Viktor Tigerström [Tue, 29 Mar 2022 23:42:50 +0000 (01:42 +0200)]
Add htlc min/max to create invoice functions

2 years agoAdd outbound min/max to `ChannelCounterparty`
Viktor Tigerström [Tue, 19 Apr 2022 21:34:53 +0000 (23:34 +0200)]
Add outbound min/max to `ChannelCounterparty`

2 years agoMerge pull request #1417 from johncantrell97/generic-persist
Matt Corallo [Thu, 21 Apr 2022 01:28:23 +0000 (01:28 +0000)]
Merge pull request #1417 from johncantrell97/generic-persist

add `KVStorePersister` trait and blanket implementations of `Persist` and `Persister` for any type that implements `KVStorePersister`

2 years agoimplement Persist and Persister with generic KVStorePersister trait
John Cantrell [Mon, 11 Apr 2022 17:50:31 +0000 (13:50 -0400)]
implement Persist and Persister with generic KVStorePersister trait

2 years agoMerge pull request #1419 from atalw/2022-03-paymentforwarded-event
valentinewallace [Wed, 20 Apr 2022 15:37:48 +0000 (11:37 -0400)]
Merge pull request #1419 from atalw/2022-03-paymentforwarded-event

Expose more info in `PaymentForwarded` event

2 years agoAdd `source_channel_id` in `PaymentForwarded` event
atalw [Wed, 30 Mar 2022 08:51:45 +0000 (14:21 +0530)]
Add `source_channel_id` in `PaymentForwarded` event

2 years agoAdd inbound htlc min/max to `ChannelDetails`
Viktor Tigerström [Tue, 22 Mar 2022 20:36:18 +0000 (21:36 +0100)]
Add inbound htlc min/max to `ChannelDetails`

2 years agoMerge pull request #1414 from ViktorTigerstrom/2022-04-default-to-tlv-onions
Jeffrey Czyz [Mon, 18 Apr 2022 20:09:55 +0000 (13:09 -0700)]
Merge pull request #1414 from ViktorTigerstrom/2022-04-default-to-tlv-onions

Default to BOLT 4 tlv payload format onions

2 years agoMerge pull request #1422 from dunxen/2022-04-invoice-expiry
valentinewallace [Sun, 17 Apr 2022 19:01:53 +0000 (15:01 -0400)]
Merge pull request #1422 from dunxen/2022-04-invoice-expiry

Add expiry to phantom invoice utility functions

2 years agoAdd expiry to inbound payment util functions
Duncan Dean [Fri, 15 Apr 2022 12:57:34 +0000 (14:57 +0200)]
Add expiry to inbound payment util functions

2 years agoAdd tests for defaulting to creating tlv onions
Viktor Tigerström [Sat, 9 Apr 2022 16:56:59 +0000 (18:56 +0200)]
Add tests for defaulting to creating tlv onions

2 years agofeatures: advertise wumbo channels as supported
Valentine Wallace [Fri, 15 Apr 2022 20:26:55 +0000 (16:26 -0400)]
features: advertise wumbo channels as supported

2 years agoMerge pull request #1404 from TheBlueMatt/2022-04-buf-writes
Jeffrey Czyz [Fri, 15 Apr 2022 19:35:01 +0000 (14:35 -0500)]
Merge pull request #1404 from TheBlueMatt/2022-04-buf-writes

Pipe filesystem writes in `lightning-persister` through `BufWriter`

2 years agoMerge pull request #1423 from jkczyz/2022-04-dyn-block-source
valentinewallace [Fri, 15 Apr 2022 18:33:36 +0000 (14:33 -0400)]
Merge pull request #1423 from jkczyz/2022-04-dyn-block-source

Allow `&dyn BlockSource` in `lightning-block-sync`

2 years agoLog as channel liquidities are/not updated in `ProbabilisticScorer`
Matt Corallo [Sat, 2 Apr 2022 23:54:01 +0000 (23:54 +0000)]
Log as channel liquidities are/not updated in `ProbabilisticScorer`

2 years agoAdd an (unused) `Logger` reference in `ProbabilisticScorer`
Matt Corallo [Sat, 2 Apr 2022 23:33:42 +0000 (23:33 +0000)]
Add an (unused) `Logger` reference in `ProbabilisticScorer`

2 years agoRemove unnecessary lifetime bound
Jeffrey Czyz [Fri, 15 Apr 2022 16:34:51 +0000 (11:34 -0500)]
Remove unnecessary lifetime bound

2 years agoRemove mut in lightning-block-sync tests
Jeffrey Czyz [Fri, 15 Apr 2022 15:32:51 +0000 (10:32 -0500)]
Remove mut in lightning-block-sync tests

2 years agoAllow &dyn BlockSource in lightning-block-sync
Jeffrey Czyz [Fri, 15 Apr 2022 14:03:00 +0000 (09:03 -0500)]
Allow &dyn BlockSource in lightning-block-sync

Update lightning-block-sync's init and poll modules to support &dyn
BlockSource such that the BlockSource can be determined at runtime.

2 years agoPass `PaymentParameters` in `get_route_and_payment_hash`
Viktor Tigerström [Thu, 14 Apr 2022 20:52:26 +0000 (22:52 +0200)]
Pass `PaymentParameters` in `get_route_and_payment_hash`

2 years agoDefault to creating BOLT4 tlv payload format onions
Viktor Tigerström [Sat, 9 Apr 2022 16:49:17 +0000 (18:49 +0200)]
Default to creating BOLT4 tlv payload format onions

Default to creating tlv onions for nodes for which we haven't received
any features through node announcements or which aren't in the
`network_graph`, and where no other features are known such as invoice
features nor features in the init msg for nodes we have channels to.

2 years agoLog gossip query msgs at GOSSIP instead of TRACE as they're huge 2022-04-less-gossip-trace-spam
Matt Corallo [Thu, 14 Apr 2022 02:12:12 +0000 (02:12 +0000)]
Log gossip query msgs at GOSSIP instead of TRACE as they're huge

2 years agoMerge pull request #1384 from valentinewallace/2022-03-chanmanless-phantom-invoices
Matt Corallo [Wed, 13 Apr 2022 14:51:35 +0000 (14:51 +0000)]
Merge pull request #1384 from valentinewallace/2022-03-chanmanless-phantom-invoices

2 years agoMerge pull request #1406 from TheBlueMatt/2022-04-scorer-precision
Matt Corallo [Wed, 13 Apr 2022 14:00:00 +0000 (14:00 +0000)]
Merge pull request #1406 from TheBlueMatt/2022-04-scorer-precision

[RFC] Expand the precision of our log10 lookup tables + add precision

2 years agoExpose methods for ChannelManager-less phantom invoice generation
Valentine Wallace [Thu, 24 Mar 2022 19:43:40 +0000 (15:43 -0400)]
Expose methods for ChannelManager-less phantom invoice generation

2 years agoMerge pull request #1412 from lightningdevkit/dependabot/github_actions/codecov/codec...
Jeffrey Czyz [Mon, 11 Apr 2022 22:16:06 +0000 (18:16 -0400)]
Merge pull request #1412 from lightningdevkit/dependabot/github_actions/codecov/codecov-action-3

Bump codecov/codecov-action from 2 to 3

2 years agoLower-bound the log approximation and stop using it > ~98.5% 2022-04-scorer-precision
Matt Corallo [Sun, 3 Apr 2022 21:21:54 +0000 (21:21 +0000)]
Lower-bound the log approximation and stop using it > ~98.5%

When we start getting a numerator and divisor particularly close to
each other, the log approximation starts to get very noisy. In
order to avoid applying scores that are basically noise (and can
range upwards of 2x the default per-hop penalty), simply consider
such cases as having a success probability of 100%.

2 years agoExpand the precision of our log10 lookup tables + add precision
Matt Corallo [Sun, 3 Apr 2022 20:16:03 +0000 (20:16 +0000)]
Expand the precision of our log10 lookup tables + add precision

When we send values over channels of rather substantial size, the
imprecision of our log lookup tables creates a rather substantial
non-linearity between values that round up or down one bit.

For example, with the default scoring values, sending 100k sats
over channels with 1m, 2m, 3m, and 4m sats of capacity score
rather drastically differently: 3645, 2512, 500, and 1442 msat.

Here we expand the precision of our log lookup tables rather
substantially by: (a) making the multiplier 2048 instead of 1024,
which still fits inside a u16, and (b) quadrupling the size of the
lookup table to look at the top 6 bits after the most-significant
bit of an input instead of the top 4.

This makes the scores of the same channels substantially more
linear, with values of 3613, 1977, 1474, and 1223 msat.

The same channels would be scored at 3611, 1972, 1464, and 1216
msat with a non-approximating scorer.

2 years agoMerge pull request #1307 from jkczyz/2022-02-block-source-self-ref
Matt Corallo [Sat, 9 Apr 2022 15:25:42 +0000 (15:25 +0000)]
Merge pull request #1307 from jkczyz/2022-02-block-source-self-ref

Immutable BlockSource interface

2 years agoBump codecov/codecov-action from 2 to 3
dependabot[bot] [Tue, 5 Apr 2022 17:32:54 +0000 (17:32 +0000)]
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>
2 years agoMerge pull request #1409 from TheBlueMatt/2022-04-bindings-invoice-ders
Matt Corallo [Mon, 4 Apr 2022 15:39:29 +0000 (15:39 +0000)]
Merge pull request #1409 from TheBlueMatt/2022-04-bindings-invoice-ders

Move lightning-invoice deser errors to lib.rs instead of `pub use`

2 years agoMove lightning-invoice deser errors to lib.rs instead of `pub use` 2022-04-bindings-invoice-ders
Matt Corallo [Mon, 4 Apr 2022 02:51:22 +0000 (02:51 +0000)]
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.

2 years agoImmutable BlockSource interface
Jeffrey Czyz [Mon, 14 Feb 2022 21:31:59 +0000 (15:31 -0600)]
Immutable BlockSource interface

Querying a BlockSource is a logically immutable operation. Use non-mut
references in its interface to reflect this, which allows for users to
hold multiple references if desired.

2 years agoPipe filesystem writes in `lightning-persister` through `BufWriter` 2022-04-buf-writes
Matt Corallo [Sun, 3 Apr 2022 01:04:26 +0000 (01:04 +0000)]
Pipe filesystem writes in `lightning-persister` through `BufWriter`

We generally make no effort to ensure all writes are buffered in
lower-level objects, so wrapping write calls in `BufWriter` may
substantially improve performance in some cases. This is especially
important now that we block the sample node exit until the
`NetworkGraph` has been written out, which includes many small-ish
writes.

With this change, shutdown of the sample node on a relatively
underpowered device went from 15-30 seconds of CPU time to a second
or two, plus IO sync time.

2 years agoAdd a test which demonstrates scores for some realistic payments
Matt Corallo [Sun, 3 Apr 2022 20:36:09 +0000 (20:36 +0000)]
Add a test which demonstrates scores for some realistic payments

2 years agoMerge pull request #1397 from jkczyz/2022-03-release-0.0.106 v0.0.106
Matt Corallo [Sun, 3 Apr 2022 16:31:54 +0000 (16:31 +0000)]
Merge pull request #1397 from jkczyz/2022-03-release-0.0.106

Cut 0.0.106

2 years agoBump crate versions to 0.0.106/invoice 0.14
Jeffrey Czyz [Wed, 30 Mar 2022 17:08:26 +0000 (12:08 -0500)]
Bump crate versions to 0.0.106/invoice 0.14

2 years agoUpdate CHANGELOG for 0.0.106
Jeffrey Czyz [Wed, 30 Mar 2022 04:58:50 +0000 (23:58 -0500)]
Update CHANGELOG for 0.0.106

2 years agoMerge pull request #1399 from jkczyz/2022-03-scoring-tweaks
Matt Corallo [Sat, 2 Apr 2022 01:50:55 +0000 (01:50 +0000)]
Merge pull request #1399 from jkczyz/2022-03-scoring-tweaks

ProbabilisticScorer improvements

2 years agoAdd an amount penalty to ProbabilisticScorer
Jeffrey Czyz [Thu, 31 Mar 2022 13:13:10 +0000 (08:13 -0500)]
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.

2 years agoAvoid retrying over recently failed channels
Jeffrey Czyz [Thu, 31 Mar 2022 02:20:58 +0000 (21:20 -0500)]
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.

2 years agoMerge pull request #1398 from jkczyz/2022-03-middle-hop-fix
Matt Corallo [Fri, 1 Apr 2022 19:32:08 +0000 (19:32 +0000)]
Merge pull request #1398 from jkczyz/2022-03-middle-hop-fix

Router fixes

2 years agoDon't consider a path as having hit HTLC-min if it isn't sufficient
Matt Corallo [Thu, 24 Mar 2022 18:38:43 +0000 (18:38 +0000)]
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.

2 years agoSelect best route by lowest total cost
Jeffrey Czyz [Wed, 30 Mar 2022 22:24:57 +0000 (17:24 -0500)]
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.

2 years agoCorrectly pick middle hop to victimize
Jeffrey Czyz [Wed, 30 Mar 2022 18:43:45 +0000 (13:43 -0500)]
Correctly pick middle hop to victimize

For even-length paths, preferring a later hop avoids overly limiting the
possible paths on the next iteration.

2 years agoFix build warnings without grind_signatures
Jeffrey Czyz [Wed, 30 Mar 2022 19:43:39 +0000 (14:43 -0500)]
Fix build warnings without grind_signatures

2 years agoMerge pull request #1376 from jurvis/jurvis/persist-networkgraph
Jeffrey Czyz [Wed, 30 Mar 2022 20:38:39 +0000 (13:38 -0700)]
Merge pull request #1376 from jurvis/jurvis/persist-networkgraph

Persist NetworkGraph on removal of stale channels

2 years agoUse common Persister for persistence tests
Jurvis Tan [Tue, 29 Mar 2022 02:36:43 +0000 (19:36 -0700)]
Use common Persister for persistence tests

2 years agoMove expected_bytes to check_persisted_data! macro
Jurvis Tan [Tue, 29 Mar 2022 01:39:39 +0000 (18:39 -0700)]
Move expected_bytes to check_persisted_data! macro