Commit Graph
100 Commits
Author SHA1 Message Date
Johan T. Halseth c1705a28da chanfitness/chaneventstore: stop ticker after goroutine
Stop the ticker after the goroutine reading from it has exited, to avoid
triggering the race detector.
2020-10-27 12:29:05 +01:00
Johan T. Halseth d26001a69a Merge pull request #4688 from carlaKC/4686-paymenttimeout
lncli: allow configurable timeout in send payment
2020-10-13 13:06:47 +02:00
Johan T. Halseth 22d7bb138c Merge pull request #3131 from halseth/reliable-payments-switch-gc
[reliable payments] switch result store clean-up
2020-10-08 15:43:34 +02:00
Johan T. Halseth 90a59fe70f router: call CleanStore on startup 2020-10-06 10:46:04 +02:00
Johan T. Halseth b071278f07 htlcswitch: add cleanStore method
That let us clean up handed off payment results, as they will never be
queried again.
2020-10-06 10:46:03 +02:00
Johan T. Halseth d1a118388d payment_control: remove unused Attempts field 2020-10-06 10:41:25 +02:00
Johan T. Halseth 46225e2921 Merge pull request #4666 from halseth/autopilot-mis-totalfunds
[autopilot] Use local channel balance in allocation calculation
2020-10-05 14:56:20 +02:00
Johan T. Halseth dbeafe8832 autopilot: rename to Capacity to Balance, define ChannelInfo()
We rename the field Capacity on local channels to Balance, define a new
method ChannelInfo on the manager config that let us query the database
for our latest channels state. Using this we will use the current local
balance instead of the channel capacity when doing allocation
calculations.
2020-10-05 12:24:07 +02:00
Johan T. Halseth d40cf6b592 autopilot: split channel definition into LocalChannel/ChannelEdge
Since non-local channels won't have a balance field, we split the
definitions in anticipation of adding one.
2020-10-05 12:24:07 +02:00
Johan T. Halseth 3e1755ee99 autopilot: remove unimpleneted SpliceIn/Out methods 2020-10-05 12:16:50 +02:00
Johan T. Halseth 392d6ccc9f autopilot: remove unused channel field FundedAmt 2020-10-05 12:16:50 +02:00
Johan T. Halseth b6c161bcfc Merge pull request #4671 from Roasbeef/health-check-logging
healthcheck: bump logging for failed healthchecks to info
2020-10-05 10:59:09 +02:00
Johan T. Halseth ef0bca7a8e Merge pull request #4660 from yyforyongyu/add-temp-miner-logs
itest: save temp miner's logs
2020-10-02 12:43:22 +02:00
Johan T. Halseth 1a73bc7d74 Merge pull request #4653 from LN-Zap/feat/spend-unconfirmed
Ability to spend unconfirmed coins when making onchain transactions
2020-10-02 08:40:45 +02:00
Johan T. Halseth d560f9eab0 Merge pull request #4662 from Roasbeef/neutrino-dep-update-sept
build: update neutrino to latest version
2020-10-01 14:26:09 +02:00
Johan T. Halseth 74e62e5c5b Merge pull request #4589 from yyforyongyu/itest-proper-cleanup
Itest: proper connect/disconnect miner
2020-09-25 10:31:56 +02:00
Johan T. Halseth 65865030d6 macaroons test: fix formatting 2020-09-24 11:59:08 +02:00
Johan T. Halseth 14960b1fb4 macaroons test: reverse macaroon time caveat check
This commit fixes a go 1.15 vet check.

