Commit graph

2129 commits

Author SHA1 Message Date
Matt Corallo
d65d7e7257 Bump versions to 0.0.13 across the board
We also skip having different versions for different subcrates,
since that is confusing.
2021-03-09 14:11:11 -05:00
Matt Corallo
00550bac19 Rename background-processor to lightning-background-processor
This matches our naming scheme better and fits better on crates.io.
Also drop the version to 0.0.1 to match our versioning scheme
better.
2021-03-09 14:11:11 -05:00
Matt Corallo
c896461319
Merge pull request #827 from TheBlueMatt/2021-03-invoice-features
Disable MPP routing when the payee does not support it
2021-03-09 17:16:50 +00:00
Matt Corallo
2cb655b3b1
Merge pull request #826 from valentinewallace/raise-max-to-self-delay
Raise max to_self_delay.
2021-03-08 15:44:18 -08:00
Valentine Wallace
b75437dcb1
Raise max to_self_delay.
lnd requires this to_self_delay for the max channel size
(excluding wumbo).
2021-03-08 17:30:02 -05:00
Matt Corallo
b9fef85aa3 Split router benchmark into an MPP and a non-MPP route benchmark 2021-03-08 17:19:23 -05:00
Matt Corallo
ef0f249294 Disable MPP routing when the payee does not support it 2021-03-08 17:19:23 -05:00
Matt Corallo
9e57364a89 Add an Option<>al InvoiceFeatures object for the payee in get_route
We currently only use it to override the graph-specific features
returned in the route, though we should also use it to enable or
disable MPP.

Note that tests which relied on MPP behavior have had all of their
get_route calls upgraded to provide the MPP flag.
2021-03-08 17:19:23 -05:00
Matt Corallo
6b707c6f23
Merge pull request #833 from TheBlueMatt/2021-03-no-xs
Drop C bindings (which are now in a separate repo)
2021-03-08 13:37:27 -08:00
Matt Corallo
05ac59c42f
Merge pull request #830 from TheBlueMatt/2021-03-chanmon-deser-utils
Make chain::Filter slightly easier with some ChannelMonitor utilities.
2021-03-08 13:25:56 -08:00
Matt Corallo
9b55c0349a Make util::logger::macro_logger pub(crate) not pub.
There is no reason for it to be pub, its a largely-internal
implementation detail of how we format our own objects for logging.
2021-03-08 16:23:01 -05:00
Matt Corallo
d793a2fc7a Drop C bindings (which are now in a separate repo)
This allows us to drop the usually-failing C bindings CI check, and
makes Github code search more useful by dropping redundant things.
2021-03-08 13:43:00 -05:00
Matt Corallo
5b230d9137 Create new InvoiceFeatures object for Invoice-specific features
In the past we skipped doing this since invoice parsing occurs in a
different crate. However, we need to accept InvoiceFeatures in routing
now that we support MPP route collection, to detect if we can select
multiple paths or not. Further, we should probably take
rust-lightning-invoice as either a module or a subcrate in this repo.
2021-03-08 13:28:54 -05:00
Matt Corallo
7cda36e26a Add codecov.yml allowing coverage to drop slightly before "failing"
This should remove one big red X in our builds, making it harder
to miss other failing tests.
2021-03-08 12:59:03 -05:00
Matt Corallo
8b4ea56966
Merge pull request #832 from jkczyz/2021-03-typo-fix
Fix misspelling of 'occurred' in public interface
2021-03-08 08:48:15 -08:00
Matt Corallo
f52f777c97 Use the new load_outputs_to_watch util in ChainMonitor
This is slightly more effecient as it avoids a clone, but its also
nice to use our own code more.
2021-03-08 11:45:32 -05:00
Matt Corallo
154dfe5755 Make get_outputs_to_watch return a Vec instead of a HashMap
`get_outputs_to_watch` returned a reference to an existing
`HashMap` avoiding extra clones, but there isn't a huge reason to
do so now that we have to clone to copy it out of the
`ChannelMonitor` mutex. Instead, return a `Vec` since it may be
less memory and it allows us to have a bindings C mapping for the
function.

