Commit Graph

513 Commits

Author SHA1 Message Date
Joost Jager
206d93d856
htlcswitch/test: test zero value for outbound cltv reject delta 2019-04-05 11:36:18 +02:00
Joost Jager
1b2816006f
htlcswitch/test: align test invoice cltv expiry 2019-04-05 11:36:16 +02:00
Joost Jager
af7d0e5ff5
htlcswitch/test: convert TestChannelLinkSingleHopPayment to two hop network 2019-04-05 11:36:13 +02:00
Joost Jager
037913fd28
link: rewrite height comparisons without subtraction
Prevent the case where a uint32 wrap around could happen.
2019-04-05 11:36:10 +02:00
Joost Jager
ab4da0f53d
cnct: define separate broadcast delta for outgoing htlcs
This commits exposes the various parameters around going to chain and
accepting htlcs in a clear way.

In addition to this, it reverts those parameters to what they were
before the merge of commit d1076271456bdab1625ea6b52b93ca3e1bd9aed9.
2019-04-05 11:36:07 +02:00
Olaoluwa Osuntokun
893cff60c4
Merge pull request #2839 from joostjager/htlc-expiry-check
link: increase expiry grace delta for exit hop and forwarded htlcs
2019-04-01 18:15:56 -07:00
Olaoluwa Osuntokun
1afec1342b
htlcswitch: update syncChanStates for new ChanSyncMsg API 2019-03-28 17:53:56 -07:00
Johan T. Halseth
59e3390f6c
Merge pull request #2750 from cryptagoras/patch-1
htlcswitch/switch: log target node on insufficient cap error
2019-03-27 15:10:08 +01:00
Joost Jager
cd535b9401
link: increase expiry grace delta
This commit increase the expiry grace delta to a value above the
broadcast delta. This prevents htlcs from being accepted that would
immediately trigger a channel force close.

A correct delta is generated in server.go where there is access to
the broadcast delta and passed via the peer to the links.

Co-authored-by: Jim Posen <jim.posen@gmail.com>
2019-03-26 18:42:00 +01:00
Joost Jager
e6fbbaa1dc
link: also check expiry grace delta for forwarded htlcs
Previously there was no minimum remaining blocks requirement on
forwarded htlcs, which may cause channel arbitrator to force
close the channel directly after forwarding the htlc.

Co-authored-by: Jim Posen <jim.posen@gmail.com>
2019-03-26 18:41:41 +01:00
cryptagoras
a50428ca96 htlcswitch/switch: log target node on insufficient cap error 2019-03-25 18:25:58 +02:00
Joost Jager
0823c79e4e
htlcswitch/test: hodl invoice test 2019-03-15 10:09:20 +01:00
Joost Jager
32f2b047e8
htlcswitch: hodl invoice
This commit modifies the invoice registry to handle invoices for which
the preimage is not known yet (hodl invoices). In that case, the
resolution channel passed in from links and resolvers is stored until we
either learn the preimage or want to cancel the htlc.
2019-03-15 10:09:17 +01:00
Joost Jager
1f41a2abce
htlcswitch: abtract invoice from link
This commit detaches signaling the invoice registry that an htlc was
locked in from the actually settling of the htlc.

