Commit Graph

11978 Commits

Author SHA1 Message Date
Harsha Goli
e4891a98fd
invoicesrpc: expose selectHopHints
selectHopHints is the function which constructs hophints otherwise found
in an invoice created with the private flag.

In this commit, we expose that functionality a little more to workaround
needing to create an invoice to retrieve routing hints. Of course, this
is not a perfect solution as the functionality is exposed exclusively to
go users.
2021-09-06 15:39:53 -07:00
Oliver Gugger
f901d450a5
Merge pull request #5692 from guggero/migration-guide-arm
docs: update safety warning in migration guide [skip ci]
2021-09-06 11:57:26 +02:00
Oliver Gugger
8d7f5314a8
docs: update safety warning in migration guide [skip ci]
Fixes #5691.
With this commit we update the safety guidelines for migrating lnd data
between 32bit ARM and 64bit ARM devices.
2021-09-06 11:00:36 +02:00
Oliver Gugger
e76c4c0e9b
Merge pull request #5356 from guggero/batch-channel-open
Atomic batch channel funding
2021-09-03 19:56:56 +02:00
Oliver Gugger
180fba056f
docs: add BatchOpenChannel to PSBT doc and release notes 2021-09-03 18:39:45 +02:00
Oliver Gugger
7a9ee48cf1
itest: add batch funding test 2021-09-03 18:39:45 +02:00
Oliver Gugger
bb079f746b
lncli: add batchopenchannel command 2021-09-03 18:39:44 +02:00
Andras Banki-Horvath
c5c956bbef
lnrpc: add BatchOpenChannel RPC 2021-09-02 12:13:47 +02:00
Oliver Gugger
37d0d651c4
rpcserver: extract abandonChan method
We'll want to re-use the abandon channel functionality for the batch
funding, as a cleanup in case the funding is aborted before publishing
any transaction.
2021-09-02 12:13:46 +02:00
Oliver Gugger
ae2e9541a4
walletrpc: export wallet kit sub server name
We'll want to re-use the PSBT funding functionality from the wallet kit
sub server in the main RPC server. To be able to dynamically obtain an
instance of the wallet kit server we need to know its name under which
it registers itself in the list of sub server. We export the name so we
don't have to hard code it in the main server.
2021-09-02 12:13:46 +02:00
Oliver Gugger
84035f1fb2
funding: add batch funding function 2021-09-02 12:13:42 +02:00
Oliver Gugger
7c41d4b349
lnrpc: add batch channel open RPC types 2021-09-02 12:11:10 +02:00
Olaoluwa Osuntokun
d263a01a2d
Merge pull request #5669 from Roasbeef/explicit-chan-type
lnwire+funding: introduce new protocol extension for explicit commitment type negotiation
2021-08-31 19:28:59 -07:00
Olaoluwa Osuntokun
26169e8e16
Merge pull request #5627 from Zero-1729/patch-3
trivial: minor grammar and typo fix [skip ci]
2021-08-30 19:23:43 -07:00
Wilmer Paulino
61a0112765
docs: add explicit channel negotiation text to release notes 2021-08-30 19:17:51 -07:00
Wilmer Paulino
3299af7919
lncli: add channel type flag to openchannel command 2021-08-30 19:17:45 -07:00
Wilmer Paulino
523eef5cf4
lntest: use explicit channel commitment negotiation for multi-hop itests 2021-08-30 19:17:42 -07:00
Wilmer Paulino
449f207217
lntest: replace commitType type with rpc alternative 2021-08-30 19:17:39 -07:00
Olaoluwa Osuntokun
ad758d8499
funding: use explicit commitment type negotiation when possible
In this commit, we modify the existing logic that defaults to implicit
commitment type negotiation to support explicit negotiation if the new
feature bit is set. This change allows us to ditch the notion of a
"default" commitment type, as we'll now use feature bits to signal our
understanding of a commiment type, but allow peers to select which
commitment type they actually wish to use.

In addition, this explicit negotiation removes the need for using the
required bit of any commitment types. Instead, if an implementation
wishes to no longer support a commitment type, they should simply stop
advertising the optional bit.
2021-08-30 19:17:37 -07:00
Wilmer Paulino
e7885f2bde
funding: add explicit commitment type negotiation support
This commit adds the ability for a channel initiator/responder to
determine whether the channel to be opened can use a specific commitment
type through explicit negotiation. It also includes the existing
implicit negotiation logic to fall back on if explicit negotiation is
not supported.
2021-08-30 19:17:34 -07:00
Wilmer Paulino
031d7b1d55
lnwire: extend RawFeatureVector with helper methods 2021-08-30 19:17:31 -07:00
Olaoluwa Osuntokun
5a9f499dd5
rpc: add new commitment_type field to OpenChannelRequest
This field will be examined later down the stack along with the set of
feature bits to determine if explicit channel commitment type
negotiation is possible or not.
2021-08-30 19:17:28 -07:00
Olaoluwa Osuntokun
d0779e2ec2
lnwire: add new feature bits for explicit channel type negotiation
If these bits are present, then both sides can examine the new
CommitmentType TLV field that's present and use this in place of the
existing implicit commiment type negotiation. With this change, it's now
possible to actually deprecate old unsupported commitment types
properly.
2021-08-30 19:17:24 -07:00
Olaoluwa Osuntokun
57b7a668c0
lnwire: add new ChannelType field as TLV record to Open/AcceptChannel
In this commit, we add a new ChannelType field as a new TLV record to
the OpenChannel message. During this change, we make a few tweaks to the
generic TLV encode/decode methods for the ExtraOpaqueData struct to have
it work on the level of tlv.RecordProducer instead of tlv.Record, as
this reduces line noise a bit.

