]> git.bitcoin.ninja Git - rust-lightning/log
rust-lightning
3 years agoAdd methods to set features in Features objects.
Valentine Wallace [Mon, 8 Mar 2021 00:26:01 +0000 (19:26 -0500)]
Add methods to set features in Features objects.

3 years agoMerge pull request #837 from TheBlueMatt/2021-03-0.0.13
Matt Corallo [Wed, 10 Mar 2021 23:26:50 +0000 (23:26 +0000)]
Merge pull request #837 from TheBlueMatt/2021-03-0.0.13

3 years agoMerge pull request #834 from TheBlueMatt/2021-03-no-pub-internals
Matt Corallo [Wed, 10 Mar 2021 01:54:55 +0000 (01:54 +0000)]
Merge pull request #834 from TheBlueMatt/2021-03-no-pub-internals

Make `util::logger::macro_logger` pub(crate) not pub.

3 years agoUpdate licenses and add missing fields in Cargo.toml files 2021-03-0.0.13
Matt Corallo [Tue, 9 Mar 2021 21:51:14 +0000 (16:51 -0500)]
Update licenses and add missing fields in Cargo.toml files

3 years agoAdd missing feature to background-processor dev-dependencies
Matt Corallo [Tue, 9 Mar 2021 21:47:43 +0000 (16:47 -0500)]
Add missing feature to background-processor dev-dependencies

3 years agoMerge pull request #835 from TheBlueMatt/2021-03-0.0.13 v0.0.13
Matt Corallo [Tue, 9 Mar 2021 20:57:07 +0000 (20:57 +0000)]
Merge pull request #835 from TheBlueMatt/2021-03-0.0.13

Bump Version to 0.0.13

3 years agoBump versions to 0.0.13 across the board
Matt Corallo [Mon, 8 Mar 2021 23:50:35 +0000 (18:50 -0500)]
Bump versions to 0.0.13 across the board

We also skip having different versions for different subcrates,
since that is confusing.

3 years agoRename `background-processor` to `lightning-background-processor`
Matt Corallo [Mon, 8 Mar 2021 23:48:24 +0000 (18:48 -0500)]
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.

3 years agoMerge pull request #827 from TheBlueMatt/2021-03-invoice-features
Matt Corallo [Tue, 9 Mar 2021 17:16:50 +0000 (17:16 +0000)]
Merge pull request #827 from TheBlueMatt/2021-03-invoice-features

Disable MPP routing when the payee does not support it

3 years agoMerge pull request #826 from valentinewallace/raise-max-to-self-delay
Matt Corallo [Mon, 8 Mar 2021 23:44:18 +0000 (15:44 -0800)]
Merge pull request #826 from valentinewallace/raise-max-to-self-delay

Raise max to_self_delay.

3 years agoRaise max to_self_delay.
Valentine Wallace [Thu, 4 Mar 2021 18:28:35 +0000 (13:28 -0500)]
Raise max to_self_delay.

lnd requires this to_self_delay for the max channel size
(excluding wumbo).

3 years agoSplit router benchmark into an MPP and a non-MPP route benchmark 2021-03-invoice-features
Matt Corallo [Fri, 5 Mar 2021 03:37:18 +0000 (22:37 -0500)]
Split router benchmark into an MPP and a non-MPP route benchmark

3 years agoDisable MPP routing when the payee does not support it
Matt Corallo [Fri, 5 Mar 2021 03:36:34 +0000 (22:36 -0500)]
Disable MPP routing when the payee does not support it

3 years agoAdd an Option<>al InvoiceFeatures object for the payee in get_route
Matt Corallo [Fri, 5 Mar 2021 03:13:18 +0000 (22:13 -0500)]
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.

3 years agoMerge pull request #833 from TheBlueMatt/2021-03-no-xs
Matt Corallo [Mon, 8 Mar 2021 21:37:27 +0000 (13:37 -0800)]
Merge pull request #833 from TheBlueMatt/2021-03-no-xs

Drop C bindings (which are now in a separate repo)

