Commit Graph

16844 Commits

Author SHA1 Message Date
Olaoluwa Osuntokun
7302051f44
build: update to sqldb v1.0.2
In this commit, we update the project and relevant sub-modules to sqldb
v1.0.2. The next step is to tag a new version of kvdb, then update the
main module to use that.
2024-04-26 15:31:14 -07:00
Olaoluwa Osuntokun
abcad6218e
Merge pull request #8696 from Roasbeef/sqlite-update
sqldb+kvdb: update to sqlite v1.29.8
2024-04-26 15:25:33 -07:00
Olaoluwa Osuntokun
b0463124d0
Merge pull request #8694 from Roasbeef/fix-pkg-race
channeldb: fix race in TestPackager by removing global test var
2024-04-26 15:18:00 -07:00
Olaoluwa Osuntokun
675ae6e213
Merge pull request #8693 from yyforyongyu/add-default-conf
rpc: add default conf target back
2024-04-26 12:45:06 -07:00
Olaoluwa Osuntokun
add2691954
Merge pull request #8485 from carlaKC/7298-3-forwardblindedroutes
[3/3]: Blinded Route Error Handling
2024-04-26 12:39:11 -07:00
Olaoluwa Osuntokun
fe8784aa0c
channeldb: fix race in TestPackager by removing global test var
In this commit, we fix a race in the `TestPackager` series on channeldb.
A few tests were sharing the same global variable of the set of log
updates, which includes a pointer to an HTLC. The `ExtraData` value of
the HTLC would then be mutated once we go to encode the message on disk.

To fix this, we the global with a function that returns a new instance
of all the test data.