In doing so it uncovers that the time caveat check is actually reversed.
Since we should check that the caveat is added, we should only fail the
check when the caveat prefix is not equal.
2020-09-24 11:22:20 +02:00
Johan T. Halseth 8ca5342b37 brontide test: fix go 1.15 vet check 2020-09-24 11:20:48 +02:00
Johan T. Halseth df6606d37f txnotifier test: add test for confirmation after cancellation
This test addition would cause the txnotifier to crash prior to the
previous commit.
2020-09-16 11:23:02 +02:00
Johan T. Halseth 2665836fa3 txnotifier: delete ntfn by confirm height always
When we cancel a confirmation request, we should remove the request from
the height map regardless of the current height. Otherwise we end up in
the situation when the height is reached, the notification is attempted
sent which results in a crash.
2020-09-16 11:20:37 +02:00
Johan T. Halseth 3a12b5867f txnotifier test: use Cancel() directly 2020-09-16 11:19:53 +02:00
Johan T. Halseth b8eb41f947 Merge pull request #4591 from hsjoberg/walletloader-unload
lnd: Call loader.UnloadWallet on shutdown
2020-09-15 13:54:46 +02:00
Johan T. Halseth bf18929f0e peer/brontide: fix pubkey log 2020-09-11 11:10:58 +02:00
Johan T. Halseth a48c369250 lnwallet: check coop close fee negative balance
Also modify the test to check for this condition.
2020-09-11 11:10:58 +02:00
Johan T. Halseth 09a126b29f lnwallet: add anchor size back to balance on coop close
To be spec compliant, we require the initiator to not pay the anchor
values into fees on coop close. We extract the balance calculation into
commitment.go, and add back the value of the anchors to the initiator's
balance.
2020-09-11 11:10:58 +02:00
Johan T. Halseth 07a57ae778 lnwallet: extract coop close balance calc into method 2020-09-11 11:10:58 +02:00
Johan T. Halseth 724f439b0b lnwire: update anchor bit to spec 2020-09-11 11:10:58 +02:00
Johan T. Halseth 517fcd691a channeldb: correct anchor comment 2020-09-11 11:10:58 +02:00
Johan T. Halseth 85b53c357f htlcswitch: use kvdb.View for loading fwdpkgs
Not necessary to open a write tx.
2020-08-13 14:36:48 +02:00
Johan T. Halseth 09b8bee865 mobile: remember walletunlocker.proto 2020-08-04 14:43:08 +02:00
Johan T. Halseth e64e71d86d Merge pull request #4482 from guggero/travis-github-split
github+travis: split CI tasks between Travis and GitHub
2020-07-24 09:42:14 +02:00
Johan T. Halseth 0fab14502d Merge pull request #4467 from cfromknecht/hh-cache-followup
chainntfns: disable height-hint cache followups
2020-07-17 09:57:37 +02:00
Johan T. Halseth 9d147c55d7 Merge pull request #4469 from halseth/mobile-global-config
mobile+make: restore mobile compilation
2020-07-17 09:55:35 +02:00
Johan T. Halseth 935fa7f12d make+mobile: pass expected falafel version to build script 2020-07-17 08:49:03 +02:00
Johan T. Halseth 39241dcdc7 mobile: use single brackets for bash if check
Double brackets are sh specific.
2020-07-17 08:49:03 +02:00
Johan T. Halseth d41ca81aad make: add goimports dep
Required by mobile bindings generate script.
2020-07-17 08:49:02 +02:00
Johan T. Halseth b55b7025b0 travis: sanity check mobile build compilation 2020-07-17 08:49:02 +02:00
Johan T. Halseth fd8e6c98b9 make: fetch falafel dependency for mobile-rpc 2020-07-17 08:49:02 +02:00
Johan T. Halseth 7a30332619 mobile: use single "mobile" build tag instead of "ios" and "android"
Since the "android" build tag conflicts with a go compiler build tag, we instead use a single "mobile" tag for both platforms.
2020-07-17 08:49:02 +02:00
Johan T. Halseth f360ec71bf mobile: restore config parsing for mobile bindings
A recent commit moved the config parsing out of lnd's Main method. This
commit makes the mobile bindings compile with this change.
2020-07-17 08:49:02 +02:00
Johan T. Halseth 5e72a4b77c routing: exit on unexpected RequestRoute error
We whitelist a set of "expected" errors that can be returned from
RequestRoute, by converting them into a new type noRouteError. For any
other error returned by RequestRoute, we'll now exit immediately.
2020-04-02 19:31:24 +02:00
Johan T. HalsethandJoost Jager fee5fd0093 itest: add testSendToRouteMultiPath
testSendToRouteMultiPath tests that we are able to successfully route a
payment using multiple shards across different paths, by using SendToRoute.