We also partially undo existing logic that would attempt to "prepend"
any new TLV records to the end of the ExtraOpaqueData if one was already
present within the struct. This is based on the assumption that if we've
read a message from disk to order to re-send/transmit it, then the
ExtraOpaqueData is fully populated so we'll write that as is. Otherwise,
a message is being encoded for the first time, and we expect all fields
that are known TLV fields to be specified within the struct itself.

This change required the unit tests to be modified slightly, as we'll
always encode a fresh set of TLV records if none was already specified
within the struct.
2021-08-30 19:17:21 -07:00
Olaoluwa Osuntokun
988d01de0d
lnwire: introduce new explicit ChannelType TLV record
In this commit, we add a new TLV record that's intended to be used as an
explicit channel commitment type for a new form of funding negotiation,
and later on a dynamic commitment upgrade protocol. As defined, we have
3 channel types: base (the OG), tweakless, and anchors w/ zero fee
HTLCs. We omit the original variant of anchors as it was never truly
deployed from the PoV of lnd.
2021-08-30 19:17:19 -07:00
Olaoluwa Osuntokun
3b026c401c
chainntnfs/neutrinonotify: fix rebase Conflict compilation issue 2021-08-30 19:16:33 -07:00
Olaoluwa Osuntokun
844874252f
Merge pull request #5676 from ErikEk/chainnotifier-remove-error-log
chainnotifier: remove error logs
2021-08-30 18:35:12 -07:00
Olaoluwa Osuntokun
480a111c54
Merge pull request #5453 from Crypt-iQ/neutrino_conf_0629
chainntnfs: neutrinonotify patches
2021-08-30 16:04:57 -07:00
Olaoluwa Osuntokun
b9231ced2b
Merge pull request #5622 from Roasbeef/wire-serdes-optimization
peer+brontide: when decrypting re-use the allocated ciphertext buf & ensure buf pool buf doesn't escape
2021-08-30 11:45:57 -07:00
Olaoluwa Osuntokun
8339b285e7
docs/release-notes: add new brontide optimization to 0.14 notes 2021-08-27 16:57:21 -07:00
Olaoluwa Osuntokun
3e1558b616
peer: re-use buf from bufpool when decoding messages
In this commit, which builds on top of the prior commit, rather than
using the returned buffer outside of the closure (which means it'll be
copied), we instead use it within the `Submit` closure instead. With the
recent changes to the `brontide` package, we won't allocate any new
buffer when we decrypt, as a result, the `rawMsg` byte slice actually
just slices into the passed `buf` slice (obtained from the pool)`.

With this change, we ensure that the buffer pool can release the slice
back to the pool and eliminate any extra allocations along the way.
2021-08-27 16:57:15 -07:00
Olaoluwa Osuntokun
8c6dbc9ffa
brontide: when decrypting re-use the allocated ciphertext buf
In this commit, we implement a simple optimization that dramatically
reduces the number of allocations we need to make when we decrypt a new
message. Before this commit, we would pass in a `nil` value to the
`Decrypt` method which meant that it would always allocate a new
buffers.

Rather than force this behavior, in this commit, we pass in the
ciphertext buffer (with a length of zero), such that the decryption
operation will simply copy the plaintext bytes over the cipher text in
place. This works as the cipher text is always larger than the
plaintext, since the plaintext doesn't have a MAC attached.

The amount the perf increase, amount of allocations, and amount of bytes
allocated are pretty nice:
```
benchmark                        old ns/op     new ns/op     delta
BenchmarkReadHeaderAndBody-8     88652         75896         -14.39%

benchmark                        old allocs     new allocs     delta
BenchmarkReadHeaderAndBody-8     6              4              -33.33%

