Commit graph

1809 commits

Author SHA1 Message Date
Ryan Loomba
c8e49aa398 trivial changes to fix clippy::write_with_newline warnings 2020-10-08 16:06:03 -07:00
Matt Corallo
52121ea97e
Merge pull request #739 from rloomba/rloomba/add-clippy-to-travis
Add clippy to Travis integration
2020-10-08 11:21:00 -07:00
Ryan Loomba
262172cddb add linting to Github CI 2020-10-08 10:47:49 -07:00
Ryan Loomba
426c5b227d add clippy to travis integration 2020-10-08 09:59:52 -07:00
Ryan Loomba
1276cc72de fix all clippy::redundant_field_names warnings 2020-10-07 11:20:21 -07:00
Matt Corallo
e808d50b9d Fix passing -O1 to build from cargo test
In 9e03087d6a we started setting
`opt-level` only on profile.test and not profile.dev. When that
commit was authored I tested only that rustc was being called with
opt-level set in its flags, not that the resulted run ran at the
speed I expected. It seems profile.test isn't applied properly to
dependencies or so, resulting in tests running much slower than
they do at profile.dev.opt-level=1.
2020-10-05 14:24:41 -04:00
Matt Corallo
f35a5ce659
Merge pull request #734 from TheBlueMatt/2020-10-ci-no-git-conf
Don't let CI fail to check commits b/c git isn't configured in CI
2020-10-05 10:27:35 -07:00
Matt Corallo
856648614e
Merge pull request #722 from TheBlueMatt/2020-09-broken-fn
Drop the redundant/broken `ChannelMonitor::get_monitored_outpoints`
2020-10-05 09:50:08 -07:00
Matt Corallo
8e99800329 Drop now-unused Vec of outpoints in remote-commitment-tx-tracking
This nearly fully reverts 6f08779b04,
removing the extra data storage that it added.
2020-10-05 12:19:41 -04:00
Matt Corallo
a162840ffd Drop the redundant/broken ChannelMonitor::get_monitored_outpoints
In review of the final doc changes in #649, I noticed there
appeared to be redundant monitored-outpoints function in
`ChannelMonitor` - `get_monitored_outpoints()` and
`get_outputs_to_watch()`.