Co-authored-by: Joost Jager <joost.jager@gmail.com>
2020-04-02 19:31:23 +02:00
Johan T. Halseth 95c5a123c8 routing/router_test: add TestSendToRouteMultiShardSend 2020-04-02 19:31:23 +02:00
Johan T. Halseth 864e64e725 channeldb: validate MPP options when registering attempts
We add validation making sure we are not trying to register MPP shards
for non-MPP payments, and vice versa. We also add validtion of total
sent amount against payment value, and matching MPP options.

We also add methods for copying Route/Hop, since it is useful to use
for modifying the route amount in the test.
2020-04-02 19:31:23 +02:00
Johan T. Halseth 9a1ec950bd channeldb/payments: extract common info fetch into fetchCreationInfo 2020-04-02 19:29:15 +02:00
Johan T. Halseth 36a80b4d51 routing/router: enable MPP sends for SendToRoute
This commit enables MPP sends for SendToRoute, by allowing launching
another payment attempt if the hash is already registered with the
ControlTower.

We also set the total payment amount of of the payment from mpp record,
to indicate that the shard value might be different from the total
payment value.

We only mark non-MPP payments as failed in the database after
encountering a failure, since we might want to try more shards for MPP.
For now this means that MPP sendToRoute payments will be failed
only after a restart has happened.
2020-04-02 19:29:15 +02:00
Johan T. Halseth 431372c0cf routing/payment_lifecycle_test: add MPP test cases 2020-04-02 19:29:15 +02:00
Johan T. Halseth 7b318a4be7 routing/payment_lifecycle+channeldb: enable multi shard send
This commit finally enables MP payments within the payment lifecycle
(used for SendPayment). This is done by letting the loop launch shards
as long as there is value remaining to send, inspecting the outcomes for
the sent shards when the full payment amount has been filled.

The method channeldb.MPPayment.SentAmt() is added to easily look up how
much value we have sent for the payment.
2020-04-02 19:29:15 +02:00
Johan T. Halseth 0fd71cd596 routing/payment_lifecycle_test: add step for terminal failure
And modify the MissionControl mock to return a non-nil failure reason in
this case.
2020-04-02 19:29:15 +02:00
Johan T. Halseth 2e63b518b7 routing/payment_lifecycle_test+mock: set up listener for FailAttempt
Also rename Success to SettleAttempt in the tests.
2020-04-02 19:29:15 +02:00
Johan T. Halseth aa9c971dc0 routing/payment_lifecycle_test: extract route creation into method
This also fixes a test bug that the manually created route didn't match
the actual payment amount in the test cases, and adds some fees to the
route.
2020-04-02 19:29:14 +02:00
Johan T. Halseth 4d343bbb46 routing tests: move TestRouterPaymentStateMachine to own file
(almost) PURE CODE MOVE
The only code change is to change a few select cases from

case _ <- channel:
to
case <- channel:

to please the linter.

The test is testing the payment lifecycle, so move it to
payment_lifecycle_test.go
2020-04-02 19:29:14 +02:00
Johan T. Halseth 3610824abd channeldb/payment_control_test: add TestPaymentControlMultiShard 2020-04-02 19:29:14 +02:00
Johan T. Halseth 70202be580 channeldb: make database logic MPP compatible
This commit redefines how the control tower handles shard and payment
level settles and failures. We now consider the payment in flight as
long it has active shards, or it has no active shards but has not
reached a terminal condition (settle of one of the shards, or a payment
level failure has been encountered).

We also make it possible to settle/fail shards regardless of the payment
level status (since we must allow late shards recording their status
even though we have already settled/failed the payment).

