Commit graph

15017 commits

Author SHA1 Message Date
Matt Morehouse
e5fcc57bbc
docs: release note for #7723 2023-07-19 09:04:22 -05:00
Matt Morehouse
bd7ec84497
zpay32: help fuzzer generate valid encodings
It is very difficult for the fuzzer to create a valid checksum for each
serialized invoice, and we were therefore unable to fuzz deeper than
invoice decoding. We can help the fuzzer generate valid serialized
invoices by calculating and appending the checksum ourselves.

We also switch to using mainnet invoices to make it easier to find valid
invoices for seeding the fuzzer. We prepend the required "lnbc" prefix
ourselves to further help the fuzzer generate valid invoices.
2023-07-19 09:04:18 -05:00
Matt Morehouse
82753f091b
zpay32: use message signer from unit tests
The message signer from invoice_test.go is identical to the one created
in the fuzz test. We're already using the private key from
invoice_test.go, so we may as well use the complete message signer for
simplicity.
2023-07-19 09:04:13 -05:00
Matt Morehouse
4207be6e50
zpay32: remove unused method calls
The fuzz tests call inv.MinFinalCLTVExpiry() and inv.Expiry() supposedly
to ensure the invoice is well-formed. However, those methods can never
panic or return errors and therefore provide no benefit for this
purpose.
2023-07-19 09:04:03 -05:00
Oliver Gugger
0d2f2aa802
Merge pull request #6895 from ellemouton/towerHasUnackedUpdates
wtclient: replay pending and unacked updates
2023-07-19 12:19:49 +02:00
Elle Mouton
7bf07d8875
docs: add release note for 6895 2023-07-19 10:10:15 +02:00
Elle Mouton
3ea67983b5
wtclient: replay un-acked updates onto pipeline
In this commit, the bugs demonstrated in prior commits are fixed. In the
case where an session has persisted a CommittedUpdate and the tower is
being removed, the session will now replay that update on to the main
task pipeline so that it can be backed up using a different session.
2023-07-18 16:28:27 +02:00
Elle Mouton
c432899bf9
watchtower: add DeleteCommittedUpdate DB method
Add a new DeleteCommittedUpdate method to the wtdb In preparation for an
upcoming commit that will replay committed updates from one session to
another.
2023-07-18 16:28:27 +02:00
Elle Mouton
cfb81c00a6
wtclient: tower with unacked updates cant be removed after restart
This commit demonstrates that if a session has persisted committed
updates and the client is restarted _after_ these committed updates have
been persisted, then removing the tower will fail.
2023-07-18 16:28:27 +02:00
Elle Mouton
af1506bff1
wtclient: demo "tower has unacked updates" bug
In this commit, we demonstrate the situation where a client has
persisted CommittedUpdates but has not yet recieved Acks for them from
the tower. If this happens and the client attempts to remove the tower,
it will with the "tower has unacked updates" error.
2023-07-18 16:28:26 +02:00
Elle Mouton
552ef4bf81
wtclient: replay pending tasks on sessionQueue stop
This commit does a few things:
- First, it gives the sessionQueue access to the TowerClient task
  pipeline so that it can replay backup tasks onto the pipeline on Stop.
- Given that the above is done, the ForceQuit functionality of the
  sessionQueue and TowerClient can be removed.
- The bug demonstrated in a prior commit is now fixed due to the above
  changes.