```
==================
WARNING: DATA RACE
Write at 0x0000021b0a48 by goroutine 2896:
  github.com/lightningnetwork/lnd/lnwire.(*ExtraOpaqueData).PackRecords()
      /home/runner/work/lnd/lnd/lnwire/extra_bytes.go:74 +0x546
  github.com/lightningnetwork/lnd/lnwire.EncodeMessageExtraData()
      /home/runner/work/lnd/lnd/lnwire/extra_bytes.go:121 +0x4d
  github.com/lightningnetwork/lnd/lnwire.(*UpdateAddHTLC).Encode()
      /home/runner/work/lnd/lnd/lnwire/update_add_htlc.go:164 +0x5af
  github.com/lightningnetwork/lnd/lnwire.WriteMessage()
      /home/runner/work/lnd/lnd/lnwire/message.go:330 +0x351
  github.com/lightningnetwork/lnd/channeldb.WriteElement()
      /home/runner/work/lnd/lnd/channeldb/codec.go:186 +0x1975
  github.com/lightningnetwork/lnd/channeldb.WriteElements()
      /home/runner/work/lnd/lnd/channeldb/codec.go:247 +0x14f
  github.com/lightningnetwork/lnd/channeldb.serializeLogUpdate()
      /home/runner/work/lnd/lnd/channeldb/channel.go:2529 +0x3c
  github.com/lightningnetwork/lnd/channeldb.putLogUpdate()
      /home/runner/work/lnd/lnd/channeldb/forwarding_package.go:525 +0xae
  github.com/lightningnetwork/lnd/channeldb.(*ChannelPackager).AddFwdPkg()
      /home/runner/work/lnd/lnd/channeldb/forwarding_package.go:489 +0x684
  github.com/lightningnetwork/lnd/channeldb_test.TestPackagerOnlyAdds.func1()
      /home/runner/work/lnd/lnd/channeldb/forwarding_package_test.go:283 +0x4c
  github.com/btcsuite/btcwallet/walletdb/bdb.(*db).Update()
      /home/runner/go/pkg/mod/github.com/btcsuite/btcwallet/walletdb@v1.4.2/bdb/db.go:429 +0xe5
  github.com/lightningnetwork/lnd/kvdb.Update()
      /home/runner/go/pkg/mod/github.com/lightningnetwork/lnd/kvdb@v1.4.6/interface.go:16 +0x258
  github.com/lightningnetwork/lnd/channeldb_test.TestPackagerOnlyAdds()
      /home/runner/work/lnd/lnd/channeldb/forwarding_package_test.go:282 +0x17b
  testing.tRunner()
      /home/runner/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.21.4.linux-amd64/src/testing/testing.go:1595 +0x238
  testing.(*T).Run.func1()
      /home/runner/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.21.4.linux-amd64/src/testing/testing.go:1648 +0x44

Previous write at 0x0000021b0a48 by goroutine 2898:
  github.com/lightningnetwork/lnd/lnwire.(*ExtraOpaqueData).PackRecords()
      /home/runner/work/lnd/lnd/lnwire/extra_bytes.go:74 +0x546
  github.com/lightningnetwork/lnd/lnwire.EncodeMessageExtraData()
      /home/runner/work/lnd/lnd/lnwire/extra_bytes.go:121 +0x4d
  github.com/lightningnetwork/lnd/lnwire.(*UpdateAddHTLC).Encode()
      /home/runner/work/lnd/lnd/lnwire/update_add_htlc.go:164 +0x5af
  github.com/lightningnetwork/lnd/lnwire.WriteMessage()
      /home/runner/work/lnd/lnd/lnwire/message.go:330 +0x351
  github.com/lightningnetwork/lnd/channeldb.WriteElement()
      /home/runner/work/lnd/lnd/channeldb/codec.go:186 +0x1975
  github.com/lightningnetwork/lnd/channeldb.WriteElements()
      /home/runner/work/lnd/lnd/channeldb/codec.go:247 +0x14f
  github.com/lightningnetwork/lnd/channeldb.serializeLogUpdate()
      /home/runner/work/lnd/lnd/channeldb/channel.go:2529 +0x3c
  github.com/lightningnetwork/lnd/channeldb.putLogUpdate()
      /home/runner/work/lnd/lnd/channeldb/forwarding_package.go:525 +0xae
  github.com/lightningnetwork/lnd/channeldb.(*ChannelPackager).AddFwdPkg()
      /home/runner/work/lnd/lnd/channeldb/forwarding_package.go:489 +0x684
  github.com/lightningnetwork/lnd/channeldb_test.TestPackagerAddsThenSettleFails.func1()
      /home/runner/work/lnd/lnd/channeldb/forwarding_package_test.go:490 +0x4c
  github.com/btcsuite/btcwallet/walletdb/bdb.(*db).Update()
      /home/runner/go/pkg/mod/github.com/btcsuite/btcwallet/walletdb@v1.4.2/bdb/db.go:429 +0xe5
  github.com/lightningnetwork/lnd/kvdb.Update()
      /home/runner/go/pkg/mod/github.com/lightningnetwork/lnd/kvdb@v1.4.6/interface.go:16 +0x2cd
  github.com/lightningnetwork/lnd/channeldb_test.TestPackagerAddsThenSettleFails()
      /home/runner/work/lnd/lnd/channeldb/forwarding_package_test.go:489 +0x1e7
  testing.tRunner()
      /home/runner/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.21.4.linux-amd64/src/testing/testing.go:1595 +0x238
  testing.(*T).Run.func1()
      /home/runner/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.21.4.linux-amd64/src/testing/testing.go:1648 +0x44

Goroutine 2896 (running) created at:
  testing.(*T).Run()
      /home/runner/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.21.4.linux-amd64/src/testing/testing.go:1648 +0x82a
  testing.runTests.func1()
      /home/runner/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.21.4.linux-amd64/src/testing/testing.go:2054 +0x84
  testing.tRunner()
      /home/runner/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.21.4.linux-amd64/src/testing/testing.go:1595 +0x238
  testing.runTests()
      /home/runner/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.21.4.linux-amd64/src/testing/testing.go:2052 +0x896
  testing.(*M).Run()
      /home/runner/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.21.4.linux-amd64/src/testing/testing.go:1925 +0xb57
  github.com/lightningnetwork/lnd/kvdb.RunTests()
      /home/runner/go/pkg/mod/github.com/lightningnetwork/lnd/kvdb@v1.4.6/test_utils.go:23 +0x26
  github.com/lightningnetwork/lnd/channeldb.TestMain()
      /home/runner/work/lnd/lnd/channeldb/setup_test.go:10 +0x308
  main.main()
      _testmain.go:321 +0x303

Goroutine 2898 (running) created at:
  testing.(*T).Run()
      /home/runner/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.21.4.linux-amd64/src/testing/testing.go:1648 +0x82a
  testing.runTests.func1()
      /home/runner/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.21.4.linux-amd64/src/testing/testing.go:2054 +0x84
  testing.tRunner()
      /home/runner/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.21.4.linux-amd64/src/testing/testing.go:1595 +0x238
  testing.runTests()
      /home/runner/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.21.4.linux-amd64/src/testing/testing.go:2052 +0x896
  testing.(*M).Run()
      /home/runner/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.21.4.linux-amd64/src/testing/testing.go:1925 +0xb57
  github.com/lightningnetwork/lnd/kvdb.RunTests()
      /home/runner/go/pkg/mod/github.com/lightningnetwork/lnd/kvdb@v1.4.6/test_utils.go:23 +0x26
  github.com/lightningnetwork/lnd/channeldb.TestMain()
      /home/runner/work/lnd/lnd/channeldb/setup_test.go:10 +0x308
  main.main()
      _testmain.go:321 +0x303
==================
```
2024-04-26 12:36:53 -07:00
Olaoluwa Osuntokun
eb605a02fd
sqldb+kvdb: update to sqlite v1.29.8
Updates to SQLite 3.45.3: https://www.sqlite.org/releaselog/3_45_3.html.

