Commit Graph

444 Commits

Author SHA1 Message Date
Johan T. Halseth
54a608d09d
htlcswitch+discovery mock: adhere to new lnpeer interface 2018-09-28 09:05:18 +02:00
maurycy
ac24b12bf2
multi: fix various typos in comments 2018-09-07 06:51:49 +02:00
Wilmer Paulino
33dda07b62
htlcswitch: return concrete error from GetLinksByInterface 2018-08-28 20:34:18 -07:00
Olaoluwa Osuntokun
19552b0dbf
htlcswitch+funding+discovery: update mock peers to add new QuitSignal method 2018-08-25 17:30:15 -07:00
Olaoluwa Osuntokun
5cf911a762
Merge pull request #1764 from cfromknecht/isolate-fwdpkg-to-live-links
htlcswitch/link: only resovle+gc fwdpkgs for live channels
2018-08-24 17:42:44 -07:00
Conner Fromknecht
22793e4418
htlcswitch/link_test: increase fwdpkg gc interval
In this commit, we increase the fwdpkg gc interval
to avoid having it conflict with switch tests that
inspect forwarding packages. The current timeout is
a little too short on travis, and sporadically fails
TestChannelLinkCleanupSpuriousResponses, which was
added recently.
2018-08-24 12:54:24 -07:00
Conner Fromknecht
9c5c1d0cb5
htlcswitch/switch: prevent panic for unknown error decryptor 2018-08-22 10:26:27 -07:00
Conner Fromknecht
b59fea460a
htlcswitch/switch: make local response handling async
This commit moves the logic handling responses to
locally-initiated payments to be asynchronous. The
reordering of operations into handleLocalDispatch
brings a serious performance burden to the switch's
main event loop. However, the at-most once semantics
of circuit map and idempotency of cleanup methods
allows concurrent operations to run in parallel.

Prior to this commit, the async_payments_benchmark
would timeout due to the forcibly serial nature of
the prior design. With this change, there is no
perceptible difference in the benchmark OMM, even
though we've added two extra db calls.
2018-08-22 10:26:26 -07:00
Conner Fromknecht
5dc2a4a4b8
htlcswitch/control_tower: use one db txn for transitions
Composes the new payment status helper methods such that
we only require one db txn per state transition. This
also allows us to remove the exclusive lock from the
control tower, and enable more concurrent requests.
2018-08-21 19:23:25 -07:00
Conner Fromknecht
2dd8f07014
htlcswitch/switch: use non-strict PaymentControl 2018-08-21 19:23:25 -07:00
Conner Fromknecht
2027444a56
htlcswitch/control_tower_test: test strict and non-strict ctrltwrs 2018-08-21 19:23:25 -07:00
Conner Fromknecht
98d2ffbfd0
htlcswitch/control_tower: add strict mode toggling 2018-08-21 19:23:24 -07:00
Conner Fromknecht
971ae3c744
htlcswitch/control_tower_test: move from switch_control_test 2018-08-21 19:23:24 -07:00
Conner Fromknecht
8b2237fc1d
htlcswitch/control_tower: move from switch_control 2018-08-21 19:23:24 -07:00
Conner Fromknecht
3f0dfd4e4b
htlcswitch/switch_control_test: extend tests + godocs 2018-08-21 19:23:24 -07:00
Conner Fromknecht
875128539c
htlcswitch/switch_control: expand godocs and add ErrUnknownPaymentStatus 2018-08-21 19:23:24 -07:00
Conner Fromknecht
9b52c510e9
htlcswitch/mock: remove new line to satisfy linter 2018-08-21 19:23:24 -07:00
Conner Fromknecht
d6083e0d66
htlcswitch/switch: reorder persistent calls and app ntfn...
for Settle/Fail responses.
2018-08-21 19:23:24 -07:00
Vadym Popov
033fd3c83d
htlcswitch: add test for integrated control tower 2018-08-21 19:23:22 -07:00
Vadym Popov
21fc7aa829
htlcswitch: integration of control tower to htlc switch 2018-08-21 19:23:22 -07:00
Vadym Popov
350287779b
htlcswitch: control tower test of payment statuses transitions 2018-08-21 19:23:22 -07:00
Vadym Popov
a3d32be808
htlcswitch: control tower implementation 2018-08-21 19:23:22 -07:00
Conner Fromknecht
211a0299e9
htlcswitch/link: only resovle+gc fwdpkgs for live channels 2018-08-21 19:10:16 -07:00
Olaoluwa Osuntokun
f028eaa152
Merge pull request #1698 from cfromknecht/switch-fwdpkg-cleanup
[htlcswitch] fwdpkg cleanup
2018-08-21 18:56:15 -07:00
Conner Fromknecht
5d131e5164
htlcswitch/link_test: assert delete spurious response 2018-08-21 17:13:58 -07:00
Conner Fromknecht
6a8507cfb5
htlcswitch/switch: ignore pending/local responses on reforward 2018-08-21 17:13:58 -07:00
Conner Fromknecht
81b4af2ec8
htlcswitch/link: cleanup spurious fail/settle responses 2018-08-21 17:13:58 -07:00
Conner Fromknecht
4e093a6cd2
htlcswitch/switch: shutdown links concurrently 2018-08-20 22:05:05 -07:00
Wilmer Paulino
44e97ee72f htlcswitch: remove no longer needed destNode field in htlcPacket 2018-08-20 21:04:52 -07:00
Wilmer Paulino
7535371238 htlcswitch: implement strict forwarding for locally dispatched payments
In this commit, we address an issue that could arise when using the
SendToRoute RPC. In this RPC, we specify the exact hops that a payment
should take. However, within the switch, we would set a constraint for
the first hop to be any hop as long as the first peer was at the end of
it. This would cause discrepancies when attempting to use the RPC as the
payment would actually go through another hop with the same peer. We fix
this by explicitly specifying the channel ID of the first hop.

