Commit Graph

14970 Commits

Author SHA1 Message Date
positiveblue
730db7ee8c
sqlc: generate go code from SQL
run `make sqlc`

All the code in this commit is auto-generated.
2023-07-10 17:57:06 -07:00
positiveblue
877b711360
sqldb: add invoice event queries 2023-07-10 17:56:29 -07:00
positiveblue
fb16287b31
sqldb: add invoice events SQL schema 2023-07-10 17:56:27 -07:00
positiveblue
6deb916216
sqldb: add AMP invoice queries 2023-07-10 17:53:57 -07:00
positiveblue
eda95e6607
sqldb: add AMP invoices SQL schema
Schema for AMP invocies.

AMP invoices can be paid multiple times and each payment to an AMP invoice
is identified by a `set_id`.

The A in AMP stands for `Atomic`. All the htlcs belonging to the same
AMP payment (share the same set_id) will be resolved at the same time
with the same result: settled/canceled.

AMP invoices do not have an "invoice preimage". Instead, each htcl has
its own hash/preimage. When a new htlc is added the hash for that htlc
is attached to it. When all the htlcs of a set_id have been received we
are able to compute the preimage for each one of them.
2023-07-10 17:53:56 -07:00
positiveblue
7aa2f390fe
sqldb: add invoice queries
Set of queries to deal with invoices. A couple of things to take into
account:

    - Because the queries are not rewritten at runtime, we cannot have a
      generic `INSERT` with different tuples.
    - Because the queries are not rewritten at runtime, we cannot build
      one query with only the filters that matter for that queries. The
      two options are a combinatorial approach (a new query for every
      permutation) or a generic query using the pattern

          ```
            SELECT *
            FROM table
            WHERE (
                -- Can be read as:
                -- Match the filter 1 value if filter_1 != nil
                column_1 >= sqlc.narg('filter_1') OR
                sqlc.narg('filter_1') IS NULL
            ) AND (
                column_2 >= sqlc.narg('filter_2') OR
                sqlc.narg('filter_2') IS NULL
            ) ...
          ```
2023-07-10 17:53:29 -07:00
positiveblue
e3663b9942
sqldb: add invoices SQL schema
This is the schema for "ordinal" BOLT11 invoices.

The invoices table aims to keep an entry for each invoice, BOLT11 or not,
that will be supported.

Invoice related HTLCs will be stored in a separete table than forwarded
htlcs.

SQLite does not support `SEQUENCE`. We achieve atomic autoincrementals
using primary keys with autoincrement/serial. An invoice `AddIndex`
translates to `invoices(id)` while `SettleIndex` is `invoice_payments(id)`.
2023-07-10 17:53:26 -07:00
positiveblue
43a9e2f1ca
multi: add sqlc support
sqlc is a tool that generates fully type-safe idiomatic code from SQL.
The result is Go code can then used execute the queries in the database.

The noraml flow looks like:
- The developer write some sql that will update the schema in the
  database: new tables, indices, etc
- The developer updates the set of queries that will use the new schema.
- `sqlc` generates type-safe interfaces to those queries.
- The developer can then write application code that calls the methods
  generated by sqlc.

The tool configuration needs to live in the repo's root and its name is
`sqlc.yaml`.

LND will support out of the box sqlite and postgres. The sql code needs to
be (almost) the same for both engines, so we cannot use custom functions
like `ANY` in postgres.

The SQLC config file needs to define what is the target engine, we will
set postgres but the generated code can be executed by sqlite too.

In some specific cases, we will `match and replace` some sql lines to be
sure the table definitions are valid for the targeted engine.
2023-07-10 17:36:58 -07:00
Oliver Gugger
287b0ac219
Merge pull request #7817 from ViktorTigerstrom/2023-07-add-viktor-key
scripts: add ViktorTigerstrom PGP key
2023-07-10 14:34:08 +02:00
Oliver Gugger
0045344692
Merge pull request #7814 from harsha-s/patch-2
Fix docker compose run issue
2023-07-10 13:36:16 +02:00
Viktor Tigerström
376aeec52a
scripts: add ViktorTigerstrom PGP key [skip ci] 2023-07-10 12:55:19 +02:00
Oliver Gugger
6002982baa
Merge pull request #7806 from lightningnetwork/dependabot/go_modules/kvdb/google.golang.org/grpc-1.53.0
build(deps): bump google.golang.org/grpc from 1.41.0 to 1.53.0 in /kvdb
2023-07-10 11:14:50 +02:00
Harsha
d9f3a12f57
Fix docker compose run issue
docker-compose run -d --name alice --volume simnet_lnd_alice:/root/.lnd lnd

 => ERROR [builder 4/4] RUN git clone https://github.com/btcsuite/btcd.git .     && git checkout v0.23  6.2s