Co-authored-by: Jeffrey Czyz <jkczyz@gmail.com>
Co-authored-by: Matt Corallo <git@bluematt.me>
2021-03-08 11:45:32 -05:00
Jeffrey Czyz
7a0acf951d
Fix misspelling of 'occurred' in public interface 2021-03-08 00:09:58 -08:00
Matt Corallo
c42ea50cc7
Merge pull request #829 from TheBlueMatt/2021-03-0.0.13-bindings
0.0.13 Bindings Updates
2021-03-07 12:49:15 -08:00
Matt Corallo
f1b4534aad Auto-generated bindings updates 2021-03-07 13:09:37 -05:00
Matt Corallo
14441a0926 [bindings] Check for a wasm32 target before compiling in genbindings 2021-03-07 13:06:07 -05:00
Matt Corallo
33f511dfa0 [bindings] Update demos for new upstream API 2021-03-07 13:06:07 -05:00
Matt Corallo
d039fc5cd1 Make IgnoringMessageHandler and ErroringMessageHandler pub
This is largely useful for bindings, and the off-github discussion
around #814 concluded these should be pub, but the PR was not
updated to capture this. Now that the bindings support generation
for the structs, expose them.
2021-03-07 13:06:07 -05:00
Matt Corallo
f7f7500da5 [bindings] Handle ::-containing paths in generics
Specifically, this is required for some paths which use
`Option<msgs::Message>`.
2021-03-07 13:06:07 -05:00
Matt Corallo
6b4c8e4690 [bindings] Be explicit when calling pointer.is_null()
When the (somewhat anti-pattern)
`impl Deref for X { type Target = X; .. }` is used, this avoids an
infinite dereference exception trying to figure out what type to
resolve `is_null` against.
2021-03-07 13:06:07 -05:00
Matt Corallo
bfa95cd289 [bindings] Avoid double-use'ing traits by writing out the path 2021-03-07 13:06:07 -05:00
Matt Corallo
578f8b72e2 Change ChannelManager::wait to be more descriptive
`wait` doesn't capture enough of what's going on, but also Java
Java doesn't accpet methods just called `wait`, as it conflicts
with existing sync primitives on all Objects.
2021-03-07 13:06:07 -05:00
Matt Corallo
135cff1c95 Add utility in ChannelMonitor to reload chain::Filter data
The deserialization process for `ChannelManager`/`ChannelMonitor`
data includes reloading any relevant `chain::Filter` with data
provided from the `ChannelMonitor`, but its nice if we adapt the
data to `chain::Filter` calls for users.
2021-03-07 13:05:04 -05:00
Matt Corallo
6742343319 [bindings] Support converting Network to rust, update variants 2021-03-05 19:16:29 -05:00
Matt Corallo
b5d88a5422
Merge pull request #823 from jkczyz/2021-03-birthday-hash
Replace default hash with birthday hash
2021-03-05 16:15:05 -08:00
Jeffrey Czyz
873014875c
Correctly update the last block hash on disconnect
When a block is disconnected, the hash of the disconnected block was
used to update the last connected block. However, this amounts to a
no-op because these hashes should be equal. Successive disconnections
would update the hash but leave it one block off.

Normally, this not a problem because the last block_disconnected should
be followed by block_connected since the former is triggered by a chain
re-org. However, this assumes the user calls the API correctly and that
no failure occurs that would prevent block_connected from being called
(e.g., if fetching the connected block fails).

Instead, update the last block hash with the disconnected block's
previous block hash.
2021-03-05 15:45:13 -08:00
Jeffrey Czyz
035dda6708
Hold ChannelManager locks independently
ChannelManager reads channel_state and last_block_hash while processing
funding_created and funding_signed messages. It writes these while
processing block_connected and block_disconnected events. To avoid any
potential deadlocks, have each site hold these locks independent of one
another and in a consistent order.

Additionally, use a RwLock instead of Mutex for last_block_hash since
exclusive access is not needed in funding_created / funding_signed and
cannot be guaranteed in block_connected / block_disconnected because of
the reads in the former.
2021-03-05 15:45:13 -08:00
Jeffrey Czyz
d21d8b3463
Rename header_hash to block_hash 2021-03-05 15:45:12 -08:00
Jeffrey Czyz
31093adef8
Pass along ChannelManager's last_block_hash
ChannelMonitor keeps track of the last block connected. However, it is
initialized with the default block hash, which is a problem if the
ChannelMonitor is serialized before a block is connected. Instead, pass
ChannelManager's last_block_hash, which is initialized with a "birthday"
hash, when creating a new ChannelMonitor.
2021-03-05 15:45:12 -08:00
Jeffrey Czyz
caabc4ef39
Remove last_block_connected from Channel
Tracking the last block was only used to de-duplicate block_connected
calls, but this is no longer required as of the previous commit.
Further, the ChannelManager can pass the latest block hash when needing
to create a ChannelMonitor rather than have each Channel maintain an
up-to-date copy. This is implemented in the next commit.
2021-03-05 15:45:12 -08:00
Jeffrey Czyz
ff4b4c4d36
Remove block_connected de-duplication logic
Calling block_connected for the same block was necessary when clients
were expected to re-fetch filtered blocks with relevant transactions. At
the time, all listeners were notified of the connected block again for
re-scanning. Thus, de-duplication logic was put in place.

