Commit graph

3553 commits

Author SHA1 Message Date
Matt Corallo
62edee5689
Merge pull request #1435 from TheBlueMatt/2022-04-1126-first-step 2022-04-28 02:43:04 +00:00
Matt Corallo
61629bc00e Consolidate Channel balance fetching into one fn returning struct
Some simple code motion to clean up how channel balances get
fetched.
2022-04-27 20:21:20 +00:00
valentinewallace
df1c4ee150
Merge pull request #1405 from TheBlueMatt/2022-04-log-scoring
Log as channel liquidities are/not updated in ProbabilisticScorer
2022-04-27 12:34:08 -04:00
valentinewallace
54e9c07ad9
Merge pull request #1453 from TheBlueMatt/2022-04-listen-filtered-blocks
Expand `chain::Listen` trivially to accept filtered block data
2022-04-27 12:25:30 -04:00
Matt Corallo
7181b53aa4
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
2022-04-27 15:59:48 +00:00
Matt Corallo
6e298ff30d Explicitly log a warning when a payment failed on the first hop 2022-04-27 00:42:08 +00:00
Matt Corallo
d629a7edb7 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.
2022-04-26 19:14:19 +00:00
valentinewallace
72069bfc9d
Merge pull request #1436 from TheBlueMatt/2022-04-event-process-try-lock
Reorder the BP loop to make manager persistence more reliable
2022-04-26 13:02:29 -04:00
Matt Corallo
050b19cd9b 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.
2022-04-26 15:29:16 +00:00
valentinewallace
d1b984d864
Merge pull request #1448 from TheBlueMatt/2022-04-fix-warnings
Fix several "unused" warnings introduced in #1417
2022-04-25 14:48:07 -04:00
Valentine Wallace
fa59544972
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
2022-04-25 14:07:46 -04:00
Valentine Wallace
7bf7b3a446
channelmanager: remove bogus panic warning from docs 2022-04-25 14:04:07 -04:00
Matt Corallo
68ee7ef5c7 Sort Event variants somewhat more sensibly 2022-04-25 15:04:21 +00:00
Matt Corallo
1af705579b 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.
2022-04-25 15:04:21 +00:00
Matt Corallo
fca67bcaa4 [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.
2022-04-24 21:04:54 +00:00
Matt Corallo
fa9fc0d094 Fix several "unused" warnings introduced in #1417 2022-04-24 16:03:26 +00:00
Matt Corallo
637fb88037
Merge pull request #1378 from ViktorTigerstrom/2022-03-include-htlc-min-max
Include htlc min/max for ChannelDetails and ChannelCounterparty
2022-04-21 18:09:20 +00:00
Viktor Tigerström
3c67687066 Add htlc min/max to create invoice functions 2022-04-21 12:27:51 +02:00
Viktor Tigerström
63f0a31b59 Add outbound min/max to ChannelCounterparty 2022-04-21 12:27:51 +02:00
Matt Corallo
d0f69f77bd
Merge pull request #1417 from johncantrell97/generic-persist
add `KVStorePersister` trait and blanket implementations of `Persist` and `Persister` for any type that implements `KVStorePersister`
2022-04-21 01:28:23 +00:00
John Cantrell
4964944279
implement Persist and Persister with generic KVStorePersister trait 2022-04-20 16:46:58 -04:00
valentinewallace
742f5e59b9
Merge pull request #1419 from atalw/2022-03-paymentforwarded-event
Expose more info in `PaymentForwarded` event
2022-04-20 11:37:48 -04:00
atalw
e53c5bdb44 Add source_channel_id in PaymentForwarded event 2022-04-20 10:58:21 +05:30
Viktor Tigerström
6644ef138d Add inbound htlc min/max to ChannelDetails 2022-04-19 23:54:55 +02:00
Jeffrey Czyz
e0b9b748d6
Merge pull request #1414 from ViktorTigerstrom/2022-04-default-to-tlv-onions
Default to BOLT 4 tlv payload format onions
2022-04-18 13:09:55 -07:00
valentinewallace
b4c645a6ce
Merge pull request #1422 from dunxen/2022-04-invoice-expiry
Add expiry to phantom invoice utility functions
2022-04-17 15:01:53 -04:00
Duncan Dean
8f047ca23f
Add expiry to inbound payment util functions 2022-04-16 22:49:28 +02:00
Viktor Tigerström
c72ae67768 Add tests for defaulting to creating tlv onions 2022-04-16 01:35:32 +02:00
Valentine Wallace
5840374d08
features: advertise wumbo channels as supported 2022-04-15 16:26:55 -04:00
Jeffrey Czyz
83595dbfdc
Merge pull request #1404 from TheBlueMatt/2022-04-buf-writes
Pipe filesystem writes in `lightning-persister` through `BufWriter`
2022-04-15 14:35:01 -05:00
valentinewallace
dc1b36dbcb
Merge pull request #1423 from jkczyz/2022-04-dyn-block-source
Allow `&dyn BlockSource` in `lightning-block-sync`
2022-04-15 14:33:36 -04:00
Matt Corallo
e6c702f786 Log as channel liquidities are/not updated in ProbabilisticScorer 2022-04-15 17:06:58 +00:00
Matt Corallo
8baa4c1945 Add an (unused) Logger reference in ProbabilisticScorer 2022-04-15 17:06:58 +00:00
Jeffrey Czyz
b902cc7c49
Remove unnecessary lifetime bound 2022-04-15 11:41:34 -05:00
Jeffrey Czyz
8967d20b29
Remove mut in lightning-block-sync tests 2022-04-15 11:41:33 -05:00
Jeffrey Czyz
b10217590b
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.
2022-04-15 11:38:48 -05:00
Viktor Tigerström
b28bcfe3d9 Pass PaymentParameters in get_route_and_payment_hash 2022-04-14 23:04:51 +02:00
Viktor Tigerström
a316ef4596 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.
2022-04-14 23:04:51 +02:00
Matt Corallo
d0a1b2b220 Log gossip query msgs at GOSSIP instead of TRACE as they're huge 2022-04-14 02:13:22 +00:00
Matt Corallo
03f655003d
Merge pull request #1384 from valentinewallace/2022-03-chanmanless-phantom-invoices 2022-04-13 14:51:35 +00:00
Matt Corallo
9afc1ec36c
Merge pull request #1406 from TheBlueMatt/2022-04-scorer-precision
[RFC] Expand the precision of our log10 lookup tables + add precision
2022-04-13 14:00:00 +00:00
Valentine Wallace
204dd42a7d
Expose methods for ChannelManager-less phantom invoice generation 2022-04-11 18:43:48 -04:00
Jeffrey Czyz
a3832b029c
Merge pull request #1412 from lightningdevkit/dependabot/github_actions/codecov/codecov-action-3
Bump codecov/codecov-action from 2 to 3
2022-04-11 18:16:06 -04:00
Matt Corallo
30e1922797 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%.
2022-04-11 20:55:55 +00:00
Matt Corallo
4930af9b54 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.
2022-04-10 21:29:33 +00:00
Matt Corallo
711bcefbcc
Merge pull request #1307 from jkczyz/2022-02-block-source-self-ref
Immutable BlockSource interface
2022-04-09 15:25:42 +00:00
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
Jeffrey Czyz
3cdbbf56e4
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.
2022-04-03 20:59:11 -05:00