It is a preparation for hodl invoices.
2019-03-15 10:09:15 +01:00
Joost Jager
aeb35d9898
htlcswitch/test: use real invoice registry with temp db as mock
In further commits the behaviour of invoice registry becomes more
intrinsically connected to the link. This commit prepares for that by
allowing link and registry to be tested as a single unit.
2019-03-15 10:09:12 +01:00
Joost Jager
e464ed18c7
htlcswitch/test: make unknown hash test independent of mock
In the TestChannelLinkMultiHopUnknownPaymentHash test, a preimage was
modified to trigger an unknown payment hash failure. The way the mock is
implemented, it would take the hash of that modified preimage and store
it. It basically stores a completely different invoice. For this test,
it is just as good to store no invoice at all.
2019-03-15 10:09:09 +01:00
Joost Jager
c23bb5b3f1
htlcswitch: extract settle invoice into method 2019-03-15 10:09:03 +01:00
Joost Jager
19f79613df
channeldb: store hold invoice 2019-03-15 10:08:55 +01:00
Joost Jager
4141773e90
htlcswitch: resolve invoice cancelation race condition
Previously it could happen that an invoice was open at the time of the
LookupInvoice call, the htlc was settled because of that, but when the
SettleInvoice call was made eventually, it would fail because the
invoice was canceled in the mean time. The htlc would then be settled,
but the invoice not marked as such.
2019-03-15 10:08:46 +01:00
Joost Jager
eb598ec7a4
htlcswitch: extract exit hop processing to method 2019-03-15 10:08:43 +01:00
Joost Jager
9643b45dbc
htlcswitch/test: move preimage cache to server level
In this commit the preimage cache is instantiated on the mock server
level where it belongs. Previously it was a cache shared across all mock
servers.
2019-03-15 10:08:40 +01:00
Conner Fromknecht
f39edd8000
peer: add SendMessageLazy 2019-03-05 17:08:22 -08:00
Valentine Wallace
f0e668974e htlcswitch/link: verify an htlc is not too large in HtlcSatifiesPolicy
Before forwarding an HTLC, ensure that the amount to forward
including fees does not exceed the max HTLC set for the channel
link.
2019-02-21 18:45:37 -08:00
Valentine Wallace
833c31eaca htlcswitch/link_test+test_utils: add max htlc to forwarding policies 2019-02-21 18:39:32 -08:00
Valentine Wallace
20b3114100 htlcswitch+lnwallet+peer: default max htlc in fwding policy of new chans
In this commit, we set a default max HTLC in the forwarding
policies of newly open channels.

The ForwardingPolicy's MaxHTLC field (added in this commit)
will later be used to decide whether an HTLC satisfies our policy before
forwarding it.

To ensure the ForwardingPolicy's MaxHTLC default matches the max HTLC
advertised in the ChannelUpdate sent out for this channel,  we also add
a MaxPendingAmount() function to the lnwallet.Channel.
2019-02-21 18:39:32 -08:00
Olaoluwa Osuntokun
cbe0bf6a22
Merge pull request #2501 from cfromknecht/batch-preimage-writes
htlcswitch: batch preimage writes/consistency fix
2019-02-21 17:00:00 -08:00
Conner Fromknecht
3428fde5ab
htlcswitch/link_test: batch preimage write test 2019-02-19 17:06:28 -08:00
Conner Fromknecht
76cecb1396
htlcswitch/link: batch write to preimage cache
This commit makes use of the batched AddWitness
method of the WitnessCache, in order to avoid
performing one write for each accepted preimage.

Additionally, this fixes an existing hole in the
consistency guarantees since the batched writes
are now guaranteed to take place before accepting
the next CommitSig. Previously, these writes were
processed in an unsynchronized go routine that
could be delayed arbitrarily long before being
executed.

With this change, the async_payments_benchmarks
actually shows a slight improvement in
performance, presumably because we no longer do
an individual write per preimage, even though
the execution is now explicitly in the critical
path. There is likely also a marginal performance
improvement from the reduction in goroutine
overhead.
2019-02-19 17:06:15 -08:00
Conner Fromknecht
29f07a58cb
cnct+lnwl+hswc: use lntypes.Preimage for witness beacon 2019-02-19 17:06:00 -08:00
Conner Fromknecht
30f61b7630
multi: make AddPreimage variadic, optimistically compute key
In this commit, we modify the WitnessCache's
AddPreimage method to accept a variadic number
of preimages. This enables callers to batch
preimage writes in performance critical areas
of the codebase, e.g. the htlcswitch.

