Commit graph

135 commits

Author SHA1 Message Date
Matt Corallo
35154a15c3 Bump crate versions to 0.0.112/invoice 0.20 2022-10-24 18:53:58 +00:00
Wilmer Paulino
f4f1093edc
Bump workspace to rust edition 2018
Mostly motivated by the need of async/await.
2022-10-21 14:47:34 -07:00
Matt Corallo
12fa0b11a6 Rework chain::Watch return types to make async updates less scary
When a `chain::Watch` `ChannelMonitor` update method is called, the
user has three options:
 (a) persist the monitor update immediately and return success,
 (b) fail to persist the monitor update immediately and return
     failure,
 (c) return a flag indicating the monitor update is in progress and
     will complete in the future.

(c) is rather harmless, and in some deployments should be expected
to be the return value for all monitor update calls, but currently
requires returning `Err(ChannelMonitorUpdateErr::TemporaryFailure)`
which isn't very descriptive and sounds scarier than it is.

Instead, here, we change the return type used to be a single enum
(rather than a Result) and rename `TemporaryFailure`
`UpdateInProgress`.
2022-09-29 20:27:53 +00:00
Matt Corallo
d33f7268fb Stop relying on *Features::known in BP and persister tests
As we move towards specify supported/required feature bits in the
module(s) where they are supported, the global `known` feature set
constructors no longer make sense.

Here we stop relying on the `known` method in the
`lightning-background-processor` and `lightning-persister` crate
tests.
2022-09-14 20:09:36 +00:00
Matt Corallo
f5473d5051 Bump versions to lightning* 0.0.111 and lightning-invoice 0.19 2022-09-12 22:34:27 +00:00
Matt Corallo
b414c0641b
Merge pull request #1658 from lightning-signer/2022-08-bitcoin-0-29
Update bitcoin crate to 0.29.0
2022-08-12 23:51:06 +00:00
Devrandom
7e05623bef Update bitcoin crate to 0.29.0 2022-08-11 00:21:26 +02:00
Valentine Wallace
c242003dd3
Fix CI to error on doc links to private items
Somehow we weren't doing this.
2022-08-07 13:49:12 -04:00
Matt Corallo
e10dfe4fd0 Bump crate versions to 0.0.110/invoice 0.18 2022-07-26 22:01:09 +00:00
Matt Corallo
156cc77753 Bump crate versions to 0.0.109/invoice 0.17 2022-07-01 16:05:33 +00:00
Matt Corallo
5ed3f25b21 Add ChannelManager methods to force close without broadcasting
If a user restores from a backup that they know is stale, they'd
like to force-close all of their channels (or at least the ones
they know are stale) *without* broadcasting the latest state,
asking their peers to do so instead. This simply adds methods to do
so, renaming the existing `force_close_channel` and
`force_close_all_channels` methods to disambiguate further.
2022-06-25 02:25:32 +00:00
Matt Corallo
deac430f17 Update crate versions to 0.0.108/invoice 0.16 2022-06-10 14:53:23 +00:00
Jeffrey Czyz
b2e635f619
Bump crate versions to 0.0.107/invoice 0.15 2022-06-08 18:16:48 -05:00
Viktor Tigerström
14e52cd7a6 Pass counterparty_node_id to force_close_channel 2022-05-14 20:32:44 +02:00
Devrandom
28d33ff9e0 bitcoin crate 0.28.1 2022-05-05 18:04:42 +02:00
Matt Corallo
fa9fc0d094 Fix several "unused" warnings introduced in #1417 2022-04-24 16:03:26 +00:00
John Cantrell
4964944279
implement Persist and Persister with generic KVStorePersister trait 2022-04-20 16:46:58 -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
Matt Corallo
7e93fdb29a 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.
2022-04-03 21:54:15 +00:00
Matt Corallo
0a0f87c00f
Merge pull request #1397 from jkczyz/2022-03-release-0.0.106
Cut 0.0.106
2022-04-03 16:31:54 +00:00
Jeffrey Czyz
de8bb8d261
Bump crate versions to 0.0.106/invoice 0.14 2022-04-03 08:05:08 -05:00
Jurvis Tan
afb7aa85cf
Add NetworkGraph persistence
Instead of creating a separate trait for persisting NetworkGraph, use and rename the existing ChannelManagerPersister to handle them both. persist_graph is then called on removal of stale channels and on exit.
2022-03-29 19:38:40 -07:00
Matt Corallo
def0628332 Bump crate versions to 0.0.105/invoice 0.13 2022-03-01 00:43:24 +00:00
Matt Corallo
5208f0c72a
Merge pull request #1303 from jkczyz/2022-02-docs-with-features
Generate docs with features for docs.rs
2022-02-28 21:00:05 +00:00
Matt Corallo
a2a90ee959 Ignore .tmp files when loading ChannelMonitors in persister
If we are in the middle of persisting an update to a
`ChannelMonitor` when we shutdown (or crash), we'll start up with
a .tmp file lying around. We should ignore it, as failure to
return from the update call should have prevented the
`ChannelManager` from taking any irrevocable action based on the
update.