In 6f08779b04,
get_monitored_outpoints() was added, with its behavior largely the
same as today's - only returning the set of remote commitment txn
outputs that we've learned about on-chain. This is clearly not
sufficient, and in 73dce207dd,
`get_outputs_to_watch` was added which was overly cautious to
ensure nothing was missed. Still, the author of 73dce207dd
(me) seemed entirely unaware of the work in 6f08779b04
(also me), despite the function being the literal next function in
the same file. This is presumably because it was assumed that
`get_monitored_outpoints` referred to oupoints for which we should
monitor for spends of (which is true), while `get_outputs_to_watch`
referred to outpouts which we should monitor for the transaction
containing said output (which is not true), or something of that
nature. Specifically, it is the expected behavior that the only
time we care about `Filter::register_tx` is for the funding
transaction (which we aren't aware of the inputs of), but for all
other transactions we register interest on the basis of an outpoint
in the previous transaction (ie via `Filter::register_output`).

Here we drop the broken-on-day-one `get_monitored_outpoints()`
version, but assert in testing that the values which it would return
are all present in `get_outputs_to_watch()`.
2020-10-05 12:19:41 -04:00
Matt Corallo
45a558b170
Merge pull request #716 from TheBlueMatt/2020-09-fee-tests
(Fix and) Test that txn pay at least a minimum relay fee in functional tests
2020-10-05 09:18:51 -07:00
Matt Corallo
3219926258 Test that txn pay at least a minimum relay fee in functional tests
This also pays a fee on the transactions we generate in response to
SpendableOutputDescriptors in tests.

This fixes the known issues in #630, though we should test for
standardness in other ways as well.
2020-10-05 11:54:24 -04:00
Matt Corallo
b43a7e3ef3 Fix feerate calculation on closing transactions
This resolves a number of bugs around how we calculate feerates on
closing transactions:

 * We previously calculated the weight wrong both by always
   counting two outputs instead of counting the number of outputs
   that actually exist in the closing transaction and by not
   counting the witness redeemscript.
 * We use assertions to check the calculated weight matches what we
   actually build (with debug_assertions for variable-length sigs).
 * As an additional sanity check, we really should check that the
   transaction had at least min-relay-fee when we were the channel
   initator.
2020-10-05 11:32:30 -04:00
Matt Corallo
6366fc7154 Fix max fee_satoshis constant to be 21 million, not 2.1 million.
Though hopefully we never see a fee of 2.1 million BTC, either...
2020-10-05 11:32:30 -04:00
Matt Corallo
89e40fe224 Don't let CI fail to check commits b/c git isn't configured in CI
This fixes #733 by just setting a dummy git name/email before
calling `git rebase` in CI.
2020-10-02 16:37:37 -04:00
Matt Corallo
937d1d8bae
Merge pull request #731 from TheBlueMatt/2020-10-fix-big-lock
Actually hold the total_consistency_lock instead of take-and-drop
2020-10-02 11:53:48 -07:00
Matt Corallo
7d38c2530a
Merge pull request #730 from TheBlueMatt/2020-09-no-rescan
Drop last bits of rescan as its too complicated to be worth having
2020-10-02 11:22:44 -07:00
Matt Corallo
ddebf36eae Actually hold the total_consistency_lock instead of take-and-drop
It was noticed (via clippy) by @casey that we were taking and then
immediately dropping the total_consistency_lock because `let _ =`
doesn't actually bind the response to anything. This appears to be
a consequence of wanting `if let Some(_) =` to not hold a ref to
the contained value at all, but is relatively surprising to me.
2020-10-02 12:51:25 -04:00
Matt Corallo
2bd571d2f9 Drop last bits of rescan as its too complicated to be worth having
Previously, we had a concept of "rescaning" blocks when we detected
a need to monitor for a new set of outputs in future blocks while
connecting a block. In such cases, we'd need to possibly learn about
these new spends later in the *same block*, requiring clients who
filter blocks to get a newly-filtered copy of the same block. While
redoing the chain access API, it became increasingly clear this was
an overly complicated API feature, and it seems likely most clients
will not use it anyway.

Further, any client who *does* filter blocks can simply update their
filtering algorithm to include any descendants of matched
transactions in the filter results, avoiding the need for rescan
support entirely.

Thus, it was decided that we'd move forward without rescan support
in #649, however to avoid significant further changes in the
already-large 649, we decided to fully remove support in a
follow-up.

Here, we remove the API features that existed for rescan and fix
the few tests to not rely on it.

After this commit, we now only ever have one possible version of
block connection transactions, making it possible to be
significantly more confident in our test coverage actually
capturing all realistic scenarios.
2020-10-02 12:36:46 -04:00
Matt Corallo
b627aa6e7c Drop stale comment about a rescan that doesn't happen in tests 2020-10-02 12:36:46 -04:00
Matt Corallo
e48f8e3f33
Merge pull request #729 from casey/readme
Add content to readme
2020-10-02 09:02:15 -07:00
Matt Corallo
1c118ed371 Fix capitalization Gleb suggested 2020-10-02 11:16:22 -04:00
Casey Rodarmor
dbda949b69
Clarify that lightning-net-tokio does networking only 2020-10-01 20:55:31 -07:00
Casey Rodarmor
7c07ca0056
Reword first paragraph and add tagline 2020-10-01 20:28:41 -07:00
Casey Rodarmor
0393b00478
Add content to readme
- Change header to "Rust-Lightning"
- Add crate and documentation badges
- Add introductory paragraph
- Move previous intro content under "Status" heading
2020-10-01 19:36:17 -07:00
Matt Corallo
8fb4a3ddc2
Merge pull request #649 from jkczyz/2020-06-refactor-chain-listener
Refactor chain monitoring
2020-10-01 11:10:13 -07:00
Jeffrey Czyz
6cd6816cd7
Merge branch '2020-06-refactor-chain-listener-move-chainmonitor' into 2020-06-refactor-chain-listener 2020-10-01 09:35:05 -07:00
Jeffrey Czyz
51a5a1a50f
Move ln/channelmonitor.rs to chain/chainmonitor.rs 2020-10-01 08:50:15 -07:00
Jeffrey Czyz
819a8653af
Move channelmonitor.rs from ln to chain module
Given the chain::Watch interface is defined in terms of ChannelMonitor
and ChannelMonitorUpdateErr, move channelmonitor.rs from the ln module
to the chain module.
2020-09-30 22:41:52 -07:00
Jeffrey Czyz
e09767ba2d
Merge ChainMonitor impl blocks 2020-09-30 22:41:52 -07:00
Jeffrey Czyz
8b1e5afddd
Define type alias for enumerated transaction data
Transaction data from a block may be filtered before it is passed to
block_connected functions, which may need the index of each transaction
within the block. Rather than define each function in terms of a slice
of tuples, define a type alias for the slice where it can be documented.
2020-09-30 22:41:52 -07:00
Jeffrey Czyz
71230c995c
Replace WatchEvent usage with get_outputs_to_watch
Outputs to watch are tracked by ChannelMonitor as of
73dce207dd. Instead of determining new
outputs to watch independently using ChainWatchedUtil, do so by
comparing against outputs already tracked. Thus, ChainWatchedUtil and
WatchEvent are no longer needed.
2020-09-30 22:41:23 -07:00
Jeffrey Czyz
9e14256b71
Include funding TXO in outputs to watch
The funding TXO was never added to ChannelMonitor's outputs_to_watch in
73dce207dd. Include it when constructing a
ChannelMonitor.
2020-09-30 22:41:23 -07:00
Jeffrey Czyz
95b7eee0e9
Fix architecture diagram arrow directions
Arrows should signify "calls" or "generates" unless noted.
2020-09-30 22:41:23 -07:00
Jeffrey Czyz
e83dcda03a
Fix architecture diagram line length 2020-09-30 22:41:23 -07:00
Jeffrey Czyz
98bc46beb9
Replace WatchEventProvider with chain::Filter
WatchEventProvider served as a means for replacing ChainWatchInterface.
However, it requires users to explicitly fetch WatchEvents, even if not
interested in them. Replace WatchEventProvider by chain::Filter, which
is an optional member of ChainMonitor. If set, interesting transactions
and output spends are registered such that blocks containing them can be
retrieved from a chain source in an efficient manner.

This is useful when the chain source is not a full node. For Electrum,
it allows for pre-filtered blocks. For BIP157/158, it serves as a means
to match against compact filters.
2020-09-30 22:40:33 -07:00
Jeffrey Czyz
1599a13643
Remove ChainListener
BlockNotifier was removed in the previous commit, thus ChainListener is
no longer needed. Instead, anything needing chain events should be
notified directly.
2020-09-30 22:40:12 -07:00
Jeffrey Czyz
367834ca90
Remove BlockNotifier
BlockNotifier is a convenience for handing blocks to listeners. However,
it requires that each listener conforms to the ChainListener interface.
Additionally, there are only two listeners, ChannelManager and
ChainMonitor, the latter of which may not be used when monitoring
channels remotely. Remove BlockNotifier since it doesn't provide much
value and constrains each listener to a specific interface.
2020-09-30 22:39:56 -07:00
Jeffrey Czyz
851283d9e5
Remove Key parameter from ChainMonitor
ChainMonitor's template Key parameter was meant to allow supporting
both local monitoring, where Key=OutPoint, and watchtowers, where Key=
(PublicKey, u32). Use OutPoint directly since the watchtower case will
not be supported this way.
2020-09-30 22:39:55 -07:00
Jeffrey Czyz
6662e959c8
Rename SimpleManyChannelMonitor to ChainMonitor
ManyChannelMonitor was renamed chain::Watch in the previous commit. Use
a more concise name for an implementation that monitors the chain for
channel activity. Future work will parameterize the struct to allow for
different varieties of persistence. Thus, users usually will be able to
use ChainMonitor directly rather than implementing a chain::Watch that
wraps it.
2020-09-30 22:39:55 -07:00
Jeffrey Czyz
801b775a7d
Replace ManyChannelMonitor with chain::Watch
Rename ManyChannelMonitor to chain::Watch and move to chain/mod.rs,
where chain-related interfaces live. Update the documentation for
clarity and to conform to rustdoc formatting.
2020-09-30 22:39:39 -07:00
Jeffrey Czyz
bc4f4631cc
Remove ChainWatchInterface
The remaining use of ChainWatchInterface was replaced by chain::Access
in the previous commit, and thus it is no longer needed.
2020-09-30 22:39:38 -07:00
Jeffrey Czyz
3ee6a27bc6
Replace ChainWatchInterface in NetGraphMsgHandler
ChainWatchInterface was intended as an interface for watching rather
than accessing the chain. Remove get_chain_utxo and add chain::Access
trait for this behavior. Wrap it with an Option in NetGraphMsgHandler in
order to simplify the error interface.
2020-09-30 22:39:38 -07:00
Jeffrey Czyz
87398be293
Remove ChainWatchInterface from channelmonitor.rs
Use of ChainWatchInterface was replaced with WatchEvent in the previous
commit. Remove it from the parameterization of SimpleManyChannelMonitor
since it is no longer needed.
2020-09-30 22:39:12 -07:00
Jeffrey Czyz
bd39b20f64
Replace use of ChainWatchInterface with WatchEvent
SimpleManyChannelMonitor is parameterized by ChainWatchInterface to
signal what transactions and outputs to watch for on chain. The
interface has grown to cover chain access (via get_chain_utxo) and block
block filtering (via filter_block and reentered), which has added
complexity for implementations and user (see ChainWatchInterfaceUtil).

Pull the watch functionality out as a first step to eliminating
ChainWatchInterface entirely.
2020-09-24 11:56:29 -07:00
Jeffrey Czyz
1ab0a1acc1
Add test utilities for {dis}connecting a block
Replace direct uses of BlockNotifier in functional tests with utility
functions. This is in preparation for signaling watch events back via a
refactoring of ManyChannelMonitor and ChainWatchInterface. Those events
will be processed by connect_block.
2020-09-24 11:04:35 -07:00
Jeffrey Czyz
5381c23d72
Replace BlockNotifier with Node in test utilities
Change confirm_transaction and connect_blocks to take a Node instead of
a BlockNotifier. This is in preparation for signaling watch events back
via a refactoring of ManyChannelMonitor and ChainWatchInterface.
2020-09-24 10:45:37 -07:00
Jeffrey Czyz
82b608d5f3
Simplify BlockNotifier tests
Use a simple ChainListner implementation rather than large test objects
for testing BlockNotifier.

Remove unregister_single_listener_ref_test since it is redundant with
unregister_single_listener_test.

Remove unnecessary clone() calls.
2020-09-24 10:29:34 -07:00
Jeffrey Czyz
f69d9d7f30
Align ChannelMonitor interface with ChainListener
ChannelMonitor has block_connected and block_disconnected methods called
by <SimpleManyChannelMonitor as ChainListener>. Use similar parameters
in ChannelMonitor such that transformations are not needed and the
interface is more closely aligned with ChainListener.
2020-09-24 10:22:06 -07:00
Jeffrey Czyz
a7b2eb6d98
Remove ChainWatchInterface from BlockNotifier
ChainListeners should be independent of each other, but in practice this
is not the case because ChainWatchInterface introduces a dependency
between them. Push ChainWatchInterface down into the ChainListener
implementations where needed. Update ChainListener's block_connected
method to take a slice of the form &[(usize, &Transaction)] where each
transaction is paired with its position within the block.
2020-09-24 10:21:54 -07:00