However, this requirement is no longer applicable for ChannelManager as
of commit bd39b20f64, so remove this
logic.
2021-03-05 15:45:12 -08:00
Jeffrey Czyz
d28fa54edb
Parameterize ChannelManager::new with a block hash
When ChannelMonitors are persisted, they need to store the most recent
block hash seen. However, for newly created channels the default block
hash is used. If persisted before a block is connected, the funding
output may be missed when syncing after a restart. Instead, initialize
ChannelManager with a "birthday" hash so it can be used later when
creating channels.
2021-03-05 15:44:54 -08:00
bmancini55
44ba52ccf1 Handle query_channel_range message from peer
Initial implementation of handling query_channel_range messages in
NetGraphMsgHandler.  Enqueues a sequence of reply message in the pending
message events buffer.
2021-03-05 17:14:35 -05:00
Matt Corallo
af49a60e2d
Update docs with correct hash type
Co-authored-by: Matt Corallo <git@bluematt.me>
Co-authored-by: Jeffrey Czyz <jkczyz@gmail.com>
2021-03-05 13:40:26 -08:00
Jeffrey Czyz
4cd2e4e94b
Revert "Merge pull request #819 from TheBlueMatt/2021-03-810-rebased"
This reverts commit 793de5fe69, reversing
changes made to 03a5189651.
2021-03-05 13:35:07 -08:00
Matt Corallo
1a8b9be5e4
Merge pull request #808 from TheBlueMatt/2021-02-791-order-fix
Process monitor update events in block_[dis]connected asynchronously
2021-03-05 12:16:21 -08:00
bmancini55
0b14e97c49 Create short_channel_id utils
Util converts parts into u64 SCID
Util extracts block height from u64 SCID

Both will be used when processing gossip_query messages.
2021-03-05 15:09:51 -05:00
bmancini55
8ec5429f0f Add end_blocknum method to query_channel_range
Overflow safe calculation of the ending block number for a query. Can
be used when processing the query.
2021-03-05 15:09:51 -05:00
bmancini55
feca062072 Add SendReplyChannelRange message event
Creates a MessageSendEvent for sending a reply_channel_range message.
This event will be fired when handling inbound query_channel_range
messages in the NetGraphMessageHandler.
2021-03-05 15:09:42 -05:00
Matt Corallo
93a75726a1 Clarify ChannelManager docs somewhat around full blocks
As suggested by Val.
2021-03-05 14:46:29 -05:00
Matt Corallo
5351f9fa03 Expand tests to cover serialization with pending background events 2021-03-05 14:46:29 -05:00
Matt Corallo
d4810087c1 Process monitor update events in block_[dis]connected asynchronously
The instructions for `ChannelManagerReadArgs` indicate that you need
to connect blocks on a newly-deserialized `ChannelManager` in a
separate pass from the newly-deserialized `ChannelMontiors` as the
`ChannelManager` assumes the ability to update the monitors during
block [dis]connected events, saying that users need to:
```
4) Reconnect blocks on your ChannelMonitors
5) Move the ChannelMonitors into your local chain::Watch.
6) Disconnect/connect blocks on the ChannelManager.
```

This is fine for `ChannelManager`'s purpose, but is very awkward
for users. Notably, our new `lightning-block-sync` implemented
on-load reconnection in the most obvious (and performant) way -
connecting the blocks all at once, violating the
`ChannelManagerReadArgs` API.

Luckily, the events in question really don't need to be processed
with the same urgency as most channel monitor updates. The only two
monitor updates which can occur in block_[dis]connected is either
a) in block_connected, we identify a now-confirmed commitment
   transaction, closing one of our channels, or
b) in block_disconnected, the funding transaction is reorganized
   out of the chain, making our channel no longer funded.
In the case of (a), sending a monitor update which broadcasts a
conflicting holder commitment transaction is far from
time-critical, though we should still ensure we do it. In the case
of (b), we should try to broadcast our holder commitment transaction
when we can, but within a few minutes is fine on the scale of
block mining anyway.

Note that in both cases cannot simply move the logic to
ChannelMonitor::block[dis]_connected, as this could result in us
broadcasting a commitment transaction from ChannelMonitor, then
revoking the now-broadcasted state, and only then receiving the
block_[dis]connected event in the ChannelManager.

Thus, we move both events into an internal invent queue and process
them in timer_chan_freshness_every_min().
2021-03-05 14:46:29 -05:00
Matt Corallo
1efc0c85eb
Merge pull request #825 from jkczyz/2021-03-client-visibility
Expose RpcClient and RestClient interfaces as pub
2021-03-05 09:44:28 -08:00
Matt Corallo
27276695fa
Merge pull request #821 from jkczyz/2021-03-fix-build-warnings
Fix build warnings
2021-03-05 09:44:21 -08:00
Jeffrey Czyz
f48e273560
Expose RpcClient and RestClient interfaces as pub
Useful for use outside of the BlockSource context, e.g., when
implementing fee estimation or transaction broadcasting.
2021-03-03 17:32:39 -08:00