We're somewhat protected from any filesystem inconsistency behavior
as the `ChannelManager` will refuse to load if we're outright
missing `ChannelMonitor`s.

Fixes #1330.
2022-02-24 19:09:44 +00:00
Jeffrey Czyz
62b1e01ad9
Generate docs with features for docs.rs
Enable generating docs using --all-features or --features="std" where
applicable. Additionally, use doc_auto_cfg to tag items requiring a
feature.

https://doc.rust-lang.org/nightly/rustdoc/unstable-features.html#doc_auto_cfg-automatically-generate-doccfg

This requires building with nightly, which is what is used by docs.rs.

https://docs.rs/about/builds

To test locally, use:

RUSTDOCFLAGS="--cfg docsrs" cargo +nightly doc ...
2022-02-18 15:38:31 -06:00
Matt Corallo
c8e3078ff7 Make router benchmarks more realistic by not running test-only code
`cargo bench` sets `cfg(test)`, causing us to hit some test-only
code in the router when benchmarking, throwing off our benchmarks
substantially. Here we swap from the `unstable` feature to a more
clearly internal feature (`_bench_unstable`) and also checking for
it when enabling test-only code.
2022-02-10 22:28:38 +00:00
hackerrdave
d46c2a20e1 update repo name to use lightningdevkit 2021-12-26 22:53:16 -05:00
Matt Corallo
ec86e2a1a7 Bump versions to 0.0.104/invoice 0.12 2021-12-17 21:34:19 +00:00
Matt Corallo
1ce922c631 Prefer fully-specified paths in test macros
This avoids macros being context-specific use-dependent.
2021-11-26 20:40:51 +00:00
Matt Corallo
2b837bb272 Bump crate versions to 0.0.103/invoice 0.11 2021-11-03 02:20:51 +00:00
Matt Corallo
107c6c7939
Merge pull request #1108 from TheBlueMatt/2021-10-persist-mon-blocks
Persist ChannelMonitors after new blocks are connected
2021-10-20 00:53:26 +00:00
Matt Corallo
5c2ff2cb30 Persist ChannelMonitors after new blocks are connected
This resolves several user complaints (and issues in the sample
node) where startup is substantially delayed as we're always
waiting for the chain data to sync.

Further, in an upcoming PR, we'll be reloading pending payments
from ChannelMonitors on restart, at which point we'll need the
change here which avoids handling events until after the user
has confirmed the `ChannelMonitor` has been persisted to disk.
It will avoid a race where we
 * send a payment/HTLC (persisting the monitor to disk with the
   HTLC pending),
 * force-close the channel, removing the channel entry from the
   ChannelManager entirely,
 * persist the ChannelManager,
 * connect a block which contains a fulfill of the HTLC, generating
   a claim event,
 * handle the claim event while the `ChannelMonitor` is being
   persisted,
 * persist the ChannelManager (before the CHannelMonitor is
   persisted fully),
 * restart, reloading the HTLC as a pending payment in the
   ChannelManager, which now has no references to it except from
   the ChannelMonitor which still has the pending HTLC,
 * replay the block connection, generating a duplicate PaymentSent
   event.
2021-10-20 00:06:17 +00:00
Matt Corallo
89ad059548 Use an opaque type to describe monitor updates in Persist
In the next commit, we'll be originating monitor updates both from
the ChainMonitor and from the ChannelManager, making simple
sequential update IDs impossible.

