Commit graph

1476 commits

Author SHA1 Message Date
Matt Corallo
082b72065e
Merge pull request #547 from valentinewallace/add-PR539-test
Verify commitment point on ChannelReestablish (no updates case).
2020-03-19 02:52:40 +00:00
Valentine Wallace
f2b7ccaa86
Verify commitment point on ChannelReestablish (no updates case).
Adds a test for PR #537.
2020-03-18 17:56:54 -04:00
Matt Corallo
33b7c906f2
Merge pull request #537 from TheBlueMatt/2020-03-data-loss-spec-550
Update pre-HTLC DataLossProtect to match new spec changes
2020-03-17 18:49:06 +00:00
Matt Corallo
feb0a9fbcc
Merge pull request #546 from TheBlueMatt/2020-03-519-nits
Watch revoked HTLC-Success/Timeout outputs
2020-03-17 18:47:48 +00:00
Antoine Riard
2d2f658f71 Add more logs in OnchainTxHandler 2020-03-17 14:09:21 -04:00
Antoine Riard
3cba654e32 Watch outputs of revoked HTLC-transactions
Bumping of justice txn on revoked HTLC-Success/HTLC-timeout is triggered
until our claim is confirmed onchain with at least
ANTI_REORG_DELAY_SAFE. Before this patch, we weren't tracking them in
check_spend_remote_htlc, leading us to infinite bumps.

Fix #411

Small fixes by Matt Corallo <git@bluematt.me>
2020-03-17 14:09:21 -04:00
Antoine Riard
0d45ddc9e2 Fix duplicata of adjusted justice tx generation in OnchainTxHandler
Adjusted tx occurs when a previous aggregated claim tx has
seen one of its outpoint being partially claimed by a remote tx.
To pursue claiming of the remaining outpoint a adjusted claim tx
is generated  with leftover of claimable outpoints.

Previously, in case of block-rescan where a partial claim occurs,
we would generate duplicated adjusted tx, wrongly inflating feerate
for next bumps. At rescan, if input has already been dropped from
outpoints map from a claiming request, don't regenerate again
a adjuste tx.
2020-03-17 14:09:21 -04:00
Matt Corallo
c8236b2811
Merge pull request #545 from TheBlueMatt/2020-03-fuzz-0-fee
Don't return a feerate of 0 in full_stack_target fuzz on EOF
2020-03-17 18:01:06 +00:00
Matt Corallo
f2e91519d3
Merge pull request #544 from TheBlueMatt/2020-03-fix-mon-ser
Fix ChannelMonitor round-trip introduced by 3d640da5c3
2020-03-17 17:59:22 +00:00
Matt Corallo
8a03830d43 Don't return a feerate of 0 in full_stack_target fuzz on EOF
This triggered a (legitimate) panic in OnChainTxHandler that the
feerate in use was non-0, which is required by the feerate API.
2020-03-16 22:09:08 -04:00
Matt Corallo
6fe8c121a7 Fix ChannelMonitor round-trip introduced by 3d640da5c3
3d640da5c3 changed the indexes for
some enums in ChannelMonitor deserialization but not serialization.
Thus, the chanmon_deser_target fuzz target failed on travis on at
least one PR.
2020-03-16 20:02:48 -04:00
Matt Corallo
4c33197af8
Merge pull request #543 from TheBlueMatt/2020-03-513-warning
Add missing unwrap() in tests introduced in 4abfd515e5
2020-03-16 20:23:37 +00:00
Matt Corallo
cd3748cd9d Add missing unwrap() in tests introduced in 4abfd515e5 2020-03-11 16:10:01 -04:00
Matt Corallo
d6b1825186
Merge pull request #513 from ariard/2020-02-fix-zero-msat-htlc
BOLT2: Check we don't send and accept 0-msat HTLC
2020-03-11 19:57:38 +00:00
Antoine Riard
dd9c476a58 Add test_override_0msat_htlc_minimum 2020-03-11 14:28:22 -04:00
Antoine Riard
9e03d2bc7a Make htlc_minimum_msat configurable
Enforce a minimum htlc_minimum_msat of 1.

