Commit graph

2031 commits

Author SHA1 Message Date
bmancini55
deffb4a3d8 Clean up iteration in handle_query_channel_range
Refactor to use an enumerator in NetGraphMsgHandler::handle_query_channel_range
2021-03-09 16:30:52 -05:00
bmancini55
dd0bb25694 Use scid_from_parts in Channel::block_connected
Refactors validation and short_channel_id construction to use
the new scid_from_parts function.
2021-03-09 15:42:45 -05:00
bmancini55
d5fd8d96e1 Improve short_channel_id utils
Modifies scid_from_parts to use u64 inputs allowing untruncated
validation. Adds public constants for limits.
2021-03-09 15:34:52 -05: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
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
4894d52d30 Merge pull request #646 from naumenkogs/2020-06-router-mpp
MPP on the router side
2021-03-02 20:33:08 -05:00
Matt Corallo
793de5fe69
Merge pull request #819 from TheBlueMatt/2021-03-810-rebased
Change ChannelManager deserialization to return an optional blockhash
2021-03-02 16:04:23 -08:00
Matt Corallo
03a5189651
Merge pull request #818 from jkczyz/2021-03-validate-best-block-header
Add validate_best_block_header utility
2021-03-02 16:03:42 -08:00
Matt Corallo
7caadd446b
Merge pull request #816 from valentinewallace/remove-simple-outer-arcs
Remove simple outer arcs
2021-03-02 16:02:44 -08:00
Gleb Naumenko
e0600e5b1e 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.
2021-03-02 21:40:08 +02:00
Matt Corallo
8550bd43d3 Update docs to use the new deserialization requirements 2021-03-02 14:30:56 -05:00
Valentine Wallace
7c8e740b6e Change ChannelMonitor deserialization to return an optional blockhash.
See previous commit msg for details.
2021-03-02 14:30:56 -05:00
Valentine Wallace
ee995a3a55 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.
2021-03-02 14:30:56 -05:00
Gleb Naumenko
18c7730040 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.
2021-03-02 21:19:58 +02:00
Gleb Naumenko
ef12ceb8dd Use outbound_capacity_msat from first_hops for routing 2021-03-02 21:09:50 +02:00
Gleb Naumenko
db4721f3a7 Implement finding paths for MPP 2021-03-02 21:09:49 +02:00
Jeffrey Czyz
60f4daf2c2
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.
2021-03-02 10:03:11 -08:00
Matt Corallo
81c6bdc953
Merge pull request #814 from TheBlueMatt/2021-03-optional-handlers
Provide Dummy routing and channel message handlers for users
2021-03-02 07:00:46 -08:00
Matt Corallo
e241ca4339
Merge pull request #813 from jkczyz/2021-02-channel-monitor-mutex
Use interior mutability in ChannelMonitor
2021-03-02 07:00:20 -08:00
Jeffrey Czyz
e8ea0d9f04
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.
2021-03-01 22:12:26 -08:00
Jeffrey Czyz
389c4ad6fa
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.
2021-03-01 22:12:26 -08:00
Jeffrey Czyz
8e558feb4b
Use consistent variable naming in ChainMonitor 2021-03-01 22:12:26 -08:00
Jeffrey Czyz
b0978a86be
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.
2021-03-01 22:12:26 -08:00
Matt Corallo
d95f14568b Add utility constructors to PeerHandler to use a dummy handler 2021-03-01 20:23:54 -05:00
Matt Corallo
825a238a2c 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.
2021-03-01 20:23:54 -05:00
Matt Corallo
59d2040c74
Merge pull request #811 from TheBlueMatt/2021-02-bindings-rust-bump
Update bindings for new Listen interface
2021-03-01 15:35:35 -08:00
Matt Corallo
ee9ceb42b1 Add simple README about our C bindings generation stuff 2021-03-01 18:07:29 -05:00
Matt Corallo
f2e4f8a229 [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
2021-03-01 18:07:29 -05:00
Matt Corallo
808db58578 Update auto-generated bindings 2021-02-28 19:44:45 -05:00
Matt Corallo
6dd9c2e97c [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.
2021-02-28 19:44:45 -05:00
Matt Corallo
c21b866c60 Fix doc typo introduced in the ChannelKeys->Sign renaming 2021-02-28 19:44:45 -05:00
Matt Corallo
cd0b212e4d [bindings] Use global context for secp256k1
Note that this uses https://github.com/rust-bitcoin/rust-secp256k1/pull/279
2021-02-28 19:44:45 -05:00
Matt Corallo
9fba7c92ad
Merge pull request #802 from TheBlueMatt/2021-01-update-rust-bitcoin
Update rust-bitcoin and add secp256k1 context randomization
2021-02-28 16:43:08 -08:00
Matt Corallo
beb88e69a9
Merge pull request #806 from valentinewallace/monitor-data-persistence-path
persist: Persist ChannelMonitors in their own directory.
2021-02-27 16:34:54 -08:00
Matt Corallo
ea48a5a089 Rebuild full_stack_target test vector for new secp256k1 fuzz req 2021-02-26 23:47:03 -05:00
Matt Corallo
c5c0abb88d Log full signed remote commitment transaction hex in channel
This is useful when rebuilding the full_stack_target test vector
2021-02-26 23:47:03 -05:00
Matt Corallo
1521633ca2 Randomize secp contexts for marginally better sidechannel resistance 2021-02-26 23:47:03 -05:00
Matt Corallo
33da665647 Use lowmemory mode for secp256k1 fuzzing, reducing memcpy time 2021-02-26 23:47:03 -05:00
Matt Corallo
4594f6eee5 Use rust-secp256k1 PR 282 and bitcoin_hashes PR 111 in fuzzing 2021-02-26 23:47:03 -05:00
Valentine Wallace
a2d9fca9d5
SimpleArcPeerManager type: remove outer Arc for flexibility 2021-02-26 17:58:56 -05:00
Valentine Wallace
eecc3b7223
SimpleArcChannelManager type: remove outer Arc for flexibility 2021-02-26 17:56:53 -05:00
Matt Corallo
9b7609a8c5 Apply --cfg=fuzzing when fuzzing, as required by new secp256k1
Note that rust-fuzz wrappers (including honggfuzz) already apply
this for us.
2021-02-26 15:15:18 -05:00
Matt Corallo
a51d5cef58 Update rust-bitcoin 2021-02-26 15:15:18 -05:00
Valentine Wallace
bfaec717ae
persist: Persist ChannelMonitors in their own directory. 2021-02-26 12:38:47 -05:00
Matt Corallo
e77b16049b
Merge pull request #791 from jkczyz/2021-01-spv-client
SPV client utility for syncing a lightning node
2021-02-26 07:54:01 -08:00
Jeffrey Czyz
8bfdfdc9e4
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).
2021-02-26 00:54:43 -06:00
Jeffrey Czyz
8505382b19
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.
2021-02-26 00:54:42 -06:00
Jeffrey Czyz
b1ecfe705d
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.
2021-02-26 00:54:42 -06:00