May also address https://github.com/lightningnetwork/lnd/issues/8666.
2024-04-26 12:26:59 -07:00
fuyangpengqi
5f22d97b51 chore: fix function names in comment
Signed-off-by: fuyangpengqi <995764973@qq.com>
2024-04-27 00:04:09 +08:00
Carla Kirk-Cohen
6572f5cb74
docs: add error handling link 2024-04-26 11:35:19 -04:00
Carla Kirk-Cohen
7867cb3a70
multi: turn on route blinding by default 2024-04-26 11:35:18 -04:00
Carla Kirk-Cohen
eaa85920ea
multi: enable optional route blinding feature 2024-04-26 11:35:17 -04:00
Carla Kirk-Cohen
75d4a4c295
itest: add coverage for blinded error resolution from on-chain failure
This itest adds a test that we still propagate blinded errors back
properly after a restart with an on-chain resolution. The test also
updates our sendpayment timeout to longer so that there's time to
resolve the on chain claim.
2024-04-26 11:35:17 -04:00
Carla Kirk-Cohen
2140f1940f
itest: manually set timeout on cancel payment and provide cancel
For tests where our payments require an on-chain resolution,
provide longer timeout and return cancel functions.
2024-04-26 10:56:33 -04:00
bitromortac
ba34f220b9
make: add cache directory for linter
Mounts a local temporary folder to the linter docker container in order
to persist the linter cache across runs.
2024-04-26 13:47:50 +02:00
yyforyongyu
db52e7e381
docs: update release notes 2024-04-26 10:42:46 +08:00
yyforyongyu
d0441a2a29
multi: add default conf targt in SendCoins/SendMany/OpenChannel/CloseChannel 2024-04-26 10:42:44 +08:00
Olaoluwa Osuntokun
e6d6789fd9
Merge pull request #8681 from Roasbeef/amp-flag-consistency
lnrpc: ensure parsing of the Amp flag for payments is consistent
2024-04-25 18:49:51 -07:00
Olaoluwa Osuntokun
e8031fdccf
lnrpc: ensure parsing of the Amp flag for payments is consistent
In this commit, we fix an inconsistent in the API related to AMP
payments. When a payment request isn't specified, we require the `--amp`
flag on the CLI to make an AMP payment. However, for payment requests,
we don't require this flag. To fix this inconsistency, we now require
the `--amp` flag to _also_ be set for payment requests.
2024-04-25 16:16:16 -07:00
Olaoluwa Osuntokun
ab2f34e13b
Merge pull request #8621 from ziggie1984/fix-sync-neutrino-nodes
fix sync neutrino nodes
2024-04-25 16:13:32 -07:00
Oliver Gugger
c6dae6c3c0
tlv: rename receivers, add ValOpt
ValOpt returns an Option of the underlying value.
2024-04-25 16:51:12 +02:00
Olaoluwa Osuntokun
956b00b599
tlv: add in new BigSizeT type
This type is useful when one wants to encode an integer as an underlying BigSize record. It wraps any integer, then handles the transformation into and out of the BigSize encoding on disk.
2024-04-25 16:48:29 +02:00
Olaoluwa Osuntokun
5b2869b0ec
tlv: add new Blob type alias
In this commit, we add a new type alias for a blob type. This type can be used in areas where a byte slice is used to store a TLV value, which may be a fully opaque nested TLV.
2024-04-25 16:48:06 +02:00
Carla Kirk-Cohen
d57c6fab47
itest: add coverage for disabling blinded forwards 2024-04-25 09:47:17 -04:00
Carla Kirk-Cohen
428a33fbda
itest: add coverage for failure at the introduction node 2024-04-25 09:47:16 -04:00
Carla Kirk-Cohen
4535cf6c65
itest: add coverage for failure within a blinded route 2024-04-25 09:47:15 -04:00
Carla Kirk-Cohen
d13a73a93a
itest: add test coverage for failure at blinded receiver 2024-04-25 09:47:14 -04:00
Carla Kirk-Cohen
43687181f7
htlcswitch: convert blinded failures for blinded payments 2024-04-25 09:47:13 -04:00
Carla Kirk-Cohen
de9c9c028c
htlcswitch: set packet obfuscator for failures through switch
Set obfuscator for use in blinded error handling when we forward
failures through the switch.
2024-04-25 09:47:12 -04:00
Carla Kirk-Cohen
72260adddb
htlcswitch: create error obfuscator with wrapped type for blinded
Create our error encrypter with a wrapped type if we have a blinding
point present. Doing this in the iterator allows us to track this
information when we have both pieces of information available to us,
compared to trying to handle this later down the line:
- Downstream link on failure: we know that we've set a blinding point
  for out outgoing HTLC, but not whether we're introduction or not