Instead of computing dynamically htlc_minimum_msat based on feerate,
relies on user-provided configuration value. This let user compute
an economical-driven channel parameter according to network dynamics.
2020-03-11 14:28:20 -04:00
Matt Corallo
d27e9e1c6a
Merge pull request #472 from TheBlueMatt/2020-01-net-async-await
Rewrite lightning-net-tokio using async/await and tokio 0.2
2020-03-11 17:41:57 +00:00
Matt Corallo
eee94672be
Merge pull request #541 from valentinewallace/fix-node-features
Fix node `with_relevant_init_flags`
2020-03-11 17:32:33 +00:00
Valentine Wallace
40a1aef322
Add test cases for feature messages from other lightning clients. 2020-03-11 12:55:00 -04:00
Valentine Wallace
658b681772
Fix blanking out non-node-context feature flags when pulling features from init context.
Fixes bug introduced in 912f877
2020-03-11 12:54:14 -04:00
Matt Corallo
174ccf5abe Fix typo in lightning-net-tokio crate description. 2020-03-11 12:19:39 -04:00
Matt Corallo
06d3b20512 Fix (and test) net-tokio outbound conns without a threaded env 2020-03-11 12:19:39 -04:00
Matt Corallo
60d37b2698 Fix long-standing race in net-tokio reading after a disconnect event
If rust-lightning tells us to disconnect a socket after we read
some bytes from the socket, but before we actually give those bytes
to rust-lightning, we may end up calling rust-lightning with a
Descriptor that isn't registered anymore.

Sadly, there really isn't a good way to solve this, and it should
be a pretty quick event, so we just busy-wait.
2020-03-11 12:19:39 -04:00
Matt Corallo
5ada940464 Rewrite lightning-net-tokio using async/await and tokio 0.2
This is a rather major rewrite, using async/await and tokio 0.2,
which cleans up the code a ton as well as adds significantly to
readability.
2020-03-11 12:19:39 -04:00
Antoine Riard
4abfd515e5 Add test_update_add_htlc_bolt2_receiver_zero_value_msat 2020-03-10 13:05:30 -04:00
Antoine Riard
d1c6f235f9 BOLT2: Check we don't send and accept 0-msat HTLC
Failing this requirement at sending means a strict receiver would
fail our channel while processing a HTLC routed from a third-party.

Fix by enforcing check on both sender and receiver side.
2020-03-10 13:05:30 -04:00
Matt Corallo
6f06858304 Swap read_event read type for a slice isntead of a Vec
It looks like we don't currently use the Vec as a Vec, and can
happily take a slice, which makes things easier on the calling
side.
2020-03-10 11:52:12 -04:00
Matt Corallo
83c9eb4b9e
Merge pull request #435 from TheBlueMatt/2020-01-node_announce
Add ability to broadcast our own node_announcement
2020-03-09 00:13:47 +00:00
Matt Corallo
4f06d7a83c Update pre-HTLC DataLossProtect to match new spec changes
This was the way DataLossProtect was originally written, however it
didn't match other implementations at the time during testing. It
turns out, other implementations didn't agree with each other
anyway (depending on the exact timeline), so the spec was clarified
somewhat in https://github.com/lightningnetwork/lightning-rfc/pull/550
. This updates us to be in line with the new guidance and appears
to solve out-of-sync issues in testing.
2020-03-05 21:16:47 -05:00
Matt Corallo
78c48f76d4 Use block timestamps as the min for generated update messages.
Fixes issue #493 and should resolve some issues where other nodes
(incorrectly) reject channel_update/node_announcement messages
which have a serial number that is not a relatively recent
timestamp.
2020-03-05 20:59:43 -05:00
Matt Corallo
c2ca6d3cdc Further document the initial routing table send.
As requested by Arik at https://github.com/rust-bitcoin/rust-lightning/pull/435#discussion_r378093821
2020-03-05 20:59:43 -05:00
Matt Corallo
a8114a70cb Add ability to broadcast our own node_announcement.
This is a somewhat-obvious oversight in the capabilities of
rust-lightning, though not a particularly interesting one until we
start relying on node_features (eg for variable-length-onions and
Base AMP).

Sadly its not fully automated as we don't really want to store the
list of available addresses from the user. However, with a simple
call to ChannelManager::broadcast_node_announcement and a sensible
peer_handler, the announcement is made.
2020-03-05 20:59:43 -05:00
Matt Corallo
107da97cd0 Allow more than one address per type in node_announcement messages
lnd has been blatantly ignoring this line in the spec forever, so
its somewhat of a lost cause trying to enforce it.
2020-03-05 18:42:49 -05:00
Matt Corallo
fd08529d59 Allow node_announcement timestamps of 0 in accordance with BOLT 7
Unlike channel_update messages, node_announcement messages have no
requirement that the timestamp is greater than 0.
2020-03-05 18:30:50 -05:00
Matt Corallo
d850e1234a
Merge pull request #535 from TheBlueMatt/2020-03-462-nits
A few minor nits on #462
2020-03-05 16:19:14 +00:00
Matt Corallo
6abce8165e Take multiple spent-txn to check_spends! in functional_tests
This reintroduces a check_spends!() removed in 3d640da5c3
due to check_spends not being able to check a transaction which
spends multiple other transactions.

