Commit Graph

2428 Commits

Author SHA1 Message Date
Conner Fromknecht 3b2e4caa93 discovery/gossiper: isolate sync with node from query
This commit refactors the SynchronizeNode logic such that
  it can be called without interacting with the gossiper's
  main execution loop. This method does not require access
  to any of the gossiper's internal state, making the change
  fairly straightforward. The primary motivation behind
  this change is to minimize the possibility of introducing
  deadlock scenarios between the gossiper and server.
2017-10-27 15:48:37 -07:00
rajeshnair2k 0e07699550 lncli: add a convenience command for paying an invoice
Fixes #324.
2017-10-27 15:39:54 -07:00
Jim Posen a13ad0a339 multi: Fix various typos. 2017-10-25 13:20:54 -07:00
Johan T. Halseth 4b883b9899 funding: poll or database state instead of using timeouts in tests
This commit make the fundingmanager tests poll for database state
for a time, instead of using an explicit sleep before accessing the
DB. This should address some of the flakes encountered on Travis,
where db writes might take longer than usual.
2017-10-25 13:17:22 -07:00
Jim Posen 2b58a39d30 lnwallet: Simplify updateLog struct by removing redundant pointers.
The updateLog struct contains pointers that refer to the state of the
commitment chains. Instead, query the commitments directly.
2017-10-25 13:11:46 -07:00
Olaoluwa Osuntokun 885753cae4
test: extend testMultiHopPayments to test a 4 node, 3 hop payment
In this commit, we extend the testMultiHopPayments test case to add an
additional node to the multi-hop payment route: Dave.

Related to #391 as it uses the provided code fragment to reproduce the
bug. With this test in place, we’ll now be able to notice any
regressions in this area.
2017-10-24 18:34:04 -07:00
Olaoluwa Osuntokun 21446c2872
htlcswitch: finish remainder of TestUpdateForwardingPolicy test case
In this commit, we address a lingering TODO within the
TestUpdateForwardingPolicy test case to ensure that Bob will reject the
payment the second time around due to an update in his fee policy.
2017-10-24 18:31:46 -07:00
Olaoluwa Osuntokun 57b9b78ce3
routing: modify path finding tests to accommodate for flip in fee calc
Before this commit, we would expect that structurally we don’t pay any
fee for the first hop, but do for the final hop. After the latest
commit, this is now flipped as when we say fee, we mean the fee that we
need to pay to transit a link. For the final hop, there’s no additional
distance to be traveled, so the fee is nothing.
2017-10-24 18:29:23 -07:00
Olaoluwa Osuntokun a7fe7ae941
routing: correct miscalculation multi-hop onion payload fees
In this commit we fix an existing miscalculation in the fees that we
prescribe within the onion payloads for multi-hop routes. Before this
commit, if a route had more than 3 hops, then we would erroneously give
the second to last hop zero fees.

In this commit we correct this behavior, and also re-write the fee
calculation code fragment within newRoute for readability and clarity.
There are now only two cases: this is the last hop, and this is any
other hop. In the case of the last hop, simply send the exact amount
with no additional fee. In the case of an intermediate hop, we use the
_prior_ (closer to the destination) hop to calculate the amount of fees
we need, which allows us to compute the incoming flow. Using that
incoming flow, we then can compute the amount that the hop should
forward out.

Partially fixes #391.
2017-10-24 18:27:35 -07:00
Olaoluwa Osuntokun 176fde4ec0
routing: modify applyChannelUpdate to not error out if update is stale
In this commit we fix a slight bug within the existing SendPayment loop
which would cause the wrong error to be returned to users. Prior to
this commit, if we received an update identical to what we were already
aware of, then that error would be returned rather than the
ForwardingError that encapsulated this update.

In this commit with remedy this by properly returning the exact error.