3 years agoMerge pull request #830 from TheBlueMatt/2021-03-chanmon-deser-utils
Matt Corallo [Mon, 8 Mar 2021 21:25:56 +0000 (13:25 -0800)]
Merge pull request #830 from TheBlueMatt/2021-03-chanmon-deser-utils

Make chain::Filter slightly easier with some ChannelMonitor utilities.

3 years agoMake `util::logger::macro_logger` pub(crate) not pub. 2021-03-no-pub-internals
Matt Corallo [Sun, 7 Mar 2021 21:24:05 +0000 (16:24 -0500)]
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.

3 years agoDrop C bindings (which are now in a separate repo) 2021-03-no-xs
Matt Corallo [Mon, 8 Mar 2021 18:43:00 +0000 (13:43 -0500)]
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.

3 years agoCreate new `InvoiceFeatures` object for Invoice-specific features
Matt Corallo [Fri, 5 Mar 2021 03:10:48 +0000 (22:10 -0500)]
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.

3 years agoAdd codecov.yml allowing coverage to drop slightly before "failing"
Matt Corallo [Mon, 8 Mar 2021 17:50:07 +0000 (12:50 -0500)]
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.

3 years agoMerge pull request #832 from jkczyz/2021-03-typo-fix
Matt Corallo [Mon, 8 Mar 2021 16:48:15 +0000 (08:48 -0800)]
Merge pull request #832 from jkczyz/2021-03-typo-fix

Fix misspelling of 'occurred' in public interface

3 years agoUse the new `load_outputs_to_watch` util in `ChainMonitor` 2021-03-chanmon-deser-utils
Matt Corallo [Mon, 8 Mar 2021 05:06:31 +0000 (00:06 -0500)]
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.

3 years agoMake `get_outputs_to_watch` return a `Vec` instead of a `HashMap`
Matt Corallo [Sun, 7 Mar 2021 18:00:11 +0000 (13:00 -0500)]
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>
3 years agoFix misspelling of 'occurred' in public interface
Jeffrey Czyz [Mon, 8 Mar 2021 08:09:58 +0000 (00:09 -0800)]
Fix misspelling of 'occurred' in public interface

3 years agoMerge pull request #829 from TheBlueMatt/2021-03-0.0.13-bindings
Matt Corallo [Sun, 7 Mar 2021 20:49:15 +0000 (12:49 -0800)]
Merge pull request #829 from TheBlueMatt/2021-03-0.0.13-bindings

0.0.13 Bindings Updates

3 years agoAuto-generated bindings updates 2021-03-0.0.13-bindings
Matt Corallo [Sun, 7 Mar 2021 18:09:20 +0000 (13:09 -0500)]
Auto-generated bindings updates

3 years ago[bindings] Check for a wasm32 target before compiling in genbindings
Matt Corallo [Sat, 6 Mar 2021 14:50:43 +0000 (09:50 -0500)]
[bindings] Check for a wasm32 target before compiling in genbindings

3 years ago[bindings] Update demos for new upstream API
Matt Corallo [Sat, 6 Mar 2021 00:09:26 +0000 (19:09 -0500)]
[bindings] Update demos for new upstream API

3 years agoMake IgnoringMessageHandler and ErroringMessageHandler pub
Matt Corallo [Tue, 2 Mar 2021 15:25:37 +0000 (10:25 -0500)]
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.

3 years ago[bindings] Handle ::-containing paths in generics
Matt Corallo [Mon, 1 Mar 2021 22:08:51 +0000 (17:08 -0500)]
[bindings] Handle ::-containing paths in generics

Specifically, this is required for some paths which use
`Option<msgs::Message>`.