Finally, we make it possible to Fail the payment when it is already
failed. This is to allow multiple concurrent shards that reach terminal
errors to mark the payment failed, without havinng to synchronize.
2020-04-02 19:29:14 +02:00
Johan T. Halseth f6c97daf0c channeldb/payment_control_test: simplify HTLC status assertion 2020-04-02 10:24:36 +02:00
Johan T. Halseth 5adfc968df routing/payment_lifecycle: return recorded errors
In preparation for MPP we return the terminal errors recorded with the
control tower. The reason is that we cannot return immediately when a
shard fails for MPP, since there might be more shards in flight that we
must wait for. For that reason we instead mark the payment failed in the
control tower, then return this error when we inspect the payment,
seeing it has been failed and there are no shards in flight.
2020-04-02 10:24:35 +02:00
Johan T. Halseth 7b5c10814b routing/payment_lifecycle+channeldb: collect existing outcome first
To move towards how we will handle existing attempt in case of MPP
(collecting their outcome will be done in separate goroutines separate
from the payment loop), we move to collect their outcome first.

To easily fetch HTLCs that are still not resolved, we add the utility
method InFlightHTLCs to channeldb.MPPayment.
2020-04-02 10:24:35 +02:00
Johan T. Halseth 49efbefb43 routing/payment_session: remove prebuilt payment session
Since we no longer use payment sessions for send to route, we remove the
prebuilt one.
2020-04-02 10:24:35 +02:00
Johan T. Halseth 4509c4f3a9 routing: move ErrMaxRouteHopsExceeded check
Now that SendToRoute is no longer using the payment lifecycle, we move
the max hop check out of the payment shard's launch() method, and return
the error directly, such that it can be handled in SendToRoute.
2020-04-02 10:24:35 +02:00
Johan T. Halseth a979b91b27 routing: remove errNoRoute and lastError
Now that SendToRoute is no longer using the payment lifecycle, we
remove the error structs and vars used to cache the last encountered
error. For SendToRoute this will now be returned directly after a shard
has failed.

For SendPayment this means that the last error encountered durinng
pathfinding no longer will be returned. All errors encounterd can
instead be inspected from the HTLC list.
2020-04-02 10:24:35 +02:00
Johan T. Halseth 6cc162e0b0 router: make sendToRoute omit payment lifecycle
Instead of having SendToRoute pull routes from the payment session in
the payment lifecycle, we utilize the new methods on the paymentShard to
launch and collect the result for this single route.

This also let us remove the check for noRouteError, as we will always
have the result from the tried attempt returned. A result of this is
that we can finally remove lastError from the payment lifecycle (see
next commits).
2020-04-02 10:24:35 +02:00
Johan T. Halseth 2c01e79eb5 routing/payment_lifecycle: extract result collection into collectResult
Fetching the final shard result will also be done for calls to
SendToRoute, so we extract this code into a new method.

We move the call to the ControlTower to set the payment level failure
out into the payment loop, as this must be handled differently when
multiple shards are in flight, and for SendToRoute.
2020-04-02 10:24:34 +02:00
Johan T. Halseth 9712dd1a7f routing/payment_lifecycle: extract attempt sending logic
Define shardHandler which is a struct holding what is needed to send
attempts along given routes. The reason we define the logic on this
struct instead of the paymentLifecycle is that we later will make
SendToRoute calls not go through the payment lifecycle, but only using
this struct.

The launch shard is responsible for registering the attempt with the
control tower, failing it if the launch fails. Note that it is NOT
responsible for marking the _payment_ failed in case a terminal error is
encountered. This is important since we will later reuse this method for
SendToRoute, where whether to fail the payment cannot be decided on the
shard level.
2020-04-02 10:24:34 +02:00
Johan T. Halseth bcca1ab821 routing/payment_lifeycle: remove payment level attempt and circuit
We replace the cached attempt, and instead use the control tower
(database) to fetch any in-flight attempt. This is done as a
preparation for having multiple attempts in flight.

In addition we remove the cached circuit, as it won't be applicable when
multiple shards are in flight.