Additionally, we lift the computation of the
witnesses' keys outside of the db transaction.
This saves us from having to do hashing inside
and blocking other callers, and limits extraneous
blocking at the call site.
2019-02-19 17:05:04 -08:00
Wilmer Paulino
abdd01ed9a
ticker+htlcswitch: rename Mock -> Force 2019-02-12 16:05:24 -08:00
Joost Jager
077852cd4e
htlcswitch/test: test canceled invoice 2019-02-06 07:29:35 +01:00
Joost Jager
f80fb286d8
htlcswitch/test: add two hop network 2019-02-06 07:29:32 +01:00
Joost Jager
524d2465e0
htlcswitch/test: extract generic hop network 2019-02-06 07:29:29 +01:00
Joost Jager
9cac0efab7
htlcswitch/test: create preparePayment function 2019-02-06 07:29:26 +01:00
Joost Jager
e7907e0e7c
htlcswitch/test: add waitForPaymentResult helper function 2019-02-06 07:29:24 +01:00
Joost Jager
afd2d69906
htlcswitch/test: convert makePayment into function 2019-02-06 07:29:21 +01:00
Joost Jager
1b87fbfab2
invoices+htlcswitch+lnrpc: cancel invoice 2019-02-06 07:29:18 +01:00
Valentine Wallace
bdd8ce14c9 switch: notify the ChannelNotifier on newly active/inactive channels. 2019-02-05 18:17:54 -08:00
Valentine Wallace
f6cffa8f4b htlcswitch/link: add ChannelPoint() to retrieve the channel outpoint.
This function will be used in the switch to retrieve the channel point for a link,
allowing the switch to retrieve individual channels from the database.
2019-02-05 18:17:54 -08:00
Joost Jager
bacd92418a
invoices: use lntypes.Hash and lntypes.Preimage
Previously chainhash.Hash was used, which converts to/from string in
reversed format. Payment hashes and preimages are supposed to be
non-reversed.
2019-02-01 09:42:29 +01:00
Joost Jager
9e012ecc93
multi: move Input interface and related code
This commit is a step to split the lnwallet package. It puts the Input
interface and implementations in a separate package along with all their
dependencies from lnwallet.
2019-01-31 13:25:33 +01:00
orbitalturtle
08750f180b multi: deprecate IncorrectHtlcAmount onion error
In this commit, we deprecate the `IncorrectHtlcAmount` onion error.
We'll still decode this error to use when retrying paths, but we'll no
longer send this ourselves. The `UnknownPaymentHash` error has been
amended to also include the value of the payment as well. This allows us
to worry about one less error.
2019-01-29 18:21:13 -08:00
Olaoluwa Osuntokun
9c59ac4383
Merge pull request #2397 from halseth/reject-commitment-expected-fee-reset-bug
[bugfix] Process fee updates as any other update message
2019-01-14 17:06:27 -08:00
Wilmer Paulino
b951f06456
multi: move CsvDelay into ChannelConstraints 2019-01-11 16:58:15 -08:00
Conner Fromknecht
6ae77bc3cb
htlcswitch/switch_test: adds HasActiveLink unit test 2019-01-10 16:34:03 -08:00
Conner Fromknecht
164250d1cd
htlcswitch/switch: check EligibleToForward in HasActiveLink
This commit modifies the behavior of the
HasActiveLink method within the switch to
only return true if the link is in the
link index and is eligible to forward
HTLCs.

The prior version returns true whenever
the link is found in the link index,
which may return true for pending
channels that are not actually active.
2019-01-10 16:34:02 -08:00
Johan T. Halseth
480f43f1dc
lnwallet/channel: add lnwire<->PaymentDescriptor FeeUpdate conversion
This commit adds conversion between the lnwire.UpdateFee message and the
new FeeUpdate PaymentDescriptor. We re-purpose the existing Amount field
in the PaymentDescriptor stuct to hold the feerate.
2019-01-10 12:26:33 +01:00
Conner Fromknecht
75ec66d9b3
Merge pull request #1975 from halseth/fwdtrigger-force
[tests] Force tick on FwdEventTicker
2019-01-07 17:46:58 -08:00
Joost Jager
5515713b88
channeldb: convert settled boolean to state
This commit is a preparation for the addition of new invoice
states. A database migration is not needed because we keep
the same field length and values.
2019-01-04 07:53:55 +01:00