Commit Graph

872 Commits

Author SHA1 Message Date
Joost Jager
7cd7cef6c6
htlcswitch: fix duplicate close
The decayed log database opening and closing is managed at a higher
level in config_builder.go.
2022-01-10 08:42:32 +01:00
Oliver Powell
1fe6a3cf9b htlcswitch: fix hint in link tests [skip ci]
Fixes #6020.
2021-11-23 16:04:12 +02:00
eugene
ee2162b5d2
htlcswitch: remove 5 second timeout for data race unit tests 2021-10-26 10:32:13 -04:00
Wilmer Paulino
8cfb53f64a
lnwallet: support transactions and scripts for new commitment type
This commit modifies the channel state machine to be able to derive the
proper commitment and second-level HTLC output scripts required by the
new script-enforced leased channel commitment type.
2021-10-19 18:30:32 -07: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
Oliver Gugger
692ea25295
Merge pull request #5642 from guggero/in-memory-graph
In-memory graph cache for faster pathfinding
2021-10-04 11:20:23 +02:00
Olaoluwa Osuntokun
32fa48df7d
Merge pull request #5770 from Crypt-iQ/dust_threshold_0619
lnwallet+htlcswitch: make Switch dust-aware
2021-09-30 20:20:19 -07:00
Olaoluwa Osuntokun
dd7bfa0c4a
Merge pull request #5650 from Roasbeef/go-1-17
build: upgrade all CI+build infra to Go 1.17
2021-09-30 19:12:29 -07:00
eugene
702b3a3258
multi: introduce config-level DustThreshold for defining threshold 2021-09-30 13:44:35 -04:00
eugene
3897baff0a
htlcswitch: call evaluateDustThreshold in SendHTLC, handlePacketForward
This commit makes SendHTLC (we are the source) evaluate the dust
threshold of the outgoing channel against the default threshold of
500K satoshis. If the threshold is exceeded by adding this HTLC, we
fail backwards. It also makes handlePacketForward (we are forwarding)
evaluate the dust threshold of the incoming channel and the outgoing
channel and fails backwards if either channel's dust sum exceeds the
default threshold.
2021-09-30 13:44:34 -04: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
Oliver Gugger
0b4e03f5fc
multi: add golang 1.17 compatible build tags
With go 1.17 a change to the build flags was implemented:
https://go.googlesource.com/proposal/+/master/design/draft-gobuild.md

The formatter now automatically adds the forward-compatible build tag
format and the linter checks for them, so we need to include them in our
code.
2021-09-29 17:31:37 -07:00
eugene
49877545ba
htlcswitch: fix flake in TestShutdownIfChannelClean
When Alice receives a CommitSig near the end of the test, the test
assumed that she wouldn't reply with a RevokeAndAck message before
shutdownAssert was called. This led to a test flake. Instead, only
call shutdownAssert after we've received the RevokeAndAck.
2021-09-29 17:04:53 -04:00
Oliver Gugger
15d3f62d5e
multi: use cache for source channels 2021-09-29 17:00:04 +02:00
Andras Banki-Horvath
11cf4216e4
multi: move all channelstate operations to ChannelStateDB 2021-09-29 17:00:03 +02:00
Olaoluwa Osuntokun
7f3c59033b
Merge pull request #5527 from ErikEk/isset-validateconfig
config: sync-freelist being ignored
2021-09-28 20:35:57 -07:00
Olaoluwa Osuntokun
7bde1662e2
multi: move breach arbiter and utxo nursery into contractcourt package
In this commit, we take an initial step towards converting the existing
breach arbiter and utxo nursery logic into contract resolvers by moving
the files as is, into the `contractcourt` pacakge.

This commit is primarily move only, though we had to massage some
interfaces and config names along the way to make things compile and the
tests run properly.
2021-09-27 19:10:31 -07:00
ErikEk
d5463818a8 bbolt sync-freelist ignored 2021-09-27 06:49:56 +01:00
yyforyongyu
995b9a711f
trivial: typo fix 2021-09-23 13:24:15 +08:00
yyforyongyu
3942c7ca02
htlcswitch: clean circuits and keystones for closed channels
In this commit, a new method `cleanClosedChannels` is added and called
when a circuit map is created. This method will delete the payment
circuits and keystones for closed channels.
2021-09-23 13:24:15 +08:00
yyforyongyu
1274e31dfb
htlcswitch: remove unused function in switch 2021-09-23 13:24:14 +08:00
yyforyongyu
22848df07a
htlcswitch: fix docs on LookupCircuit 2021-09-23 13:24:14 +08:00
yyforyongyu
e513057eae
htlcswitch: add docs for circuit bucket hierarchy 2021-09-23 13:22:34 +08:00
yyforyongyu
3d50edf9f8
channeldb: add method to wipe all forwarding packages
This commit adds a method, Wipe, to remove all forwarding packages on
disk for a given channel.
2021-09-23 13:22:33 +08:00
Olaoluwa Osuntokun
ac5f88bae8
Merge pull request #5618 from Crypt-iQ/coop_switch_sync_08092021
multi: optimistically shutdown link during coop close
2021-09-20 18:09:07 -07:00
yyforyongyu
3204e2d74b
multi: add shutdown logs in subservers
This commit adds a simple shutdown to every subserver to assist
debugging.
2021-09-15 19:52:03 +08: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
23a4fad4ac
htlcswitch+peer: CreateAndAddLink in switch, add messageSwitch to peer
This commit allows the peer to be tested without relying on a raw
htlcswitch.Switch pointer. This is accomplished by using a messageSwitch
interface and adding the CreateAndAddLink method to the
htlcswitch.Switch.
2021-08-10 17:15:52 -04:00
eugene
e72468646c
htlcswitch+peer: embed ChannelUpdateHandler in ChannelLink
GetLink, GetLinksByInterface now use ChannelUpdateHandler.
2021-08-10 17:15:52 -04: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
Oliver Gugger
1e27f491c7
multi: make decayed log DB remote compatible
Even though the sphinx router's persistent replay log is not crucial in
the operation of lnd as its state can be re-created by creating a new
brontide connection, we want to make lnd fully stateless and therefore
have the option of not storing any state on disk.
2021-08-04 14:55:53 +02: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
Olaoluwa Osuntokun
6d5ab035c5
Merge pull request #5280 from champo/interceptor_dont_leak_htlcs
htlcswitch: set sourceRef when resolving packets through interceptor
2021-07-01 17:35:26 -07:00
carla
5d717cb039
multi: surface may add outgoing hltc 2021-06-22 13:56:08 +02:00
Olaoluwa Osuntokun
6f051fa5ea
Merge pull request #5248 from joostjager/concurrent-onion
htlcswitch: concurrent onion decoding
2021-06-18 14:08:24 -07: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
Joost Jager
dddf0bc887 htlcswitch: concurrent onion decoding 2021-05-24 20:12:57 +02:00
Joost Jager
94b6f8af5b htlcswitch: extract onion decode function 2021-05-24 20:12:57 +02: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
Olaoluwa Osuntokun
7ab5906093
Merge pull request #5245 from bhandras/kvdb_module
kvdb: make kvdb a top level submodule to allow dependency in other projects
2021-05-13 15:59:20 -07:00