Instead of tracking the attemp we consult the database on every
iteration, and pick up any existing attempt. This also let us avoid
having to pass in the existing attempts from the payment loop, as we
just fetch them direclty.
2020-04-02 10:24:34 +02:00
Johan T. Halseth 9bcf41d401 channeldb: make FailureReason Error() 2020-04-02 10:24:34 +02:00
Johan T. Halseth e1f4d89ad9 routing: add FetchPayment method to ControlTower
This method is used to fetch a payment and all HTLC attempt that have
been made for that payment. It will both be used to resume inflight
attempts, and to fetch the final outcome of previous attempts.

We also update the the mock control tower to mimic the real control
tower, by letting it track multiple HTLC attempts for a given payment
hash, laying the groundwork for later enabling it for MPP.
2020-04-02 10:24:34 +02:00
Johan T. Halseth 6d9f9c31f4 routing/router_test: remove preimage overwrite
The test case's preimage was (mistakenly) overwritten after crafting the
lightning payment, causing the parts of the testcases use the same
preimage causing problems when we are using the payment hash and
preimage in the mock control tower to distinguish paymennts.
2020-04-02 10:24:34 +02:00
Johan T. Halseth 79227bab3a routing/route: define route.ReceiverAmt() method 2020-04-02 10:24:34 +02:00
Johan T. Halseth 4485e8261f routing/payment_lifecycle: move Fail call to payment loop
In our quest to move calls to the ControlTower into the main payment
lifecycle loop, we move the edge case of a too long route out of
createNewPaymentAttempt.
2020-04-02 10:24:33 +02:00
Johan T. Halseth 3620721391 routing/payment_lifecycle: move attempt DB checkpointing into payment
loop

To prepare for multiple in flight payment attempts, we move
checkpointing the payment attempt out of createNewPaymentAttempt and
into the main payment lifecycle loop.

We'll attempt to move all calls to the DB via the ControlTower into this
loop, so we can more easily handle them in sequence.
2020-04-02 10:24:33 +02:00
Johan T. Halseth e61fcda6a9 routing/payment_lifecycle: move requesting route out of createNewPaymentAttempt
To prepare for having more than one payment attempt in flight at the
same time, we decouple fetching the next route from crafting the payment
attempt.
2020-04-02 10:24:33 +02:00
Johan T. Halseth 00903ef9f5 routing/payment_session: make RequestRoute take max amt, fee limit and
active shards

In preparation for doing pathfinding for routes sending a value less
than the total payment amount, we let the payment session take the max
amount to send and the fee limit as arguments to RequestRoute.
2020-04-02 10:24:33 +02:00
Johan T. Halseth f9eeb6b41f routing/router+lifecycle: remove LightningPayment from payment lifecycle
Now that the information needed is stored by the paymentSession, we no
longer need to pass the LightningPayment into the payment lifecycle.
2020-04-02 10:24:33 +02:00
Johan T. Halseth c2301c14b2 routing/payment_session: make NewPaymentSession take payment directly
This commit moves supplying of the information in the LightningPayment
to the initialization of the paymentSession, away from every call to
RequestRoute.

Instead the paymentSession will store this information internally, as it
doesn't change between payment attempts.