benchmark                        old bytes     new bytes     delta
BenchmarkReadHeaderAndBody-8     65664         128           -99.81%
```

Here old is without this change, and new with it.
2021-08-27 16:57:12 -07:00
Olaoluwa Osuntokun
02509025d5
brontide: add new benchmark to measure allocs for header+body decrypt 2021-08-27 16:57:09 -07:00
Olaoluwa Osuntokun
c93824ec9a
Merge pull request #5621 from Roasbeef/ping-pong-headers
peer: always send latest block header as part of ping messages
2021-08-27 16:55:46 -07:00
Olaoluwa Osuntokun
d9644eba84
Merge pull request #5629 from Roasbeef/priv-key-caching
keychain+lnwallet: when fetching priv keys or signing try to use cache
2021-08-27 16:51:24 -07:00
ErikEk
c68a508535 chainnotifier: remove error log 2021-08-28 00:13:37 +02:00
eugene
9f6f5e963a
docs: update release notes for 0.14 2021-08-27 14:12:02 -04:00
eugene
de71195bcb
chainntnfs/neutrinonotify: update EndHeight after filter update
After the error is received on the filter update errChan, update the
EndHeight if we're performing a historical scan. If a block was mined
after the call to RegisterConf/RegisterSpend but before the filter was
updated, then the block would not have the filter applied. This means
that a block containing the desired conf/spend parameters would be
undetected. Fix this by ensuring the historical scan also includes this
height, as it would previously not be included.
2021-08-27 14:12:02 -04:00
eugene
0d39c0799a
chainntnfs/neutrinonotify: call drainChainUpdates when updating filter
Moves filter handling logic for connecting blocks to the
connectFilteredBlock method. The disconnect logic now lives in
disconnectFilteredBlock. After updating the filter, drainChainUpdates
is called which will drain everything from the chainUpdates chan and
apply all updates by calling either connectFilteredBlock or
disconnectFilteredBlock. This will allow callers to update their
EndHeight if performing a historical dispatch, as blocks up to this
height may not have had the filter applied.
2021-08-27 14:12:01 -04:00
eugene
b7de0eae93
chainntnfs/neutrinonotify: make chainUpdates a buffered chan
ConcurrentQueue has internal structures so if a filterUpdate exists
in it, the idea of draining the queue may not work reliably. The
update may exist in the ConcurrentQueue but may not be available via
ChanOut() when we're ready to drain the ConcurrentQueue. Fix this by
using a regular buffered chan, which will either have the update or
not have the update. Its size is set to 100 as our tests may generate
quite a bit of updates.
2021-08-27 14:12:01 -04:00
eugene
86f28cdc1d
chainntnfs: skip conf dispatch if ntfn already dispatched
This mirrors the logic for the spend case. This prevents a double
dispatch scenario when combined with a later commit. Otherwise, the
confirmation would linger in the buffer which is not ideal.
2021-08-27 14:11:55 -04:00
Olaoluwa Osuntokun
abb2448718
docs/release-notes: add section w/ priv key caching in 0.14 2021-08-25 18:55:27 -07:00
Olaoluwa Osuntokun
d6524ea517
keychain+lnwallet: when fetching priv keys or signing try to use cache
In this commit, we start to optimistically use the new private key cache
that was added to btcwallet. As is, btcwallet will cache the decrypted
account keys for each scope in memory. However, the existing methods
to derive a child key from those account keys requires a write database
transaction, and will re-derive the private key using BIP-32 each time.

The newly added `DeriveFromKeyPathCache` lets us skip all this and
directly use a cache assuming the account info is already cached. The
new logic will try to use this method, but if it fails fall back to the
existing `DeriveFromKeyPath` method. All calls after this will use this
new cached key.

Fixes https://github.com/lightningnetwork/lnd/issues/5125.

Basic benchmark before the btcwallet change and after:
```
benchmark                    old ns/op     new ns/op     delta
BenchmarkDerivePrivKey-8     22840583      125           -100.00%

benchmark                    old allocs     new allocs     delta
BenchmarkDerivePrivKey-8     89             2              -97.75%

benchmark                    old bytes     new bytes     delta
BenchmarkDerivePrivKey-8     10225         24            -99.77%
```
2021-08-25 18:55:22 -07:00
Olaoluwa Osuntokun
2206eba91a
build: point to latest btcwallet w/ new cached privkey method 2021-08-25 18:55:19 -07:00
Olaoluwa Osuntokun
df11b0fed0
keychain: add basic benchmark for privkey derivation 2021-08-25 18:55:16 -07:00
Olaoluwa Osuntokun
8fd14bc458
docs/release-notes: add notes for new ping header in 0.14 2021-08-25 16:47:23 -07:00
Olaoluwa Osuntokun
00d275d9f0
lnrpc+rpc: expose last ping message received by peer over ListPeers resp 2021-08-25 16:47:17 -07:00
Olaoluwa Osuntokun
2947076607
peer: store the last ping payload received by a remote peer in an atomic var 2021-08-25 16:47:13 -07:00
Olaoluwa Osuntokun
4287e25494
peer: add message summaries for ping+pong 2021-08-25 16:47:10 -07:00
Olaoluwa Osuntokun
d566e51a52
peer: always send latest block header as part of ping messages
In this commit, we implement a long discussed mechanism to use the
Lightning Network as a redundant block header source. By sending our
latest block header with each ping message, we give peers another source
(outside of the Bitcoin P2P network) they can use to spot check their
chain state. Peers can also use this information to detect if they've
been eclipsed from the traditional Bitcoin P2P network itself.

As is, we only send this data in Ping messages (which are periodically
sent), in the future we could also move to send them as the partial
payload for our pong messages, and also randomize the payload size
requested as well.
2021-08-25 16:47:07 -07:00