Commit graph

1188 commits

Author SHA1 Message Date
yyforyongyu
765714e750
htlcswitch: add processLocalUpdateFulfillHTLC 2025-07-03 19:50:29 +08:00
yyforyongyu
c42bf9b545
htlcswitch: log err in the end in handleUpstreamMsg 2025-07-03 19:50:29 +08:00
yyforyongyu
87b490dfc4
htlcswitch: add processRemoteError and processRemoteUpdateFee 2025-07-03 19:50:29 +08:00
yyforyongyu
4017104475
htlcswitch: add processRemoteRevokeAndAck 2025-07-03 19:50:29 +08:00
yyforyongyu
04abf96f60
htlcswitch: add processRemoteCommitSig 2025-07-03 19:50:29 +08:00
yyforyongyu
ad1566ee3f
htlcswitch: add processRemoteUpdateFailHTLC 2025-07-03 19:50:29 +08:00
yyforyongyu
e883a51a63
htlcswitch: add processRemoteUpdateFailMalformedHTLC 2025-07-03 19:50:28 +08:00
yyforyongyu
f9df5a9f51
htlcswitch: add processRemoteUpdateFulfillHTLC 2025-07-03 19:50:28 +08:00
yyforyongyu
212262bf88
htlcswitch: add processRemoteUpdateAddHTLC 2025-07-03 19:50:28 +08:00
yyforyongyu
83f658f714
htlcswitch: remove TODO and nolint
This old TODO is no longer relevant.
2025-07-03 19:50:28 +08:00
yyforyongyu
3af8281370
htlcswitch: add handler resumeLink 2025-07-03 19:50:25 +08:00
yyforyongyu
ca770bb4af
htlcswitch: notify channel active after reforwarding
The channel should only be considered active when its pending tasks are
finished, which includes,
1. sync channel state via reestablish.
2. send previous shutdown msg.
3. reset the mailbox's packets.
4. reforwarding logs loaded from restart.

When the above tasks are finished, the channel can be considered as
fully resumed from its previous disconnection.
2025-07-03 18:31:13 +08:00
yyforyongyu
09022b5f56
htlcswitch: add handler toggleBatchTicker 2025-07-03 18:31:12 +08:00
yyforyongyu
cccb447439
htlcswitch: add handler handleUpdateFee 2025-07-03 18:31:12 +08:00
yyforyongyu
e8b2035484
htlcswitch: add handler handleQuiescenceReq 2025-07-03 18:31:12 +08:00
yyforyongyu
30f9257a6b
htlcswitch: add handler handleHtlcResolution 2025-07-03 18:31:12 +08:00
George Tsagkarelis
4ad84627e1
htlcswitch+routing: PaymentBandwidth accepts channel peer pubkey argument 2025-07-02 12:09:24 +02:00
George Tsagkarelis
1793b1ab64
routing+htlcswitch: ProduceHtlcExtraData uses first hop pub key 2025-07-02 12:03:34 +02:00
Elle Mouton
8cf567b948
multi: use the "errors" package everywhere
Replace all usages of the "github.com/go-errors/errors" and
"github.com/pkg/errors" packages with the standard lib's "errors"
package. This ensures that error wrapping and `errors.Is` checks will
work as expected.
2025-06-30 09:46:55 +02:00
yyforyongyu
755bb09a73
htlcswitch: skip decoding hop if the htlc is already acked
We now move the check earlier in the loop so we don't even need to
decode the hop for already processed ADDs.
2025-06-17 11:39:38 +08:00
yyforyongyu
e3f95dcd09
htlcswitch: remove batchReplayBkt
This commit removes the `batchReplayBkt` as its only effect is to allow
reforwarding htlcs during startup.

