Commit Graph

340 Commits

Author SHA1 Message Date
Olaoluwa Osuntokun
7b56b67f34
Merge pull request #6546 from carlaKC/bolts-950-warningmessage
lnwire/peer: add ability to read + log peer warning messages
2022-06-30 16:56:20 -07:00
Carla Kirk-Cohen
99828b8ebb
multi: add ability to read warning messages and log on link level
Warning messages are intended to add "softer" failure modes for peers,
so to start with we simply log the warnings sent to us. While we "may"
disconnect from the peer according to the spec, we start with the least
extreme option (which is also not a change in behavior because
previously we'd just log that we received an unknown odd message).
2022-05-16 13:51:31 -04:00
eugene
87a486f1f9
htlcswitch: remove synchronous link handoff, special-case keystone err
This allows Switch-initiated payments to be failed back if they don't
make it into a commitment. Prior to this commit, a Switch-initiated
HTLC could get "lost" meaning the circuit wouldn't get deleted except
if conditions were "right" and the network result store would never
be made aware of the HTLC's fate. Switch-initiated HTLC's are now
passed to the link's mailbox to ensure they can be failed back.

This change also special-cases the ErrDuplicateKeystone error from
OpenCircuits(...) so that callers of updateCommitTx() in the link
don't send an Error to the peer if they encounter the keystone error.
With the first async change, the keystone error should now always
be recoverable.
2022-05-11 13:49:37 -04:00
Olaoluwa Osuntokun
0ec88b5346
Merge pull request #6347 from yyforyongyu/5388-rm-revc-log
lnwallet+channeldb: store minimal info in revocation log bucket
2022-05-05 15:52:59 -07:00
Tommy Volk
5ae2ce984e multi: typo fixes [skip ci] 2022-05-03 20:55:40 +00:00
yyforyongyu
22d98ca6d5
multi: use new revocation log when creating breach retribution
This commit changes the `NewBreachRetribution` to use the new revocation
log format, while maintaining the compatibilty to use an older
revocation log format. Unit tests have been added to make sure a breach
retribution can be created in both log formats.

This also means the watch tower needs to pass the relevant commit tx at
its backup height when creating the breach retribution during backing
up. This is achieved by recording the current remote commitment state
before advancing the remote commitment chain.
2022-04-20 01:18:14 +08:00
yyforyongyu
acde626ac9
lnwallet+htlcswitch: remove the redundant param in OweCommitment
This commit removes the bool param found in OweCommitment, which we
only ever use `true`.
2022-04-20 01:18:12 +08:00
yyforyongyu
13ade7e9ce
htlcswitch+lnwallet: add trace logs for tickers 2022-03-24 10:01:41 +08:00
Joost Jager
ae314ec794
htlcswitch: add an always on mode to interceptable switch
Co-authored-by: Juan Pablo Civile <elementohb@gmail.com>
2022-03-17 17:39:37 +01:00
Oliver Gugger
7dfe4018ce
multi: use btcd's btcec/v2 and btcutil modules
This commit was previously split into the following parts to ease
review:
 - 2d746f68: replace imports
 - 4008f0fd: use ecdsa.Signature
 - 849e33d1: remove btcec.S256()
 - b8f6ebbd: use v2 library correctly
 - fa80bca9: bump go modules
2022-03-09 19:02:37 +01:00
Olaoluwa Osuntokun
a47da0a990
Merge pull request #6246 from Crypt-iQ/settle_pipeline_check
htlcswitch: only pipeline settle if add is locked-in
2022-03-02 17:07:14 -08:00
eugene
028dec80cb
htlcswitch: only pipeline settle if add is locked-in
The counter-party shouldn't be doing this anyways as they would be
giving away a preimage for free. Them doing this would bork their
own channel due to open circuits not getting trimmed on startup.
Removing this faulty behavior also makes it easier to reason about
the circuit logic.
2022-02-25 12:07:17 -05:00
eugene
8607e8c28a
multi: reliable hand-off from htlcswitch to contractcourt
This is achieved by changing the 1-way handoff to a 2-way handoff
with a done channel.
2022-02-24 13:35:15 -05:00
Oliver Gugger
895a2e497b
multi: formatting and comment fixes 2022-02-10 11:02:02 +01:00
carla
990dda4b18
multi: thread bandwidth check amount down to MayAddOutgoingHtlc
Pass htlc amount down to the channel so that we don't need to rely
on minHtlc (and pad it when the channel sets a 0 min htlc). Update
test to just check some sane values since we're no longer relying
on minHtlc amount at all.
2021-10-19 09:50:51 +02:00
Elle Mouton
f667683e6c
htlcswitch: respect minimum relay fee
When channels fee rates are being considered for an update, the minimum
relay fee should also be considered.
2021-10-05 18:30:41 +02:00
eugene
0ce6194e1e
htlcswitch: extend ChannelLink iface with dustHandler iface
This allows the Switch to determine the dust exposure of a certain
channel and allows the link to set the feerate of the mailbox given
a fee update.
2021-09-30 13:44:34 -04:00
eugene
0b24603aef
htlcswitch: extend Mailbox iface with dust, fee methods
This commit extends the Mailbox interface with the SetDustClosure,
SetFeeRate, and DustPackets methods. This enables the mailbox to
report the dust exposure to the Switch when the Switch decides whether
to forward a dust packet. The dust is counted from the time an Add is
introduced via AddPacket until it is removed via AckPacket. This can
lead to some packets being counted twice before they are signed for,
but this is a trade-off between accuracy and simplicity.
2021-09-30 13:44:34 -04:00
eugene
b2e90480ed
htlcswitch: extend ChannelLink interface with ShutdownIfChannelClean
This allows a caller to ensure to optimistically shut down the link
if the channel is clean. If the channel is not clean, an error is
returned and the link continues functioning as normal. The caller
should also call RemoveLink to ensure that the link isn't seen as
usable within the switch.
2021-09-13 13:29:50 -04:00
Joost Jager
09386213be
htlcswitch: log link message with channel point
In lnd, log messages about channels are generally logged with a
reference to their channel point rather than the short channel id.
Channel point is reorg-resistant and also easier to look up in for
example a block explorer.

In the link however, all log messages are accompanied by short channel
id. This makes it difficult to grep a log for all channel activity. The
PEER message for example which are often crucial to analyse, are logged
with channel points.

This commit modifies the link logging to also use channel points.
2021-08-16 08:24:35 +02:00
eugene
051cd8793a
htlcswitch: introduce and embed packetHandler interface in ChannelLink
This will allow separating the now-private *htlcPacket methods from
the publicly-used ChannelLink interface methods.
2021-08-10 17:15:51 -04:00
eugene
6c6e353597
htlcswitch+peer: pass BestHeight to ChannelLinkConfig
This allows non-test usages of ChannelLinkConfig to omit the raw
htlcswitch.Switch pointer.
2021-08-10 17:15:49 -04:00
Olaoluwa Osuntokun
ccd7421488
Merge pull request #5487 from C-Otto/fix-5367
htlcswitch: log amount for failures
2021-07-09 14:35:31 -07:00
Olaoluwa Osuntokun
db3819fcef
Merge pull request #5236 from offerm/preimage-to-settleevent
feature: expose preimage in forward+settle event
2021-07-09 14:35:11 -07:00
Carsten Otto
0396220b71 htlcswitch: log amount for failures
fixes #5367
2021-07-08 20:33:00 +02:00
carla
5d717cb039
multi: surface may add outgoing hltc 2021-06-22 13:56:08 +02:00
offerm
2c4dbfa19f feature: expose preimage in forward+settle event
Until now, clients of SubscribeHTLCEvents didn't have access to the settled preimage. The API allows to intercept forward event and to be updated on forward events however the forward+settle event does not include the payment preimage. This pr changes allows it.
2021-06-15 22:01:24 +03:00
Carsten Otto
4b4d34fcce htlcswitch: change errors to warnings
for issues caused by bogus incoming HTLC data
2021-05-23 19:17:59 +01:00
Carsten Otto
2ae82df2fa htlcswitch: fix typo 2021-05-23 19:17:59 +01:00
Carsten Otto
378bc08e16 htlcswitch: add detailed "insufficient bandwidth" log message
fixes #5250
2021-05-23 19:17:59 +01:00
Carsten Otto
ac4742c2c5 htlcswitch: fix documentation 2021-05-23 19:17:59 +01:00
Carsten Otto
788c94bdcd htlcswitch: fix log message 2021-05-23 19:17:59 +01:00
Johan T. Halseth
0fd76e53b8
multi: cap anchors feerate at configurable maximum
This commit caps the update fee the initiator will send when the anchors
channel type is used. We do not limit anything on the receiver side.

10 sat/vbyte is the current default max fee rate we use. This should be
enough to ensure propagation before anchoring down the commitment
transaction.
2020-12-15 19:54:50 +01:00
yyforyongyu
bf036f2665
htlcswitch: close the updateFeeTimer properly 2020-12-04 23:08:50 +08:00
Conner Fromknecht
0d0f22aacb
link+peer: thread anchor tower client to link 2020-11-25 15:39:14 -08:00
Conner Fromknecht
dd325f04d2
watchtower/wtclient: parameterize backup task with channel type 2020-11-25 15:04:12 -08:00
Johan T. Halseth
87cdf3b797
htlcswitch/link: revert borking channels on received Errors
Since it turned out borking channels on every received error could cause
us to bork channels in case of a sync error with C-lightning, we revert
this for now.
2020-11-23 14:42:41 +01:00
Johan T. Halseth
dde6763cef
htlcswitch/link: set PermanentFailure in case of remote error 2020-11-04 11:16:22 +01:00
eugene
ea467783e9 htlcswitch+peer: remove fwd pkgs once before tick, bump timer to 1hr
This commit changes the logic when garbage collecting forwarding
packages such that they are removed once when the function is called,
and then again upon subsequent ticks. This allows us to bump the
peer timer to 1 hour to limit the number of db transactions happening
in lnd. The forwarding packages need to be removed initially as
otherwise a flappy node will never have them garbage collected.
2020-08-31 20:52:51 -04:00
eugene
62e19185f1 htlcswitch+channeldb: single tx for removing fwdpkgs
This commit changes RemoveFwdPkg to RemoveFwdPkgs so that a single
tx is used instead of N where N is the number of fwd pkgs to remove.
2020-08-31 20:52:51 -04:00
Joost Jager
2903505164
htlcswitch: expose custom records on intercepted packet 2020-06-27 11:00:46 +02:00
Roei Erez
1a6701122c htlcswitch: change ForwardPackets to return error
As part of the preparation to the switch interceptor feature, this
function is changed  to return error instead of error channel that
is closed automatically.
Returning an error channel has become complex to maintain and
implement when adding more asynchronous flows to the switch.
The change doesn't affect the current behavior which logs the
errors as before.
2020-06-18 12:48:21 +03:00
Joost Jager
c325bf8c57
htlcswitch: sync link hand-off
This commit extends the link with a new synchronous delivery point for
local UpdateAddHTLC messages. The switch method SendHTLC is updated to
use this delivery point and thereby becomes a synchronous call.

For MPP payments, synchronous hand-off is important. Otherwise the next
pathfinding round could start without the channel balance updated yet.
2020-05-20 08:03:48 +02:00
Joost Jager
de2df5606a
htlcswitch: extract handleDownstreamUpdateAdd in link
To be able to call just the UpdateAdd logic for synchronously handled
local adds in a later commit.
2020-05-20 08:03:46 +02:00
Joost Jager
55930df70d
htlcswitch: update commit tx per downstream msg type
Unroll common code to allow splitting in separate handlers per message
type.
2020-05-20 08:03:44 +02:00
Joost Jager
b559811bf5
htlcswitch: extract updateCommitTxOrFail in link
Deduplicate code and prepare for further split of
handleDownstreamPkt.
2020-05-20 08:03:42 +02:00
Andras Banki-Horvath
556e3525ea misc: fix error formatting in multiple files 2020-04-24 19:15:08 +02:00
Conner Fromknecht
b467f549b7
htlcswitch/link: return error from AddPacket 2020-04-14 22:34:59 -07:00
Conner Fromknecht
ec1b8d874d
htlcswitch/link: add pending commit ticker for stall detection
This commit adds a PendingCommitTicker to the link config, which allows
us to control how quickly we fail the link if the commitment dance
stalls. Now that the mailbox has the ability to cancel packets, when the
link fails it will reset the mailbox packets on exit, forcing a
reevaluation of the HTLCs against their mailbox expiries.
2020-04-14 10:51:30 -07:00
Conner Fromknecht
6fca22be2b
htlcswitch/link: use return instead of break out
There is no clean up logic after the loop, done purely to improve
clarity.
2020-04-14 10:50:45 -07:00