Partially fixes #391.
2017-10-24 18:23:04 -07:00
Olaoluwa Osuntokun 3e64ba0394
test: modify all testing involving HTLC routing to directly use payreqs
In this commit we modify all the test that involve sending payments to
use the payreq returned rather than manually populating the
payhash+dest fields in the SendRequest proto argument to SendPayment.
This is required as if we don’t use the payreq returned, then the
receiving node will reject the payment as it’ll use the global final
CLTV delta value, rather than the value (within the pay req) that the
receiver is expecting.
2017-10-22 18:37:02 -07:00
Olaoluwa Osuntokun e02af3f877
htlcswitch: as exit node check for invoice and HTLC value match after existence 2017-10-22 18:37:00 -07:00
Olaoluwa Osuntokun a29210f089
rpc: properly interpret and parse cltvDelta from payreqs (if exists) 2017-10-22 18:37:00 -07:00
Olaoluwa Osuntokun 25614f67f8
routing: restore in memory selfNode within the ChannelRouter
In this commit we restore the in memory ChannelRouter as we’ll no
dynamically set the ChannelRouter’s pointer within he spec path finding
test example.
2017-10-22 18:36:59 -07:00
Olaoluwa Osuntokun 76ec41103e
routing: extend missionControl.RequestRoute to take final CLTV delta 2017-10-22 18:36:58 -07:00
Olaoluwa Osuntokun 828057889e
routing/testdata: modify spec example to set bob as initial source node 2017-10-22 18:36:58 -07:00
Olaoluwa Osuntokun 74165ca8c1
htlcswitch: update l.clearedOnionBlobs in link to use new HtlcIndex 2017-10-22 18:36:57 -07:00
Olaoluwa Osuntokun 3b94e5df4d
lnwallet: introduce distinct HTLC counter+index on top of updateLog
In this commit, we fix an existing derivation from the commitment state
machine as defined within the specification. Before this commit, we
only kept a single counter which both HTLC adds and fails/settles would
share. This was valid in the prior pre-spec iteration of the state
machine. However in the current draft of the spec, only a distinct
counter for HTLCs are used throughout.

This would cause an incompatibility, as if we mixed adds and settles
during an exchange, then our counter values would differ with other
implementations. To remedy this, we now introduce a distinct HTLC
counter and index within the updateLog.

Each Add will increment both the log counter, and the HTLC counter.
Each Settle/Fail will only increment the log counter. Inbound
Settle/Fails will index into the HTLC index as to target the proper
HTLC. The PaymentDescriptor type has been extended with an additional
field (HltcIndex) which itself tracks the index of an incoming/outgoing
HTLC.
2017-10-22 18:36:57 -07:00
Olaoluwa Osuntokun da9a771a58
htlcswitch: update timelock policy mismatch test due to time lock changes
In this commit, we update the TestLinkForwardTimelockPolicyMismatch to
instead _subtract_ time from the first HTLC extended to the initial
hop. We now subtract instead as giving intermediate hops more time
is.now permitted.
2017-10-22 18:36:56 -07:00
Olaoluwa Osuntokun 6a255fb588
htlcswitch: relax timelock verification in middle link to allow for shadow routes
In this commit, we relax the time lock verification when we realize
we’re an intermediate hop. We no longer directly assert that the time
lock we receive is _identical_, instead we allow slow slack and will
reject iff, the incoming timelock minus the outgoing time lock doesn’t
meet our delta requirements.
2017-10-22 18:36:56 -07:00
Olaoluwa Osuntokun bdc4d09b25
rpc: display the cltv expiry in decoded pay req 2017-10-22 18:36:55 -07:00
Olaoluwa Osuntokun 22881ec05e
rpc: in createRPCInvoice properly populate CltvExpiry 2017-10-22 18:36:55 -07:00
Olaoluwa Osuntokun 5bc906dd18
rpc: properly parse our CltvExpiry in AddInvoice 2017-10-22 18:36:54 -07:00
Olaoluwa Osuntokun c54e6fc803
zpay32: add new 'c' field to payreqs for specifying final cltv delta 2017-10-22 18:36:53 -07:00
Olaoluwa Osuntokun de7e339281
lnrpc: add cltv_expiry to Invoice and PayReq protos 2017-10-22 18:36:53 -07:00
Olaoluwa Osuntokun 6e00abf3f1
routing: update tests in router_test.go to pass in new param to FindRoutes 2017-10-22 18:36:52 -07:00
Olaoluwa Osuntokun 69a3783d55
routing: add new test case from spec to assert proper route calc 2017-10-22 18:36:52 -07:00
Olaoluwa Osuntokun acd160a419
routing: update path finding tests to account for change in fee calculation 2017-10-22 18:36:51 -07:00
Olaoluwa Osuntokun aee1619488
routing: add new FinalCLTVDelta attribute to SendPayment
In this commit, we’ll now optionally allow the user to pass in the CLTV
delta value specified by the recipient a payment. If the value isn’t
specified, then we’ll use the current global default for the payment.
2017-10-22 18:36:51 -07:00
Olaoluwa Osuntokun c8f45e3a04
routing: add new param to FindRoutes for CLTV expiry for final hop
In this commit, we modify the FindRoutes method to pass in the CLTV
expiry for the final hop. If the value isn’t passed in, then we’ll use
the current global default value in place.
2017-10-22 18:36:50 -07:00
Olaoluwa Osuntokun 4b82e2ec43
routing: correct fee calculation when converting from path to route
In this commit, we correct the fee calculation when converting from a
path to route. Previously we would apply the “no fee” case at the
_first_ hop, rather than the last hop. As a result, we needed to swap
the edges during path finding, otherwise, if the incoming and outgoing
edges had different fee rates, then we would create an invalid onion
payload.