2023-07-18 16:28:26 +02:00
Elle Mouton
449d6b5500
wtclient: fix handleStaleTower comment 2023-07-18 14:27:14 +02:00
Elle Mouton
25c4d3f1f7
wtclient: make sessionQueueSet thread safe
In preparation for an upcoming commit where multiple threads will have
access to the TowerClient sessionQueueSet, we turn it into a thread safe
struct.
2023-07-18 14:27:04 +02:00
Elle Mouton
c4fec3ebc9
wtclient: show that bound tasks are not replayed
This commit demonstrates a bug. It shows that if backup tasks have been
bound to a session with a tower (ie, the tasks are in the session's
pendingQueue) and then the tower is removed and a new one is added, then
the tasks from the pendingQueue are _not_ replayed to the session with
the new tower. Instead, they are silently lost. This will be fixed in an
upcoming commit.
2023-07-18 14:26:51 +02:00
Elle Mouton
feb35e65d8
wtclient: show that a client can switch towers
This commit adds a new watchtower client test to demonstrate that a
client is able to successfully switch to a new tower and continue
backing up updates to that new tower.
2023-07-18 14:26:35 +02:00
Elle Mouton
d8af5fcc92
wtclient: ensure that waitForUpdates has no race condition on timeout
Enforce that the fail timeout in `waitForUpdates` is greater than the
ping timeout.
2023-07-18 14:25:58 +02:00
Elle Mouton
d979f59331
wtclient: move server specific methods to serverHarness 2023-07-18 14:15:46 +02:00
Elle Mouton
2ed5788de3
wtclient: separate server from testHarness
In this commit, a serverHarness is added to the test framework. This
will allow us to create more mock servers appart from the main server.
2023-07-18 14:15:26 +02:00
Oliver Gugger
2bb28f7aaf
Merge pull request #7834 from bitcoincore-dev/1689267061/e8c11b989/ee55126b5-scripts/check-release-notes.sh
scripts/check-release-notes.sh: fix bash expression
2023-07-18 12:03:30 +02:00
Oliver Gugger
bd3f570107
Merge pull request #7807 from lightningnetwork/dependabot/go_modules/google.golang.org/grpc-1.53.0
build(deps): bump google.golang.org/grpc from 1.41.0 to 1.53.0
2023-07-17 14:15:25 +02:00
Oliver Gugger
cbb1d943b2
Merge pull request #7831 from bitcoincore-dev/1689264113/6e68c3b2b/afbc9c629-consistent-username
docs: Make MacOS user path consistent across docs
2023-07-17 14:12:22 +02:00
@RandyMcMillan
2b7c9019eb
docs/grpc/java.md: use /Users/<username>/..
Make MacOS user path consistent across docs
2023-07-14 16:44:28 -04:00
@RandyMcMillan
ed94a8f3b4
docs/INSTALL.md: use /Users/<username>/..
Make MacOS user path consistent across docs
2023-07-14 16:41:52 -04:00
@RandyMcMillan
f2b3674b3a
scripts/check-release-notes.sh: fix bash expression 2023-07-13 12:51:40 -04:00
Oliver Gugger
a6fc5d0753
Merge pull request #7826 from carlaKC/race-testinvoice
invoices/test: fix data race in TestMppPaymentWithOverpayment
2023-07-13 17:32:27 +02:00
Carla Kirk-Cohen
590d898ba0
invoices/test: fix data race in TestMppPaymentWithOverpayment
Details of race:
- A global testInvoice is used in various invoice related tests.
- All tests are running with t.Parallel.
- TestMppPaymentWithOverpayment passes a reference to the testInvoice
  to AddInvoice which writes the AddIndex.
- TestMultipleSetHeightExpiry reads the testInvoice to make a copy.
2023-07-13 10:39:35 -04:00
Oliver Gugger
e8c11b9898
Merge pull request #7783 from guggero/bump-tor-dependency-ipv6-fix
mod: bump tor submodule to v1.1.1
2023-07-13 11:05:20 +02:00
Oliver Gugger
bc58dce176
docs: update release notes 2023-07-13 10:17:17 +02:00
Oliver Gugger
cffdc9a46f
mod: bump tor submodule to v1.1.1 2023-07-13 10:17:02 +02:00
Olaoluwa Osuntokun
acecb12f54
Merge pull request #7354 from positiveblue/invoice-sql-schema
sqldb: add invoice schema and sql queries
2023-07-12 17:03:26 -07:00
Oliver Gugger
7d202e69ef
Merge pull request #7739 from sputn1ck/autocert_fix
tlsmanager: fix autocert autogeneration
2023-07-12 10:03:01 +02:00
sputn1ck
92e0b08a7a
docs: add release note for 7739 2023-07-11 21:25:19 +02:00
sputn1ck
10f9748193
tlsmanager: fix autocert autogeneration
As the getConfig() function would previously overwrite the
GetCertificateFunction of the tls config, the autocert manager would
never be used.
2023-07-11 21:24:46 +02:00
Olaoluwa Osuntokun
33b470b4a6
Merge pull request #7768 from ProofOfKeags/spurious-htlc-rejections
invoices+htlcswitch: fix spurious htlc rejections from overly strict onion packet integrity checks
2023-07-11 10:51:22 -07:00
Oliver Gugger
54acf270a2
Merge pull request #7758 from guggero/gpg-homedir
scripts: use gpg --homedir flag to fix new behavior in 2.4
2023-07-11 10:33:57 +02:00
Oliver Gugger
52115ab19b
docs: add release notes 2023-07-11 09:18:43 +02:00
Oliver Gugger
8c9f4515b6
scripts: use gpg --homedir flag to fix new behavior in 2.4
With the latest Golang Docker base image we are using the new gpg
version 2.4 is now being installed in the lnd Docker base image.

Apparently the expected value for the --keyring flag is just a file name
and not an absolute path. The path of the file is indicated either by
the $HOME environment variable or the --homedir flag. It looks like 2.4
now finally stopped supporting an absolute path in the --keyring flag
and we need to update our gpg command to make the script work again.

This should be backward compatible and still work on older versions of
gpg.
2023-07-11 09:18:22 +02:00
positiveblue
8fcb404161
docs: add release note for 7354 2023-07-10 17:57:09 -07:00
positiveblue
ff1379a633
CI: Add sqlc code generation check 2023-07-10 17:57:09 -07:00
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