Commit Graph

15455 Commits

Author SHA1 Message Date
yyforyongyu
62d240bba1
itest: add testSendDirectPayment
Adds a new test to check direct payments between two nodes. The fee rate
is tuned to 1 sat/vb to catch edge cases.
2023-09-28 19:42:11 +08:00
Olaoluwa Osuntokun
eae9dd07f0
peer: launch persistent peer pruning in background goroutine
This PR is a follow up, to a [follow
up](https://github.com/lightningnetwork/lnd/pull/7938) of an [initial
concurrency issue](https://github.com/lightningnetwork/lnd/pull/7856)
fixed in the peer goroutine.

In #7938, we noticed that the introduction of `p.startReady` can cause
`Disconnect` to block. This happens as `Disconnect` cannot be called
until `p.startReady` has been closed. `Disconnect` is also called from
`InboundPeerConnected` (the case of concurrent peers, so we need to
remove one of the connections) while the main server mutex is held. If
`p.Start` blocks for any reason, then this leads to the deadlock as: we
can't disconnect until we've finished starting, and we can't finish
starting as we need the disconnect caller to exit as it has the mutex.

In this commit, we now make the call to `prunePersistentPeerConnection`
async. The call to `prunePersistentPeerConnection` eventually wants to
grab the server mutex, which triggers the circular waiting scenario
above.

The main learning here is that no calls to the main server mutex path
can block from `p.Start`. This is more or less a stop gap to resolve the
issue initially introduced in v0.16.4. Assuming we want to move forward
with this fix, we should reexamine `p.startReady` all together, and also
revisit attempt to refactor this section of the code to eliminate the
mega mutex in the server in favor of a dedicated event loop.
2023-09-27 21:24:50 -05:00
Olaoluwa Osuntokun
1ebfe95772
Merge pull request #8035 from Roasbeef/0-17-rc5
build: bump version to v0.17.0 rc5
2023-09-26 18:21:07 -05:00
Olaoluwa Osuntokun
f63a2b9507
build: bump version to v0.17.0 rc5 2023-09-26 16:11:45 -05:00
Olaoluwa Osuntokun
01a05fdea7
Merge pull request #8031 from guggero/chan-acceptor-taproot-chan
chanacceptor+lnrpc: add simple taproot channel support
2023-09-26 16:08:19 -05:00
Oliver Gugger
d16e7a5eef
itest: add itest for externally funded taproot chans 2023-09-26 21:45:17 +02:00
Oliver Gugger
d94ae3f509
lnrpc+rpcserver: add musig2 to ChanPointShim 2023-09-26 21:45:17 +02:00
Oliver Gugger
ebf98c6d51
chanacceptor: add simple taproot channels 2023-09-26 21:45:16 +02:00
Oliver Gugger
3821baa0c8
Merge pull request #8024 from Roasbeef/htlc-resolver-c-queue
contractcourt: modify the incoming contest resolver to use concurrent…
2023-09-26 16:03:10 +00:00
Olaoluwa Osuntokun
abe888f719
contractcourt: modify the incoming contest resolver to use concurrent queue
In this commit, we modify the incoming contest resolver to use a
concurrent queue. This is meant to ensure that the invoice registry
subscription loop never blocks. This change is meant to be minimal and
implements option `5` as outlined here:
https://github.com/lightningnetwork/lnd/issues/8023.

With this change, the inner loop of the subscription dispatch method in
the invoice registry will no longer block, as the concurrent queue uses
a fixed buffer of a queue, then overflows into another queue when that
gets full.

Fixes https://github.com/lightningnetwork/lnd/issues/7917
2023-09-25 18:48:30 -05:00
Michael Rooke
78d9996620
trivial: Fix spelling errors
- Fixes some spelling in code comments and a couple of function names
2023-09-21 22:35:33 -04:00
eugene
8f20cd82fb
funding: add TestFundingManagerCoinbase test
This tests that the funding manager doesn't immediately consider
a coinbase transaction that is also a funding transaction usable
until the maturity has been reached.
2023-09-21 11:33:42 -04:00
eugene
5e6ebf561b
chanfunding: introduce NewShimIntent for testing
This is needed so that the next commit can create a ShimIntent
without having to export the ShimIntent's fields.
2023-09-21 11:33:42 -04:00
eugene
0cf3552515
funding: wait for coinbase maturity before sending channel_ready 2023-09-21 11:33:38 -04:00
Oliver Gugger
a1b0a7eb02
Merge pull request #8021 from petertodd/2023-09-fix-ots-name
Fix capitalization of OpenTimestamps in release notes
2023-09-21 10:56:46 +00:00
Peter Todd
d5b88dde72
Fix capitalization of OpenTimestamps in release notes 2023-09-21 02:10:14 -04:00
Olaoluwa Osuntokun
ec585431a9
Merge pull request #8004 from Roasbeef/0-17-rc4
build: bump version to v0.17.0 rc4
2023-09-18 18:44:29 -07:00
Olaoluwa Osuntokun
8948dfa113
build: bump version to v0.17.0 rc4 2023-09-18 13:58:41 -07:00
Olaoluwa Osuntokun
9f4a8836db
Merge pull request #7981 from ellemouton/handleRogueUpdates
watchtower: handle rogue updates
2023-09-18 13:56:52 -07:00
Olaoluwa Osuntokun
12be6a37a7
Merge branch 'master' into handleRogueUpdates 2023-09-18 13:55:41 -07:00
Olaoluwa Osuntokun
7412482406
Merge pull request #7994 from Roasbeef/remote-signer-musig2-nonces
multi: add ability to specify local nonces for musig2 signer rpc, add itest for remote signer taproot chans
2023-09-18 13:54:14 -07:00
Olaoluwa Osuntokun
2359481226
Merge pull request #7983 from Roasbeef/blocking-and-mutex-profile
lnd+config: add ability to obtain blocking and mutex profiles
2023-09-18 11:45:40 -07:00
Olaoluwa Osuntokun
23a153abae
lnd+config: add ability to obtain blocking and mutex profiles
In this commit, we add the ability to obtain blocking and mutex
profiles. The blocking profile will show which goroutines are
consistently blocked on synchronization primitives like channels, or
I/O. The mutex profile will show which mutexes are very contested.

The blocking profile can be enabled with a new arg: `--blockingprofile`.
The mutex profile can be enabled with a new arg: `--mutexprofile`. These
are both ignored if the profile port isn't set.

Activating these profiles requires the caller to pass in a sampling
rate. For now I've set it just to `1` to test things out. Unfortunately
documentation is rather scarce, so there aren't any good guides re what
these values should be set to. AFAICT, these add more overhead than the
other prowling options, so they shouldn't necessarily be enabled
persistently in production.
2023-09-18 11:44:49 -07:00
Olaoluwa Osuntokun
6c3a55d89c
itest: add remote signer test case for taproot chans
This ensures that taproot chans can be used with the remote signer
configuration.
2023-09-18 11:42:20 -07:00
Olaoluwa Osuntokun
8405590152
lnrpc/signrpc+lnwallet/rpcwallet: expose local nonces over RPC
In this commit, we update the set of protos to accept the local secret
nonces over RPC. This is actually a 97 byte value, as it includes the
two 32 byte nonces, as well as the 33 byte value of the public key of
the signer.

This is needed in order to be able to open taproot channels over the RPC
interface.
2023-09-18 11:42:15 -07:00
Olaoluwa Osuntokun
ce93b236aa
input+lnwallet: modify musig2 interfaces use explicit optional local nonces
In this commit, we modify the musig2 interfaces to instead use an
explicit value for the local nonces. Before this commit, we used the
functional option, but we want to also support specifying this value
over RPC for the remote signer. The functional option pattern is opaque,
so we can't get the nonce value we need. To get around this, we'll just
make this an explicit pointer, then map this to the functional option at
the very last moment.
2023-09-18 11:42:13 -07:00
Olaoluwa Osuntokun
327b0c92bd
Merge pull request #7991 from Roasbeef/ws-bufio-max-msg
lnrpc: increase max message size for ws proxy
2023-09-18 11:33:02 -07:00
Olaoluwa Osuntokun
247c1d8dc8
lnrpc: increase max message size for ws proxy
In this commit, we increase the max message size for the ws proxy. We
have a similar setting for the normal gRPC server which was tuned to be
able to support decoding `GetNetworkInfo` as the channel graph got
larger. We keep the default buffer size of 64 KB, but allow that to be
expanded to up to 4 MB (current value) to decode larger messages.

One alternative would be to modify the `Split` function to break up
larger lines into smaller ones. We'd need to double check that the
libraries at a higher level of abstraction can handle the chunks. The
scan function would look something like:
```go
splitFunc := func(data []byte, eof bool) (int, []byte, error) {
        if len(data) >= chunkSize {
                return chunkSize, data[:chunkSize], nil
        }

        return bufio.ScanLines(data, eof))
}
scanner.Split(splitFunc)
```
2023-09-18 11:32:34 -07:00
Olaoluwa Osuntokun
2d5c0c9b4e
Merge pull request #7985 from Roasbeef/graceful-data-loss-fc
lnwallet+contractcourt: gracefully handle auto force close post data …
2023-09-15 18:30:53 -07:00
Olaoluwa Osuntokun
de54a603b7
lnwallet+contractcourt: gracefully handle auto force close post data loss
In this commit, update the start up logic to gracefully handle a
seemingly rare case. In this case, a peer detects local data loss with a
set of active HTLCs. These HTLCs then eventually expire (they may or may
not actually "exist"), causing a force close decision. Before this PR,
this attempt would fail with a fatal error that can impede start up.

To better handle such a scenario, we'll now catch the error when we fail
to force close due to entering the DLP and instead terminate the state
machine at the broadcast state. When a commitment transaction eventually
confirms, we'll play it as normal.

Fixes https://github.com/lightningnetwork/lnd/issues/7984
2023-09-15 18:29:09 -07:00
Elle Mouton
95c2bfe181
docs: add entry for 7981 2023-09-14 10:33:07 +02:00
Elle Mouton
273b934f62
wtdb+lnrpc: return correct NumAckedUpdates from wtclientrpc 2023-09-14 10:33:04 +02:00
Elle Mouton
2a9339805e
watchtower: account for rogue updates
In this commit, we introduce the concept of a rogue update. An update is
rogue if we need to ACK it but we have already deleted all the data for
the associated channel due to the channel being closed. In this case, we
now no longer error out and instead keep count of how many rogue updates
a session has backed-up.
2023-09-14 10:33:02 +02:00
Elle Mouton
c33cd0ea38
wtdb: refactor getRangesWriteBucket
A pure refactor commit that passes the required buckets to the
`getRangesWriteBucket` instead of re-fetching them.
2023-09-14 10:30:00 +02:00
Elle Mouton
adb87dcfb8
wtclient: demo un-acked update of closed channel bug
This commit adds a new test to the tower client to demonstrate a bug
that can happen if a channel is closed while an update for it has yet to
be acked by the tower server. This will be fixed in an upcomming commit.
2023-09-14 10:28:56 +02:00
Elle Mouton
ff0d8fc619
watchtower: completely remove the mock tower client DB
Remove the use of the mock tower client DB and use the actual bbolt DB
everywhere instead.
2023-09-13 12:21:04 +02:00
Elle Mouton
f889c9b1cc
watchtower: use bbolt db instead of mock DB for client tests
The watchtower client test framework currently uses a mock version of
the tower client DB. This can lead to bugs if the mock DB works slightly
differently to the actual bbolt DB. So this commit ensures that we only
use the bbolt db for the tower client tests. We also increment the
`waitTime` used in the tests a bit to account for the slightly longer DB
read and write times. Doing this switch resulted in one bug being
caught: we were not removing sessions from the in-memory set on deletion
of the session and so that is fixed here too.
2023-09-13 12:13:22 +02:00
Olaoluwa Osuntokun
90effda090
Merge pull request #7977 from Roasbeef/lnd-17-rc3
build: bump version to v0.17.0 rc3
2023-09-12 16:27:45 -07:00
Olaoluwa Osuntokun
1628240960
build: bump version to v0.17.0 rc3 2023-09-12 15:13:40 -07:00
Olaoluwa Osuntokun
8c53620021
Merge pull request #7966 from yyforyongyu/add-force-sweep-outgoing
contractcourt: make sure we force sweep outgoing htlcs
2023-09-12 10:12:49 -07:00
Olaoluwa Osuntokun
c77192a64d
Merge pull request #7960 from Roasbeef/update-kv-db
build: update to kvdb v1.4.3
2023-09-12 10:07:32 -07:00
Olaoluwa Osuntokun
0c815af7ff
build: update lnd sub modules, and btcd + btcutil 2023-09-11 20:35:06 -07:00
Olaoluwa Osuntokun
bb67131ce5
kvdb/sqlbase: use positive+negative build tags for new sql error parsing
In this commit, we use exhaustive build tags to ensure that we can
always build the `sqlbase` package, independent of the set build tags.
To do this, we move the type declarations _into_ the parsing functions.
This then allows us to create two versions for each db: with the db, and
without it.

To avoid a module tag round trip to get this working, we use a local
replace for now. Once this is merged in, we can do the tag (along side
rc3), then remove the replace.
2023-09-11 20:35:01 -07:00
Olaoluwa Osuntokun
30eb90d901
build: update to kvdb v1.4.3
We needed a tag after updating the module with retry for
sqlite/postgres.
2023-09-11 20:34:58 -07:00
bartoli
92059a5278
Update channel.go
Fix missing space between words
2023-09-09 17:56:34 +02:00
yyforyongyu
8787c6c227
contractcourt: make sure we force sweep outgoing htlcs 2023-09-08 20:30:43 +08:00
Olaoluwa Osuntokun
fd58cbfe6b
Merge pull request #7954 from yyforyongyu/fix-chainfee-unit-test
multi: fix unit test flakes
2023-09-05 15:46:56 -07:00
Olaoluwa Osuntokun
84b2f2d0f8
Merge pull request #7955 from yyforyongyu/fix-rand-retry-delay
kvdb/sqlbase: fix params used in `randRetryDelay`
2023-09-05 15:44:49 -07:00
yyforyongyu
c568ba9fa2
github+Makefile: add new action make tidy-module-check
This commit adds `tidy-module` and `tidy-module-check` to make sure the
modules are always tidy.
2023-09-06 02:48:13 +08:00
yyforyongyu
8813bc7ba8
kvdb/sqlbase: fix build errors
We copy the `sqldb/sqlerrors.go` into `kvdb/sqlbase` to avoid import
cycles.
2023-09-06 02:48:12 +08:00