3 years ago[bindings] Be explicit when calling pointer.is_null()
Matt Corallo [Mon, 1 Mar 2021 22:07:29 +0000 (17:07 -0500)]
[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.

3 years ago[bindings] Avoid double-use'ing traits by writing out the path
Matt Corallo [Mon, 1 Mar 2021 22:06:25 +0000 (17:06 -0500)]
[bindings] Avoid double-use'ing traits by writing out the path

3 years agoChange ChannelManager::wait to be more descriptive
Matt Corallo [Fri, 26 Feb 2021 16:28:55 +0000 (11:28 -0500)]
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.

3 years agoAdd utility in `ChannelMonitor` to reload `chain::Filter` data
Matt Corallo [Sun, 7 Mar 2021 17:58:14 +0000 (12:58 -0500)]
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.

3 years ago[bindings] Support converting Network to rust, update variants
Matt Corallo [Fri, 5 Mar 2021 23:51:23 +0000 (18:51 -0500)]
[bindings] Support converting Network to rust, update variants

3 years agoMerge pull request #823 from jkczyz/2021-03-birthday-hash
Matt Corallo [Sat, 6 Mar 2021 00:15:05 +0000 (16:15 -0800)]
Merge pull request #823 from jkczyz/2021-03-birthday-hash

Replace default hash with birthday hash

3 years agoCorrectly update the last block hash on disconnect
Jeffrey Czyz [Thu, 4 Mar 2021 02:33:54 +0000 (18:33 -0800)]
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.

3 years agoHold ChannelManager locks independently
Jeffrey Czyz [Fri, 5 Mar 2021 20:37:50 +0000 (12:37 -0800)]
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.

3 years agoRename header_hash to block_hash
Jeffrey Czyz [Thu, 4 Mar 2021 19:47:09 +0000 (11:47 -0800)]
Rename header_hash to block_hash

3 years agoPass along ChannelManager's last_block_hash
Jeffrey Czyz [Fri, 5 Mar 2021 02:22:37 +0000 (18:22 -0800)]
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.

3 years agoRemove last_block_connected from Channel
Jeffrey Czyz [Fri, 5 Mar 2021 01:39:21 +0000 (17:39 -0800)]
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.

3 years agoRemove block_connected de-duplication logic
Jeffrey Czyz [Fri, 5 Mar 2021 00:58:26 +0000 (16:58 -0800)]
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 bd39b20f642e042981e4fdd5f3600a357be51931, so remove this
logic.

3 years agoParameterize ChannelManager::new with a block hash
Jeffrey Czyz [Wed, 3 Mar 2021 19:24:55 +0000 (11:24 -0800)]
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.

3 years agoUpdate docs with correct hash type
Matt Corallo [Tue, 2 Mar 2021 18:07:43 +0000 (13:07 -0500)]
Update docs with correct hash type

Co-authored-by: Matt Corallo <git@bluematt.me>
Co-authored-by: Jeffrey Czyz <jkczyz@gmail.com>
3 years agoRevert "Merge pull request #819 from TheBlueMatt/2021-03-810-rebased"
Jeffrey Czyz [Fri, 5 Mar 2021 21:28:20 +0000 (13:28 -0800)]
Revert "Merge pull request #819 from TheBlueMatt/2021-03-810-rebased"

This reverts commit 793de5fe6944bb6ab414934e53a7ae80bb5a9a31, reversing
changes made to 03a518965100b6852f36e4f95ead4c1d93f5c4b0.

3 years agoMerge pull request #808 from TheBlueMatt/2021-02-791-order-fix
Matt Corallo [Fri, 5 Mar 2021 20:16:21 +0000 (12:16 -0800)]
Merge pull request #808 from TheBlueMatt/2021-02-791-order-fix

Process monitor update events in block_[dis]connected asynchronously

3 years agoClarify ChannelManager docs somewhat around full blocks 2021-02-791-order-fix
Matt Corallo [Mon, 1 Mar 2021 22:30:41 +0000 (17:30 -0500)]
Clarify ChannelManager docs somewhat around full blocks

As suggested by Val.

3 years agoExpand tests to cover serialization with pending background events
Matt Corallo [Fri, 26 Feb 2021 17:50:46 +0000 (12:50 -0500)]
Expand tests to cover serialization with pending background events

3 years agoProcess monitor update events in block_[dis]connected asynchronously
Matt Corallo [Fri, 26 Feb 2021 17:02:11 +0000 (12:02 -0500)]
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().

3 years agoMerge pull request #825 from jkczyz/2021-03-client-visibility
Matt Corallo [Fri, 5 Mar 2021 17:44:28 +0000 (09:44 -0800)]
Merge pull request #825 from jkczyz/2021-03-client-visibility

Expose RpcClient and RestClient interfaces as pub

3 years agoMerge pull request #821 from jkczyz/2021-03-fix-build-warnings
Matt Corallo [Fri, 5 Mar 2021 17:44:21 +0000 (09:44 -0800)]
Merge pull request #821 from jkczyz/2021-03-fix-build-warnings

Fix build warnings

3 years agoExpose RpcClient and RestClient interfaces as pub
Jeffrey Czyz [Thu, 4 Mar 2021 01:32:39 +0000 (17:32 -0800)]
Expose RpcClient and RestClient interfaces as pub

Useful for use outside of the BlockSource context, e.g., when
implementing fee estimation or transaction broadcasting.

3 years agoFix build warnings
Jeffrey Czyz [Wed, 3 Mar 2021 05:30:34 +0000 (21:30 -0800)]
Fix build warnings

3 years agoChange ShutdownResult type to better capture the possibilites
Matt Corallo [Fri, 26 Feb 2021 02:55:30 +0000 (21:55 -0500)]
Change ShutdownResult type to better capture the possibilites

The return value from Channel::force_shutdown previously always
returned a `ChannelMonitorUpdate`, but expected it to only be
applied in the case that it *also* returned a Some for the funding
transaction output.

This is confusing, instead we move the `ChannelMontiorUpdate`
inside the Option, making it hold a tuple instead.

3 years agoAdd a few notes about deserializing stale ChannelManagers
Matt Corallo [Wed, 3 Feb 2021 20:13:06 +0000 (15:13 -0500)]
Add a few notes about deserializing stale ChannelManagers

See diff for more details

3 years agoFix indentation in test_htlc_no_detection
Matt Corallo [Sun, 7 Feb 2021 23:15:21 +0000 (18:15 -0500)]
Fix indentation in test_htlc_no_detection

3 years agoMove functional tests involving reorgs to reorg_test
Matt Corallo [Sun, 7 Feb 2021 23:06:58 +0000 (18:06 -0500)]
Move functional tests involving reorgs to reorg_test

functional_tests.rs is huge, so anything we can do to split it up
some is helpful. This also exposes a somewhat glaring lack of
reorgs in our existing tests.

3 years agoMerge pull request #646 from naumenkogs/2020-06-router-mpp
Matt Corallo [Wed, 3 Mar 2021 01:32:45 +0000 (20:32 -0500)]
Merge pull request #646 from naumenkogs/2020-06-router-mpp

MPP on the router side

3 years agoMerge pull request #819 from TheBlueMatt/2021-03-810-rebased
Matt Corallo [Wed, 3 Mar 2021 00:04:23 +0000 (16:04 -0800)]
Merge pull request #819 from TheBlueMatt/2021-03-810-rebased

Change ChannelManager deserialization to return an optional blockhash

3 years agoMerge pull request #818 from jkczyz/2021-03-validate-best-block-header
Matt Corallo [Wed, 3 Mar 2021 00:03:42 +0000 (16:03 -0800)]
Merge pull request #818 from jkczyz/2021-03-validate-best-block-header

Add validate_best_block_header utility

3 years agoMerge pull request #816 from valentinewallace/remove-simple-outer-arcs
Matt Corallo [Wed, 3 Mar 2021 00:02:44 +0000 (16:02 -0800)]
Merge pull request #816 from valentinewallace/remove-simple-outer-arcs

Remove simple outer arcs

3 years agoDon't underpay htlc_min due to path contribution
Gleb Naumenko [Mon, 1 Mar 2021 10:37:51 +0000 (12:37 +0200)]
Don't underpay htlc_min due to path contribution

We could have possibly constructed a slightly inconsistent
path: since we reduce value being transferred all the way, we
could have violated htlc_minimum_msat on some channels
we already passed (assuming dest->source direction). Here,
we recompute the fees again, so that if that's the case, we
match the currently underpaid htlc_minimum_msat with fees.

3 years agoUpdate docs to use the new deserialization requirements 2021-03-810-rebased
Matt Corallo [Tue, 2 Mar 2021 18:07:43 +0000 (13:07 -0500)]
Update docs to use the new deserialization  requirements

3 years agoChange ChannelMonitor deserialization to return an optional blockhash.
Valentine Wallace [Tue, 2 Mar 2021 00:47:55 +0000 (19:47 -0500)]
Change ChannelMonitor deserialization to return an optional blockhash.

See previous commit msg for details.

3 years agoChange ChannelManager deserialization to return an optional blockhash
Valentine Wallace [Fri, 26 Feb 2021 21:09:28 +0000 (16:09 -0500)]
Change ChannelManager deserialization to return an optional blockhash

If the ChannelManager never receives any blocks, it'll return a default blockhash
on deserialization. It's preferable for this to be an Option instead.

3 years agoMind htlc_minimum_msat when truncating overpaid value
Gleb Naumenko [Wed, 17 Feb 2021 20:43:16 +0000 (22:43 +0200)]
Mind htlc_minimum_msat when truncating overpaid value

At truncating the overpaid value, if we fall below
htlc_minimum_msat, reach it by increasing fees.

3 years agoUse outbound_capacity_msat from first_hops for routing
Gleb Naumenko [Sun, 20 Dec 2020 14:19:25 +0000 (16:19 +0200)]
Use outbound_capacity_msat from first_hops for routing

3 years agoImplement finding paths for MPP
Gleb Naumenko [Mon, 10 Aug 2020 10:50:29 +0000 (13:50 +0300)]
Implement finding paths for MPP

3 years agoAdd validate_best_block_header utility
Jeffrey Czyz [Tue, 2 Mar 2021 18:03:11 +0000 (10:03 -0800)]
Add validate_best_block_header utility

Refactor synchronize_listeners by pulling out a function returning the
validated block header of a BlockSource's best chain tip. This is needed
when a node is started from scratch and has no listeners to sync.

3 years agoMerge pull request #814 from TheBlueMatt/2021-03-optional-handlers
Matt Corallo [Tue, 2 Mar 2021 15:00:46 +0000 (07:00 -0800)]
Merge pull request #814 from TheBlueMatt/2021-03-optional-handlers

Provide Dummy routing and channel message handlers for users

3 years agoMerge pull request #813 from jkczyz/2021-02-channel-monitor-mutex
Matt Corallo [Tue, 2 Mar 2021 15:00:20 +0000 (07:00 -0800)]
Merge pull request #813 from jkczyz/2021-02-channel-monitor-mutex

Use interior mutability in ChannelMonitor

3 years agoImplement chain::Listen without using RefCell
Jeffrey Czyz [Mon, 1 Mar 2021 06:39:01 +0000 (22:39 -0800)]
Implement chain::Listen without using RefCell

The implementation of chain::Listen for ChannelMonitor required using a
RefCell since its block_connected method required a mutable borrow. This
is no longer the case since ChannelMonitor now uses interior mutability
via a Mutex. So the RefCell is no longer needed.

3 years agoChange Mutex to RwLock in ChainMonitor
Jeffrey Czyz [Mon, 1 Mar 2021 06:26:41 +0000 (22:26 -0800)]
Change Mutex to RwLock in ChainMonitor

Now that ChannelMonitor uses an internal Mutex to support interior
mutability, ChainMonitor can use a RwLock to manage its ChannelMonitor
map. This allows parallelization of update_channel operations since an
exclusive lock only needs to be held when adding to the map in
watch_channel.

3 years agoUse consistent variable naming in ChainMonitor
Jeffrey Czyz [Mon, 1 Mar 2021 20:01:43 +0000 (12:01 -0800)]
Use consistent variable naming in ChainMonitor

3 years agoMove ChannelMonitor state behind a Mutex
Jeffrey Czyz [Mon, 1 Mar 2021 05:42:27 +0000 (21:42 -0800)]
Move ChannelMonitor state behind a Mutex

ChainMonitor accesses a set of ChannelMonitors behind a single Mutex.
As a result, update_channel operations cannot be parallelized. It also
requires using a RefCell around a ChannelMonitor when implementing
chain::Listen.

Moving the Mutex into ChannelMonitor avoids these problems and aligns it
better with other interfaces. Note, however, that get_funding_txo and
get_outputs_to_watch now clone the underlying data rather than returning
references.

3 years agoAdd utility constructors to PeerHandler to use a dummy handler 2021-03-optional-handlers
Matt Corallo [Mon, 1 Mar 2021 23:04:20 +0000 (18:04 -0500)]
Add utility constructors to PeerHandler to use a dummy handler

3 years agoProvide Dummy routing and channel message handlers for users
Matt Corallo [Mon, 1 Mar 2021 20:10:59 +0000 (15:10 -0500)]
Provide Dummy routing and channel message handlers for users

We currently "support" not having a router or channel in memory by
forcing users to implement the same, but its trivial to provide our
own dummy implementations.

3 years agoMerge pull request #811 from TheBlueMatt/2021-02-bindings-rust-bump
Matt Corallo [Mon, 1 Mar 2021 23:35:35 +0000 (15:35 -0800)]
Merge pull request #811 from TheBlueMatt/2021-02-bindings-rust-bump

Update bindings for new Listen interface

3 years agoAdd simple README about our C bindings generation stuff 2021-02-bindings-rust-bump
Matt Corallo [Fri, 19 Feb 2021 22:56:15 +0000 (17:56 -0500)]
Add simple README about our C bindings generation stuff

3 years ago[bindings] Build a wasm32-wasi library in genbindings.sh
Matt Corallo [Sat, 9 Jan 2021 02:55:47 +0000 (21:55 -0500)]
[bindings] Build a wasm32-wasi library in genbindings.sh

This will switch to use the clang/C WASM ABI instead of the
wasm_bindgen WASM ABI as of rustc 1.51 (or nightly since [1]),
allowing us to link C and Rust code in a single wasm binary.

[1] https://github.com/rust-lang/rust/pull/79998

3 years agoUpdate auto-generated bindings
Matt Corallo [Fri, 26 Feb 2021 23:21:03 +0000 (18:21 -0500)]
Update auto-generated bindings

3 years ago[bindings] Be explicit when calling trait methods in generated code
Matt Corallo [Fri, 26 Feb 2021 23:16:14 +0000 (18:16 -0500)]
[bindings] Be explicit when calling trait methods in generated code

For ChannelManager, at least, we have two separate functions called
block_connected, one in the Listen trait, one in the struct, we
need to be explicit with which one we're trying to call.

3 years agoFix doc typo introduced in the ChannelKeys->Sign renaming
Matt Corallo [Mon, 22 Feb 2021 16:59:17 +0000 (11:59 -0500)]
Fix doc typo introduced in the ChannelKeys->Sign renaming

3 years ago[bindings] Use global context for secp256k1
Matt Corallo [Mon, 1 Feb 2021 05:09:50 +0000 (00:09 -0500)]
[bindings] Use global context for secp256k1

Note that this uses https://github.com/rust-bitcoin/rust-secp256k1/pull/279

3 years agoMerge pull request #802 from TheBlueMatt/2021-01-update-rust-bitcoin
Matt Corallo [Mon, 1 Mar 2021 00:43:08 +0000 (16:43 -0800)]
Merge pull request #802 from TheBlueMatt/2021-01-update-rust-bitcoin

Update rust-bitcoin and add secp256k1 context randomization

3 years agoMerge pull request #806 from valentinewallace/monitor-data-persistence-path
Matt Corallo [Sun, 28 Feb 2021 00:34:54 +0000 (16:34 -0800)]
Merge pull request #806 from valentinewallace/monitor-data-persistence-path

persist: Persist ChannelMonitors in their own directory.

3 years agoRebuild full_stack_target test vector for new secp256k1 fuzz req 2021-01-update-rust-bitcoin
Matt Corallo [Fri, 19 Feb 2021 01:04:47 +0000 (20:04 -0500)]
Rebuild full_stack_target test vector for new secp256k1 fuzz req

3 years agoLog full signed remote commitment transaction hex in channel
Matt Corallo [Fri, 19 Feb 2021 01:02:06 +0000 (20:02 -0500)]
Log full signed remote commitment transaction hex in channel

This is useful when rebuilding the full_stack_target test vector

3 years agoRandomize secp contexts for marginally better sidechannel resistance
Matt Corallo [Sat, 13 Feb 2021 16:20:07 +0000 (11:20 -0500)]
Randomize secp contexts for marginally better sidechannel resistance

3 years agoUse lowmemory mode for secp256k1 fuzzing, reducing memcpy time
Matt Corallo [Sat, 27 Feb 2021 04:45:41 +0000 (23:45 -0500)]
Use lowmemory mode for secp256k1 fuzzing, reducing memcpy time

3 years agoUse rust-secp256k1 PR 282 and bitcoin_hashes PR 111 in fuzzing
Matt Corallo [Fri, 19 Feb 2021 01:35:54 +0000 (20:35 -0500)]
Use rust-secp256k1 PR 282 and bitcoin_hashes PR 111 in fuzzing

3 years agoSimpleArcPeerManager type: remove outer Arc for flexibility
Valentine Wallace [Fri, 26 Feb 2021 22:58:56 +0000 (17:58 -0500)]
SimpleArcPeerManager type: remove outer Arc for flexibility

3 years agoSimpleArcChannelManager type: remove outer Arc for flexibility
Valentine Wallace [Fri, 26 Feb 2021 22:55:13 +0000 (17:55 -0500)]
SimpleArcChannelManager type: remove outer Arc for flexibility

3 years agoApply --cfg=fuzzing when fuzzing, as required by new secp256k1
Matt Corallo [Fri, 19 Feb 2021 20:07:28 +0000 (15:07 -0500)]
Apply --cfg=fuzzing when fuzzing, as required by new secp256k1

Note that rust-fuzz wrappers (including honggfuzz) already apply
this for us.

3 years agoUpdate rust-bitcoin
Matt Corallo [Fri, 15 Jan 2021 01:57:56 +0000 (20:57 -0500)]
Update rust-bitcoin

3 years agopersist: Persist ChannelMonitors in their own directory.
Valentine Wallace [Fri, 26 Feb 2021 16:33:51 +0000 (11:33 -0500)]
persist: Persist ChannelMonitors in their own directory.

3 years agoMerge pull request #791 from jkczyz/2021-01-spv-client
Matt Corallo [Fri, 26 Feb 2021 15:54:01 +0000 (07:54 -0800)]
Merge pull request #791 from jkczyz/2021-01-spv-client

SPV client utility for syncing a lightning node

3 years agoUtility for syncing a set of chain listeners
Jeffrey Czyz [Fri, 5 Feb 2021 03:20:03 +0000 (19:20 -0800)]
Utility for syncing a set of chain listeners

Add a utility for syncing a set of chain listeners to a common chain
tip. Required to use before creating an SpvClient when the chain
listener used with the client is actually a set of listeners each of
which may have had left off at a different block. This would occur when
the listeners had been persisted individually at different frequencies
(e.g., a ChainMonitor's individual ChannelMonitors).

3 years agoAdd SpvClient used to poll for the best chain tip
Jeffrey Czyz [Thu, 4 Feb 2021 01:41:03 +0000 (17:41 -0800)]
Add SpvClient used to poll for the best chain tip

Adds a lightweight client for polling one or more block sources for the
best chain tip. Notifies listeners of blocks connected or disconnected
since the last poll. Useful for keeping a Lightning node in sync with
the chain.

3 years agoAdd ChainNotifier and define ChainListener trait
Jeffrey Czyz [Mon, 1 Feb 2021 21:17:20 +0000 (13:17 -0800)]
Add ChainNotifier and define ChainListener trait

Add an interface for being notified of block connected and disconnected
events, along with a notifier for generating such events. Used while
polling block sources for a new tip in order to feed these events into
ChannelManager and ChainMonitor.