Further, the existing async monitor update API was somewhat hard to
work with - instead of being able to generate monitor_updated
callbacks whenever a persistence process finishes, you had to
ensure you only did so at least once all previous updates had also
been persisted.

Here we eat the complexity for the user by moving to an opaque
type for monitor updates, tracking which updates are in-flight for
the user and only generating monitor-persisted events once all
pending updates have been committed.
2021-10-19 23:49:04 +00:00
Matt Corallo
f2e47e0db2 Bump crate versions to 0.0.102 and lightning-invoice 0.10 2021-10-18 18:32:36 +00:00
Matt Corallo
6a7c48b60d Move ChannelMonitorUpdateErr to chain as it is a chain::Watch val 2021-10-14 00:16:50 +00:00
Matt Corallo
0dfb24e661 Move Persist trait to chainmonitor as that's the only reference 2021-10-14 00:16:50 +00:00
Matt Corallo
43fe3d55f1 Bump Crate versions to 0.0.101 (and invoice to 0.9) 2021-09-23 18:22:59 +00:00
Matt Corallo
a233780c7e Fix windows-only test failure added in #997
This is a trivial bugfix to add a missing test updated required in
PR 997.
2021-09-21 21:16:51 +00:00
Antoine Riard
6ce7f3e1ce Add ChannelClosed generation at cooperative/force-close/error processing
When we detect a channel `is_shutdown()` or call on it
`force_shutdown()`, we notify the user with a Event::ChannelClosed
informing about the id and closure reason.
2021-09-21 15:46:42 -04:00
Matt Corallo
11f78798d3 Update versions to 0.0.100 and lightning-invoice to 0.8 2021-08-17 18:55:07 +00:00
Matt Corallo
84909447e9 Check IO errors in test using raw_os_error() instead of kind()
std::io::ErrorKind is a `#[non_exhaustive]` enum as more specific
error types are to be added in the future. It was unclear in the
docs until very recently, however, that this is to be done by
re-defining `ErrorKind::Other` errors to new enum variants. Thus,
our tests which check explicitly for `ErrorKind::Other` as a
result of trying to access a directory as a file were incorrect.
Sadly, these generated no meaningful feedback from rustc at all,
except that they're suddenly failing in rustc beta!

After some back-and-forth, it seems rustc is moving forward
breaking existing code in future versions, so we move to the
"correct" check here, which is to check the raw IO error.

See rust-lang/rust#86442 and rust-lang/rust#85746 for more info.
2021-08-02 18:50:00 +00:00
Matt Corallo
3f229052ea Bump dependencies to bitcoin 0.27 and bech32 0.8 2021-07-31 18:29:07 +00:00
Matt Corallo
c9a8b26d58 Bump most crate versions to 0.0.99 and lightning-invoice to 0.7.0 2021-07-09 16:34:46 +00:00
Matt Corallo
9c9081dfcb Bump versions to 0.0.98, lightning-invoice to 0.6.0 2021-06-08 21:08:29 +00:00
Matt Corallo
f551d5946b Bump versions to 0.0.14, lightning-invoice 0.5 2021-05-01 00:43:15 +00:00
Valentine Wallace
6f5d81631a
Make _test_utils depend on bitcoinconsensus feature 2021-04-29 18:39:47 -04:00
Matt Corallo
5e968114b6 Drop the amount parameter to claim_funds
Like the payment_secret parameter, this paramter has been the source
of much confusion, so we just drop it.

Users should prefer to do this check when registering the payment
secret instead of at claim-time.
2021-04-28 15:30:25 -04:00
Matt Corallo
3fdf252bd3 Improve + fix indentation and style in lightning-persister 2021-04-12 19:28:17 -04:00
Matt Corallo
6b2e179bc1 Return ChannelMonitors in a Vec, not HashMap when loading from disk
There's little reason for the HashMap - the ChannelMonitors are
already unique (enforced by file names), and the eventual HashMap
that users need when deserializing the `ChannelManager` is a
slightly different form (it requires no BlockHash entry).
2021-04-12 18:35:24 -04:00