This is done to rid the RequestRoute call of the LightingPayment
argument, as for SendToRoute calls, it is not needed to supply the next
route.
2020-04-02 10:24:33 +02:00
Johan T. Halseth 73c542c934 travis+lint+make: limit lint concurrency only on travis
Since linting is much faster by using the defaults locally.
2020-03-31 10:27:44 +02:00
Johan T. Halseth e269e3f91b itest: calcStaticFee based on commit type 2020-03-27 08:01:46 +01:00
Johan T. Halseth 1d2985ce33 Merge pull request #4108 from jnewbery/2020-03-min-htlc-comment
[Docs] fix defaultBitcoinMinHTLCInMSat comment
2020-03-24 13:02:04 +01:00
Johan T. Halseth 8dc5a3c144 itest: wait for file writing in wait predicate 2020-03-24 12:18:42 +01:00
Johan T. Halseth 8623bfac22 Merge pull request #4103 from halseth/itest-multi-hop-move
[itests] multi hop test move
2020-03-24 09:37:53 +01:00
Johan T. Halseth b4ea34037a lntest: move multi-hop root test case and common utils to own file 2020-03-23 11:19:18 +01:00
Johan T. Halseth 1ade912361 itest: run multi-hop claim tests for all commit types 2020-03-23 11:16:29 +01:00
Johan T. Halseth 6ed0c83d11 itest: spin up new nodes for multi-hop tests
This will let us set their commitment type for the subtest.
2020-03-23 11:13:27 +01:00
Johan T. Halseth 1ce4abc0a9 itest: extract multi-hop tests into sub tests 2020-03-23 11:13:26 +01:00
Johan T. Halseth 5a0f2d004a itest: update multi hop test case docs
To make clear whcih sweep scenarios are actually being tested
2020-03-23 11:11:25 +01:00
Johan T. Halseth 4b5d91d24d itest: move multi hop tests to own files
PURE CODE MOVE.
2020-03-23 11:10:33 +01:00
Johan T. Halseth d81c8bbda7 itest: run force closure test for all commit types
Now that the force closure test has been extracted, spin up new nodes
for each commit type, and ensure the test succeed for all types.
2020-03-23 11:10:31 +01:00
Johan T. Halseth 651bb09c25 itest: extract channel force closure test into subtest
To make it possible to run the for close test for multiple commit types,
we extract it into a subtest, where the two nodes get passed in.
2020-03-23 11:07:36 +01:00
Johan T. Halseth 538f3baac8 itest: print wrong balance in correct format 2020-03-23 11:05:40 +01:00
Johan T. Halseth 42638183d8 Merge pull request #4105 from carlaKC/lnrpc-formatroutingprotos
routerrpc: run rpc-format on routerrpc
2020-03-20 20:57:42 +01:00
Johan T. Halseth c1d00a0c9b Merge pull request #4101 from ErikEk/typo_fixes_trivial
trivial: typo fixes
2020-03-19 21:36:38 +01:00
Johan T. HalsethandJoost Jager dc6c4637b6 lnwallet+channeldb: add anchor resolutions
Co-authored-by: Joost Jager <joost.jager@gmail.com>
2020-03-17 14:19:35 +01:00
Johan T. Halseth 7d305fdc46 lnrpc: add commitment_type to listchannels 2020-03-13 20:00:48 +01:00
Johan T. Halseth 15be39b8db Merge pull request #4071 from halseth/autopilot-log-active
[trivial] pilot: log whether autopilot is active at startup
2020-03-11 16:22:33 +01:00
Johan T. Halseth 44ba481f56 Merge pull request #4069 from guggero/windows-build
travis+lncli: fix windows build
2020-03-11 14:51:54 +01:00
Johan T. Halseth 5484436520 Merge pull request #4010 from halseth/avoid-resend-chansync-loop
peer: avoid chansync resend loop
2020-03-11 14:47:07 +01:00
Johan T. Halseth d4bb0854df Merge pull request #4070 from guggero/disable-clang-format
Makefile: don't format proto on Travis
2020-03-11 14:43:44 +01:00
Johan T. Halseth c9c667bbf2 pilot: log whether autopilot is active at startup 2020-03-11 12:56:16 +01:00
Johan T. Halseth 7b8eae38e5 peer: avoid chansync resend loop
If a peer receives a channel reestablish message shortly after the
channel has been closed, it will resend its own channel reestablish
message. In the meantime the other peer could also have seen the channel
being closed and will also resend its own message. This leads to a
resend loop that never terminates.

To avoid two peers getting into this situation, we now allow only one
such resent message per conection.
2020-03-11 12:13:25 +01:00
Johan T. Halseth b7885dbbae lnwallet+size: select HTLC fees based on channel type 2020-03-09 12:59:35 +01:00