- Upstream link on failure: once the failure packet has been sent
  through the switch, we no longer know whether we were the introduction
  point (without looking it up / examining our payload again /
  propagating this information through the switch).
2024-04-25 09:47:11 -04:00
Carla Kirk-Cohen
9f038c6191
htlcswitch: introduce wrapper type error encrypter to identify blinded
Introduce two wrapper types for our existing SphinxErrorEncrypter
that are used to represent error encrypters where we're a part of a
blinded route. These encrypters are functionally the same as a sphinx
encrypter, and are just used as "markers" so that we know that we
need to handle our error differently due to our different role.

We need to persist this information to account for restart cases where
we've resovled the outgoing HTLC, then restart and need to handle the
error for the incoming link. Specifically, this is relevant for:
- On chain resolution messages received after restart
- Forwarding packages that are re-forwarded after restart

This is also generally helpful, because we can store this information
in one place (the circuit) rather than trying to reconstruct it in
various places when forwarding the failure back over the switch.
2024-04-25 09:47:10 -04:00
Carla Kirk-Cohen
776c889267
multi: return route role from HopPayload
We need to know what role we're playing to be able to handle errors
correctly, but the information that we need for this is held by our
iterator:
- Whether we had a blinding point in update add (blinding kit)
- Whether we had a blinding point in payload

As we're now going to use the route role return value even when our
err!=nil, we rename the error to signal that we're using less
canonical golang here.

An alternative to this approach is to attach a RouteRole to our
ErrInvalidPayload. The downside of that approach is:
- Propagate context through parsing (whether we had updateAddHtlc)
- Clumsy handling for errors that are not of type ErrInvalidPayload
2024-04-25 09:46:31 -04:00
Carla Kirk-Cohen
b81a6f3d2f
htlcswitch: split parsing and validation of TLV payloads
When handling blinded errors, we need to know whether there was a
blinding key in our payload when we successfully parsed our payload
but then found an invalid set of fields. The combination of
parsing and validation in NewPayloadFromReader means that we don't know
whether a blinding point was available to us by the time the error is
returned.