In this commit we now properly switch fee calculation into three cases:
  * a single hop route, so there’s no fee
  * we’re at the first hop in a multi hop route, and we apply the fee
for the _next_ hop
  * we’re at an intermediate hop and the fee calculation proceeds as
normal
2017-10-22 18:36:50 -07:00
Olaoluwa Osuntokun 8df69a83a7
routing: revert the swapping of in/out edges during path finding
In this commit we revert a commit which was added in the past as way to
allow the path -> route conversion code to remain the same, while
properly respecting the necessary time locks and fees. In an upcoming
change, this swap is no longer necessary as we’ll always use: the time
lock of the outgoing node and the fee of the incoming node.
2017-10-22 18:36:49 -07:00
Olaoluwa Osuntokun 23b6d84493
routing: modify newPath to take the preferred final CLTV delta of last hop
In this commit, rather than reading the final CLTV delta from the
channel graph itself (which would require _both_ edges to be advertised
in order to route over), we now instead have moved to allowing the
receiving node to choose their own final CLTV delta.
2017-10-22 18:36:48 -07:00
Olaoluwa Osuntokun 65482faa79
routing: remove the selfNode attribute from memory
In this commit, we’ve removed the selfNode attribute from memory, as
the set of new tests we’ll write, will depend on us being able to
switch the source node dynamically from the database itself.
2017-10-22 18:36:48 -07:00
Olaoluwa Osuntokun f5881ad3df
routing: only write a single edge as edges in test data are now directional 2017-10-22 18:36:47 -07:00
Olaoluwa Osuntokun 86283b0d06
routing: make setting source node optional when parsing testdata 2017-10-22 18:36:47 -07:00
Olaoluwa Osuntokun e70031da7b
routing: properly assign flags and write both edges when parsing test data 2017-10-22 18:36:46 -07:00
Olaoluwa Osuntokun 4ff66efa2b
routing: convert testChan stuct to take an int64 for FeeRate 2017-10-22 18:36:46 -07:00
Olaoluwa Osuntokun fae3dacc9b
routing: modify basic_graph.json to include both directional edges 2017-10-22 18:36:45 -07:00
Olaoluwa Osuntokun 3c01d5bab9
routing: convert basic_graph.json testdata to use fixed point fee rate 2017-10-22 18:36:44 -07:00
Olaoluwa Osuntokun bb1fd98b67
peer: print hex encoded failure reason for lnwire.UpdateFailHTLC in msg summaries 2017-10-22 18:36:40 -07:00
Jim Posen 7c1ae8bda3 lnwallet: Split tx generation code out of fetchCommitmentView.
This moves the commitment transaction generation code out of
fetchCommitmentView into createCommitmentTx. Aside from being a pretty
clean logical split, this allows the transaction generation code to be
unit tested more effectively.
2017-10-19 22:23:14 -07:00
Jim Posen bd497438af lnwallet: Pass around key ring instead of individual keys.
The signatures of some functions/methods in lnwallet are simplified by
passing in a commitmentKeyRing argument instead of multiple keys.
2017-10-19 22:23:14 -07:00
Jim Posen 3151a3a596 lnwallet: Refactor commitment key generation code.
Create struct holding all commitment keys to clean up code and avoid
deriving keys multiple times.
2017-10-19 22:23:14 -07:00
Alex 0994852396 lnwallet: add reorg test 2017-10-19 21:26:31 -07:00
Olaoluwa Osuntokun 126c73af59
test: increase timeout for testNodeAnnouncement 2017-10-19 21:18:27 -07:00
Dustin Dettmer 5661748df0 test: fix typo 2017-10-19 20:20:27 -07:00
nsa aa6395874d wallet: channel test fee fix for added HTLC
This commit fixes the TestChannelBalanceDustLimit unit test in
channel_test.go. The unit test does not account for the fees
required by adding an HTLC. As a result, Alice's balance according
to her local and remote commitment chains drops below 0 at certain
points. By using the correct fee, this is avoided.
2017-10-19 20:04:04 -07:00
mlerner cc221b1548 Fix spelling in docker docs 2017-10-19 20:03:00 -07:00
Jim Posen e9c16845dc chainntnfs: Remove some unnecessary channels in interface_test. 2017-10-19 20:00:16 -07:00