It also simplifies a few calls in claim_htlc_outputs_single_tx by
using check_spends!().
2020-03-04 21:06:58 -05:00
Matt Corallo
f554c59463 Drop redundant .clone() in check_spends calls.
The API to rust-bitcoin to check a transaction correctly spends
another changed some time ago, but we still have a lot of needless
.clone()s in our tests.
2020-03-04 21:06:57 -05:00
Matt Corallo
9de9288100 Correct comment in onchaintx.rs
This comment was stale and referred to a previous implementation
of #462, which changed before it was merged.
2020-03-04 21:06:57 -05:00
Matt Corallo
4c3533d017 Flatten Vec passed from channelmonitor to onchaintx block_connected
Instead of passing a Vec of Vecs drop them into one as we go in
ChannelMonitor, hopefully avoiding a bit of memory fragmentation
and improving readability.
2020-03-04 17:57:22 -05:00
Matt Corallo
48549de955
Merge pull request #462 from ariard/2020-01-refactor-chan
Introduce OnchainTxHandler, move bumping and tracking logic
2020-03-04 22:23:28 +00:00
Antoine Riard
a4a5e01437 Rename InputMaterial script to witness_script 2020-03-04 16:06:31 -05:00
Antoine Riard
e8cb076267 Comment better get_height_timer logic.
Height timer as an important component of a more-secure, fee-sensitive
claiming of time-constrained LN outputs, therefore document assumptions.
2020-03-04 16:06:31 -05:00
Antoine Riard
d86423c366 Remove TestBroadcaster temporary dedup buffer 2020-03-04 16:06:31 -05:00
Antoine Riard
14335358d0 Structurify claim request handed between detection/reaction 2020-03-04 16:06:31 -05:00
Antoine Riard
3d640da5c3 Introduce OnchainTxHandler, move bumping and tracking logic
Encapsulates tracking and bumping of in-flight transactions in
its own component. This component may be latter abstracted
to reuse tracking and RBF for new features (e.g dual-funding,
splicing)

Build all transactions generation in one place. Also as fees
and signatures are closely tied, what keys do you have determine
what bumping mode you can use.
2020-03-04 16:06:29 -05:00
Matt Corallo
e94635703a
Merge pull request #523 from TheBlueMatt/2020-02-router-ser-fix
Fix Router Serialization Roundtrip
2020-03-04 20:37:58 +00:00
Matt Corallo
5f3986d047 Test Router serialization round-trip in functional_tests.
This tests Router serialization round-trip at the end of each
functional test in the same way we do ChannelMonitors and
ChannelManagers to catch any cases where we were able to get into
a state which would have prevented reading a Router back off disk.

We further walk all of the announcements which both the original
and deserialized Routers would send to peers requesting initial
sync to ensure they match.
2020-03-04 14:29:06 -05:00
Matt Corallo
b80d3d9d29 Change Option<T> serialization format to include length
This is a cheap way to fix an error in Router serialization
roundtrip due to us calling read_to_end during the read of
channel/node announcement/updates. During normal message reading,
we only have limited bytes to read (specifically the message buffer)
so this is fine, however when we read them inside Router, we have
more data from other fields of the Router available as well. Thus,
we end up reading the entire rest of the Router into one message
field, and failing to deserialize.

Because such fields are always stored in Option<>s, we can simply
use a LengthLimitingStream in the Option<> serialization format and
make only the correct number of bytes available.

By using a variable-length integer for the new field, we avoid
wasting space compared to the existing serialization format.
2020-03-04 14:29:06 -05:00
Matt Corallo
32ca8ec13e Make Readable::read a templated on the stream, not Readable itself
This makes Readable symmetric with Writeable and makes sense -
something which is Readable should be Readable for any stream which
implements std::io::Read, not only for a stream type it decides on.

This solves some lifetime-compatibility issues in trying to read()
from a LengthLimitingReader in arbitrary Readable impls.
2020-03-04 14:29:06 -05:00
Matt Corallo
39b62335b7 Impl ReadableArgs for Arc<ChannelManager>, not just ChannelManager.
This provides a simple wrapper for deserializing right into an
Arc<ChannelManager>, which improves UX a tiny bit when working with
SimpleArcChannelManager types.
2020-03-04 14:29:06 -05:00