------
 > [builder 4/4] RUN git clone https://github.com/btcsuite/btcd.git .     && git checkout v0.23.5     && go install -v . ./cmd/...:
#0 0.253 Cloning into '.'...
#0 6.059 error: pathspec 'v0.23.5' did not match any file(s) known to git
------
failed to solve: executor failed running [/bin/sh -c git clone https://github.com/btcsuite/btcd.git .     && git checkout $BTCD_VERSION     && go install -v . ./cmd/...]: exit code: 1
2023-07-10 01:00:57 +01:00
dependabot[bot]
b9b34a086f
build(deps): bump google.golang.org/grpc from 1.41.0 to 1.53.0 in /kvdb
Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.41.0 to 1.53.0.
- [Release notes](https://github.com/grpc/grpc-go/releases)
- [Commits](https://github.com/grpc/grpc-go/compare/v1.41.0...v1.53.0)

---
updated-dependencies:
- dependency-name: google.golang.org/grpc
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-07-05 21:12:10 +00:00
Olaoluwa Osuntokun
86e7b4e1e0
Merge pull request #7794 from yyforyongyu/prepare-channel-ready-fix
brontide: refactor peer to prepare channel ready fix
2023-07-04 12:39:59 -07:00
Olaoluwa Osuntokun
55c991a1a7
Merge pull request #7775 from yyforyongyu/fix-logger-order
lnd: fix orders when initializing subsystem loggers
2023-07-04 12:39:39 -07:00
Olaoluwa Osuntokun
5015cd941e
Merge pull request #7797 from guggero/kvdb-1-4-2
mod: bump kvdb submodule to v1.4.2
2023-07-04 12:39:23 -07:00
Olaoluwa Osuntokun
df9b53b6af
Merge pull request #7766 from ffranr/export_unmarshall_outpoint
Export unmarshall outpoint functionality
2023-07-04 12:37:48 -07:00
Olaoluwa Osuntokun
f3437d6d2a
Merge pull request #7782 from guggero/fix-tor-dial-ipv6
tor: short circuit host lookup if connecting to IP
2023-07-04 12:37:36 -07:00
Oliver Gugger
5c5ce1f707
Merge pull request #7780 from ziggie1984/max_local_csv
Change defaultMaxLocalCSVDelay to protect user from high delays
2023-06-29 20:52:26 +02:00
Oliver Gugger
2604aebdef
mod: bump kvdb submodule to v1.4.2
This is necessary after #7796 to apply the change made in the kvdb
submodule to the main module.
2023-06-29 13:37:58 -04:00
Oliver Gugger
5ea4251b3a
Merge pull request #7796 from hsjoberg/update-kvdb
kvdb: Update bbolt to 1.3.7 in order to address mmap issues
2023-06-29 19:35:26 +02:00
Hampus Sjöberg
3d69ed3d4c kvdb: Update bbolt to 1.3.7 in order to address mmap issues 2023-06-29 17:54:43 +02:00
ziggie
6cbb62a2df
docs: update release-notes 2023-06-28 07:08:32 +02:00
Olaoluwa Osuntokun
aa17c17f9a
Merge pull request #7772 from Roasbeef/release-notes-merge-queue
scripts: update release notes check for merge queue usage
2023-06-27 13:46:29 -04:00
yyforyongyu
195e951e58
peer: rename newChannels to newActiveChannel
As new pending channels will be tracked in the following commits, the
`newChannels` is now renamed to `newActiveChannel` to explicitly refer
to active, non-pending channels.
2023-06-27 20:19:37 +08:00
yyforyongyu
22d2819489
peer: add handleNewChannelMsg method to handle new channel request 2023-06-27 20:19:37 +08:00
yyforyongyu
60627f676f
peer: stop considering pending channels as active
This commit changes the method `isActiveChannel` such that the pending
channels are not consider as active.
2023-06-27 20:19:37 +08:00
yyforyongyu
ccb86a9d1d
peer: update and use SyncMap in Brontide
This commit applies methods `ForEach` and `Len` to `Brontide`.
2023-06-27 20:19:37 +08:00
yyforyongyu
a66d42c682
funding: use SyncMap to simplify map usage 2023-06-27 20:19:37 +08:00
ziggie
39f9673bc7
lnd: update defaultMaxLocalCSVDelay
Make sure our default local csv delay maximum is symetric
compared  to the remote default csv maximum.
2023-06-26 23:39:45 +02:00
Olaoluwa Osuntokun
d0ca48a435
Merge pull request #7767 from yyforyongyu/fix-mempool-leak
Fix mempool memory usage
2023-06-22 11:22:20 -05:00
Oliver Gugger
e95720cf3a
tor: short circuit host lookup if connecting to IP
With this commit we avoid calling LookupHost if we already have an IPv4
or IPv6 address, as we can return that directly.
This avoids asking Tor to resolve an IPv6 address, which it cannot do.
2023-06-22 09:43:22 +02:00
Oliver Gugger
13e198fbde
Merge pull request #7777 from yyforyongyu/fix-pprof-redirect
lnd: fix pprof server redirects
2023-06-22 09:20:31 +02:00
yyforyongyu
148732af61
lnd: fix pprof server redirects 2023-06-22 01:23:27 +08:00
yyforyongyu
b04a40e7b3
mod: update btcwallet version 2023-06-22 01:09:15 +08:00
Oliver Gugger
f1bca2a59c
Merge pull request #7774 from yyforyongyu/log-block-sync
lnd: add debug log when syncing blocks
2023-06-20 13:56:07 +02:00
yyforyongyu
2451e6ae50
lnd: fix orders when initializing subsystem loggers
This commit fixed a wrong ordering of initializing subsystem loggers. We
need to make sure "third party" loggers are initialized first such that
when we customize the names later in `lnd`'s packages, the overwriting
of the logger names will take effect.
2023-06-20 18:34:16 +08:00
Oliver Gugger
0d8d0fd261
Merge pull request #7763 from yyforyongyu/enhance-temp-miner
Better temp miner management and more verbose loggings
2023-06-19 10:37:01 +02:00
yyforyongyu
bd205aac13
lnd: add debug log when syncing blocks 2023-06-19 14:53:56 +08:00
yyforyongyu
29124dd3b4
itest+lntest: add helper methods to manage temp miners
This commit adds several methods to easily spawn a temp miner and
connect/disconnect it from the original miner.
2023-06-19 14:04:24 +08:00
yyforyongyu
bacb49ddba
peer+server: provide more verbose logging 2023-06-19 14:04:24 +08:00
Olaoluwa Osuntokun
7f95810359
Merge pull request #7710 from carlaKC/7297-updateaddtlvs
Channeldb: Store HTLC Extra TLVs in Onion Blob Varbytes
2023-06-16 14:31:11 -05:00
Oliver Gugger
02c1261a3d
Merge pull request #7728 from shaurya947/memo-pending-channels
lnrpc+itest: return channel Memo for Pending channels
2023-06-16 18:34:30 +02:00
Oliver Gugger
2e1b6597cf
Merge pull request #7771 from ellemouton/towerConfigDefaults
multi: add tower config defaults
2023-06-16 09:39:49 +02:00
Olaoluwa Osuntokun
f42b6a3949
scripts: update release notes check for merge queue usage
Without this commit, PRs can fail to be merged via the merge queue, as
it'll fail with this error:
```
Run scripts/check-release-notes.sh
PR gh-readonly-queue didn't update release notes
Error: Process completed with exit code 1.
```
2023-06-15 17:48:55 -05:00
shaurya947
44fdd02ab4
lnrpc+itest: return channel Memo for Pending channels
In a previous PR we added a Memo field for channels that could be
specified when opening a channel. This was a reference note-to-self
with no bearing on the functioning of the channel. In that PR, the
memo value was returned only through ListChannels. This commit builds
upon that PR by also returning the Memo field for channels returned by
PendingChannels RPC.
2023-06-15 15:16:06 -04:00
Elle Mouton
7484910968
docs: add release note for 7771 2023-06-15 11:36:44 +02:00
Elle Mouton
255d8bb355
lncfg: remove deprecated PrivateTowerURIs from Wtclient cfg
This commit removes the `PrivateTowerURIs` member from the `WtClient`
config struct. This field has been deprecated since v0.8.0-beta and
currently, LND would fail to start if the field was specified.
2023-06-15 11:36:44 +02:00
Elle Mouton
f3525e8b7c
multi: add default watchtower config to main LND config
In this commit, a `DefaultWatchtowerCfg` function is added which is used
to construct a default `lncfg.Watchtower` struct. This is then used to
populate the default watchtower config in the main LND config struct.
2023-06-15 11:36:44 +02:00