This commit splits parsing and validation into two functions so that
we can take a look at what we actually pulled of the payload in between
parsing and TLV validation.
2024-04-25 09:15:58 -04:00
Carla Kirk-Cohen
4d051b4170
multi: handle all blinding point validation in ValidateParsedPayloadTypes
This commit moves all our validation related to the presence of fields
into ValidateParsedPayloadTypes so that we can handle them in a single
place. We draw the distinction between:
- Validation of the payload (and the context within it's being parsed,
  final hop / blinded hop etc)
- Processing and validation of encrypted data, where we perform
  additional cryptographic operations and validate that the fields
  contained in the blob are valid.

This helps draw the line more clearly between the two validation types,
rather than splitting some payload-releated blinded hop processing
into the encrypted data processing part. The downside of this approach
(vs doing the blinded path payload check _after_ payload validation)
is that we have to pass additional context into payload validation
(ie, whether we got a blinding point in our UpdateAddHtlc - as we
already do for isFinalHop).
2024-04-25 09:15:57 -04:00
Carla Kirk-Cohen
c2c0158c84
htlcswitch: handle malformed HTLC with invalid onion blinding code
This commit adds handling for malformed HTLC errors related to blinded
paths. We expect to receive these errors _within_ a blinded path,
because all non-introduction nodes are instructed to return malformed
errors for failures.

Note that we may actually switch back to a malformed error later on if
we too are a relaying node in the route, but we handle that case the
incoming link.
2024-04-25 09:15:56 -04:00
Oliver Gugger
2089a88f4b
Merge pull request #7765 from ErikEk/retire-io-ioutil-dep
Remove io/ioutil package dependency
2024-04-25 13:17:15 +02:00
ziggie
f4b92eb3d4
docs: add release-notes. 2024-04-25 12:00:56 +01:00
ziggie
9f9d1c9e0b
itest: fix typo. 2024-04-25 12:00:26 +01:00
ziggie
fe829c2508
mod: bump neutrino version. 2024-04-25 12:00:26 +01:00
erik
0d94131fca doc: release note 2024-04-25 11:56:54 +02:00
erik
df4ddcc573 multi: replace ioutil.TempDir 2024-04-25 11:24:41 +02:00
erik
caf2419ff6 multi: replace ioutil.ReadDir 2024-04-25 11:24:17 +02:00
erik
c7f81d3142 multi: replace ioutil.Discard 2024-04-25 11:23:54 +02:00
erik
789c6bac8c multi: replace ioutil.WriteFile 2024-04-25 11:23:31 +02:00
erik
ab83343c87 multi: repleace ioutil.ReadFile 2024-04-25 11:22:43 +02:00
erik
619c8f4eb8 multi: repleace ioutil.ReadAll 2024-04-25 11:21:18 +02:00
Oliver Gugger
dcd8e16376
Merge pull request #8685 from ziggie1984/fix-bumpfee-immediate
fix lncli bumpfee flag parsing
2024-04-25 10:17:05 +02:00
Oliver Gugger
7f5f8065ca
Merge pull request #8672 from mohamedawnallah/makeDeleteAllPaymentsArgsRequired
rpcserver: Make sure the arguments are provided when calling `DeleteAllPayments` RPC
2024-04-25 10:02:59 +02:00
Oliver Gugger
8ce3622792
Merge pull request #8590 from ffranr/test-node-name-in-tmpdir
lntest: add test node name to tmp directory name
2024-04-24 20:06:04 +02:00
Oliver Gugger
fe26005228
Merge pull request #8592 from zhiqiangxu/master
itest: fix ascii
2024-04-24 11:05:21 -06:00
Oliver Gugger
5cf700d611
Merge pull request #8658 from hidewrong/master
chore: fix struct names
2024-04-24 10:56:20 -06:00