Fixes #1500.
Fixes #1515.
2018-08-20 21:04:47 -07:00
Conner Fromknecht
53b58a1eb3
htlcswitch/mock: drop messages if link is not online
In this commit, we modify the readHandler w/in
the mock peer to drop messages if it is unable
to find the target link. This has led to observed
race conditions related to removing a link and still
attempting to deliver messages. By removing this,
the readHandler shouldn't fail the test as a result.
2018-08-20 19:23:15 -07:00
Conner Fromknecht
f636ff8b4a
htlcswitch/test_utils: bump fwdpkg gc timeout to 15s
This commit increases the fwdpkg garbage collection
interval to 15s, to mitigate the likelihood of it
interfering with our unit tests related to fwdpkgs.
2018-08-20 18:48:49 -07:00
Conner Fromknecht
4f2137eafc
htlcswitch/switch: set SourceRef of failed packets 2018-08-20 18:47:03 -07:00
Conner Fromknecht
cd7e4f98c0
htlcswitch/link_test: check fwdpkg cleanup for failed adds 2018-08-20 18:46:59 -07:00
Conner Fromknecht
3fb6a310f8
htlcswitch/link: remove circuit deletion forgiveness
This commit removes the concept of "circuit deletion
forgivness" from the link. This was originally
implemented due to the strict semantics of the original
DeleteCircuit implementation, which would fail if we tried
to delete unknown circuits. Forgivness is used on startup
to ignore this error in case the circuits had already been
deleted before shutting down.

Now that the circuit deletion has been relaxed, this
behavior is no longer necessary, as requests to delete
unknown (or previously deleted) circuits will be ignored.

This is necessary for future changes regarding switch
cleanup, which may attempt to cleanup already deleted
circuits.
2018-08-20 16:45:42 -07:00
Conner Fromknecht
78439416c0
htlcswitch/circuit_test: test for relaxed DeleteCircuits
Modify unit tests to expect success when removing
already-deleted circuits, as well as test that extra
circuit deletions are ignored.
2018-08-20 16:45:42 -07:00
Conner Fromknecht
a213810563
htlcswitch/circuit_map: prune stray locally-initiated keystones 2018-08-20 16:45:42 -07:00
Conner Fromknecht
c2055d4a9e
htlcswitch/circuit_map: relax circuit deletion
Previously, we would only allow deletion of circuits if all circuit keys
were found in the pending map.

In this commit, we relax this to allow for deletion of any circuits
that are found pending, and ignore those that are not found. This
is a preliminary step to cleaning up duplicate forwards that get caught
by the switch. It also allows us to gracefully handle any nodes that
are still afflicted by the split mailbox issue.
2018-08-20 16:45:42 -07:00
Conner Fromknecht
0372bf9319
htlcswitch/circuit_map: prevent spewing secp curve in trace
Replaces the log statement in CommitCircuits so that
it prints the circuit key of the incoming channel. This way
we avoid spewing the secp curve stored in the ErrorEncrypter.
2018-08-20 16:45:42 -07:00
Conner Fromknecht
48b616629a
htlcswitch/switch: remove unnecessary defer closure 2018-08-18 20:19:17 -07:00
Conner Fromknecht
9047eee2f1
htlcswitch/switch: adds concrete ErrSwitchExisting 2018-08-18 20:19:17 -07:00
Conner Fromknecht
0d49a60924
htlcswitch/switch: remove go-errors pkg 2018-08-18 20:19:17 -07:00
Johan T. Halseth
887722f38f
htlcswitch/switch: add method HasActiveLink 2018-08-17 23:24:12 +02:00
Olaoluwa Osuntokun
7a113d469b
Merge pull request #1551 from cfromknecht/switch-revert-replace-link
[htlcswitch]: revert replace link, ensure removed links are stopped
2018-08-13 21:44:42 -07:00
Conner Fromknecht
f84cd14b12
htlcswitch/switch: permit link shutdown mid-forwarding
In this commit, we thread through a link's quit channel into
routeAsync, the primary helper method allowing links to send
htlcPackets through the switch. This is intended to remove
deadlocks from happening, where the link is synchronously
blocking on forwarding packets to the switch, but also
needs to shutdown.
2018-08-10 11:42:26 -07:00
Conner Fromknecht
0fef1c71fe
htlcswitch/link: pass link quit to ForwardPackets 2018-08-10 11:42:26 -07:00
Conner Fromknecht
d08003b285
htlcswitch/link_test: adds TestChannelLinkShutdownDuringForward
This commit adds a test that verifies Stop does not block
if the link is concurrently forwarding incoming Adds to
the switch. This test fails prior to the commits that
thread through the link's quit channel.
2018-08-10 11:42:26 -07:00
Conner Fromknecht
11f02de3b3
htlcswitch/link_test: removes unnecessary WaitForShutdown
The new RemoveLink method blocks until the link has
been fully stopped, so we no longer need to wait
for it explicitly.
2018-08-10 11:42:25 -07:00
Conner Fromknecht
b507d265b4
htlcswitch/link: only update contract signals on start if live link 2018-08-10 11:42:25 -07:00
Conner Fromknecht
c78e81d32b
htlcswitch/switch: synchronous stop of links after removal 2018-08-10 11:42:25 -07:00