Normally for every incoming htlc added, their shared secret is used as
the key to be saved into the `sharedHashBucket`, which will be used for
check for replays. In addition, the fwdPkg's ID, which is SCID+height is
also saved to the bucket `batchReplayBkt`. Since replays of HTLCs cannot
happen at the same commitment height, when a replay happens,
`batchReplayBkt` simply doesn't have this info, and we again rely on
`sharedHashBucket` to detect it. This means most of the time the
`batchReplayBkt` is a list of SCID+height with empty values.

The `batchReplayBkt` was previously used as a mechanism to check for
reforwardings during startup - when reforwarding htlcs, it quries this
bucket and finds an empty map, knowing this is a forwarding and skips
the check in `sharedHashBucket`. Given now we use a bool flag to
explicitly skip the replay check, this bucket is no longer useful.
2025-06-17 11:39:38 +08:00
yyforyongyu
3b9c4eb232
htlcswitch: exit early if the fwdPkg is already completed 2025-06-17 11:39:38 +08:00
yyforyongyu
fb95458a1b
htlcswitch: skip checking replays for reforwarded packets
We now rely on the forwarding package's state to decide whether a given
packet is a reforwarding or not. If we know it's a reforwarding packet,
there's no need to check for replays in the `sharedHashes` bucket, which
behaves the same as if we are querying the `batchReplayBkt`.
2025-06-17 11:39:37 +08:00
Olaoluwa Osuntokun
92a5d35cff
Merge pull request #9911 from ziggie1984/exit-early-for-fwd-adds
htlcswitch: exit early if no adds are in the fwd pkg
2025-06-10 15:14:09 -07:00
ziggie
6feed32288
htlcswitch: exit early if no adds are in the fwd pkg
This lead to the case that we would always record a HTLC
two times in the decayed log protection which is not necessary
in the first place.
2025-06-09 09:17:25 +02:00
Olaoluwa Osuntokun
c6d6d4c0b6
Merge pull request #9913 from yyforyongyu/debug-switch
htlcswitch+lntest: add more debug logs
2025-06-06 12:34:40 -07:00
yyforyongyu
26960e36ce
htlcswitch+lntest: add more debug logs 2025-06-06 19:40:35 +08:00
Abdullahi Yunus
f79e6137c1
htlcswitch+channeldb: add htlcidx to fwding log
In this commit we add htlcindex field to the forwardingevent
struct, which is persisted alongside the other event fields.
2025-06-06 12:21:39 +01:00
Oliver Gugger
56d2381f51
htlcswitch+routing: add funding blob to PaymentBandwidth
For certain auxiliary bandwidth checks we need to know the funding blob
that was present when the channel was created.
2025-04-22 21:21:11 +02:00
Oliver Gugger
5fb0f43172
htlcswitch+routing: add htlc blob to ShouldHandleTraffic
Whether we should let the aux bandwidth manager decide what the
bandwidth of a channel is should also depend on whether the HTLC is a
custom HTLC, not just the channel.
2025-04-17 11:52:56 +02:00
Oliver Gugger
cf0e0ff32c
switch: add trace log for circular route detection
Helps with debugging of strict forwarding issues.
2025-04-17 10:53:37 +02:00
Oliver Gugger
7381f4b221
Merge pull request #9687 from GeorgeTsagk/aux-trff-shpr-htlcview
`AuxTrafficShaper.PaymentBandwidth` uses HTLC view
2025-04-17 07:59:00 +02:00
George Tsagkarelis
d0ef248ae2
htlcswitch: add HtlcView as PaymentBandwidth argument
In order to get more precise bandwidth reports, we also need to provide
this method with the latest htlc view. Since aux data is committed to in
the channel commitment, some uncommited HTLCs may not be accounted for,
so we need to manually provide them via the HTLC view.
2025-04-14 15:42:28 +02:00
ziggie
490347b056
multi: update walletdb package 2025-04-09 18:47:53 +02:00
yyforyongyu
5a72d5258f
htlcswitch+itest: catch link quit signal when processing hodlQueue
This commit makes sure when processing resolutions, e.g, settling
invoices, when the link is already broken, the process would exit with
an error. This fixes the issue we found in the itest, where an
unexpected empty remote pending commitment was created although the
remote peer is already offline.
2025-03-21 03:25:24 +08:00
yyforyongyu
be4c4cc8ff
multi: improve logging 2025-03-21 03:24:26 +08:00
Olaoluwa Osuntokun
bf3007a2ce multi: thread thru RPC caller context from CloseChannel 2025-03-18 11:44:20 -05:00
Olaoluwa Osuntokun
01382f4c2a htlcswitch: change LinkDirection to be a type alias
In this commit, we change LinkDirection to be a type alias. This makes
creating wrapper structs/interfaces easier, as we don't need to leak
htlcswitch.LinkDirection, instead we can accept a bool.
2025-03-18 11:44:20 -05:00
Oliver Gugger
dac5de5ce9
htlcswitch+routing: return IsHandled from AuxBandwidth
To make it more clear whether the external traffic shaper is handling a
channel or not, we return an explicit boolean.
2025-03-13 12:26:50 -05:00
Oliver Gugger
1227eb1cce
Merge pull request #9491 from ziggie1984/closechannel-rpc
Allow coop closing a channel with HTLCs on it via lncli
2025-02-21 05:05:53 -06:00
ziggie
f994c2cb9f
htlcswitch: fix log output 2025-02-20 17:43:18 +01:00
ziggie
9382fcb801
multi: fix debug log 2025-02-20 10:44:19 +01:00
ziggie
17e37bd7c2
multi: introduce new traffic shaper method.
We introduce a new specific fail resolution error when the
external HTLC interceptor denies the incoming HTLC. Moreover
we introduce a new traffic shaper method which moves the
implementation of asset HTLC to the external layers.
Moreover itests are adopted to reflect this new change.
2025-01-29 09:59:02 +01:00
Elle Mouton
950194a2da
htlcswitch+go.mod: use updated fn.ContextGuard
This commit updates the fn dep to the version containing the updates to
the ContextGuard implementation. Only the htlcswitch/link uses the guard
at the moment so this is updated to make use of the new implementation.
2025-01-11 06:17:43 +02:00
yyforyongyu
1d53e7d081
multi: improve loggings 2024-12-20 17:54:03 +08:00
yyforyongyu
944f16255a
htlcswitch: handle nil circuit properly when settling
We have two sources which can call `handlePacketSettle`, either through
the link's `<-s.htlcPlex`, or the `<-s.resolutionMsgs`, which means the
`closeCircuit` could be call twice. Previously we already caught this
case inside `closeCircuit`, in that we would return a nil circuit upon
seeing `ErrUnknownCircuit`, indicating the circuit was removed. However,
we still need to account the case when the circuit is the process of
being closed, which is now fixed as we will ignore when seeing
`ErrCircuitClosing`.
2024-12-16 15:58:23 +08:00
Olaoluwa Osuntokun
fb429d658b
Merge pull request #9330 from ProofOfKeags/update/fn2
multi: update to fn v2
2024-12-09 12:56:23 +01:00
Oliver Gugger
86b3be71fe
multi: thread through and use AuxTrafficShaper 2024-12-05 12:39:34 +01:00
Oliver Gugger
a2e78c3984
htlcswitch: thread through packet's inbound wire records
For calculating the available auxiliary bandwidth of a channel, we need
access to the inbound custom wire records of the HTLC packet, which
might contain auxiliary information about the worth of the HTLC packet
apart from the BTC value being transported.
2024-12-05 12:39:33 +01:00
Oliver Gugger
117c6bc781
multi: move routing.TlvTrafficShaper => htlcswitch.AuxTrafficShaper
With this commit we move the traffic shaper definition from the routing
package to the HTLC switch package as a preparation for being able to
use it there as well.
At the same time we rename it to AuxTrafficShaper to be more in line
with the other auxiliary components.
2024-12-05 12:39:33 +01:00