Commit Graph

7648 Commits

Author SHA1 Message Date
Olaoluwa Osuntokun
c344a3a642
Merge pull request #1453 from cfromknecht/decayed-log-flake
htlcswitch/decayedlog_test: fix bug in gc unit test
2018-06-27 16:37:08 -07:00
Conner Fromknecht
e85fa1af96
htlcswitch/decayedlog_test: fix bug in gc unit test
This commit fixes a bug in the
TestDecayedLogPersistentGarbageCollector unit test.
The test generates a second hash prefix, which is never
added to the log, and used to query for the final
existence check. This commit reverts the behavior so
that the same hash prefix is used throughout the test.
2018-06-27 14:40:28 -07:00
Olaoluwa Osuntokun
4e264ee88e
rpc: include the FinalCltvDelta when writing new invoices to disk 2018-06-26 19:50:05 -07:00
Olaoluwa Osuntokun
a2f0d6d38e
htlcswitch: use the delta within the time lock, not the default policy at exit node
In this commit, we fix a lingering bug within the link when we're the
exit node for a particular payment. Before this commit, we would assert
that the invoice gives us enough of a delta based on our current routing
policy. However, if the invoice was generated with a lower delta, or
we've changed from the default routing policy, then this would case us
to fail back any payments sent to us.

We fix this by instead using the newly available final CLTV delta
information within the extracted invoice.

Fixes #1431.
2018-06-26 19:50:04 -07:00
Olaoluwa Osuntokun
8dcfeeaef5 channeldb: explicitly store the FinalCltvDelta within the ContractTerm struct
In this commit, we move to explicitly storing a bit more information
within the invoice. Currently this information is already stored in the
payment request, but by storing it at this level, callers that may not
be in the state to fully decode a payment request can obtain this data.

We avoid a database migration by appending this data to the end of an
invoice. When decoding, we'll try to read out this extra information,
and simply return what we have if it isn't found.
2018-06-26 19:49:49 -07:00
Olaoluwa Osuntokun
ec7cfc6906
Merge pull request #1447 from Roasbeef/forwarding-timelock-fix
routing+htlcswitch: finalize switch of CLTV delta directionality in path finding and link forwarding
2018-06-26 19:47:46 -07:00
Olaoluwa Osuntokun
81e647a520
Merge pull request #1449 from cfromknecht/wait-for-link-shutdown
Wait for link shutdown
2018-06-26 19:46:28 -07:00
parth
8c5543d701 aezeed/errors: add missing space in error message 2018-06-26 19:20:39 -07:00
Conner Fromknecht
66c4240234
htlcswitch/link: add WaitForShutdown method for testing 2018-06-26 18:28:54 -07:00
Conner Fromknecht
23f2d93402
htlcswitch/link_test: wait for link shutdown after removal 2018-06-26 18:28:53 -07:00
Olaoluwa Osuntokun
05d1d4e845
Merge pull request #1262 from guggero/unix-sockets
rpc: add support for unix sockets
2018-06-26 18:17:27 -07:00
Olaoluwa Osuntokun
b44ce7b366
Merge pull request #1312 from halseth/breacharbiter-wait-for-spend
breacharbiter: wait on spend events instead of timeout
2018-06-26 17:50:47 -07:00
Olaoluwa Osuntokun
6a6c29cd00
routing: fix incorrect expiry values in spec_example.json
In this commit, we fix the incorrect expiry values in the
spec_example.json test file. Many of the time locks were incorrect which
allowed bugs within the path finding logic related to CLTV deltas to go
un-detected.
2018-06-26 17:29:42 -07:00
Olaoluwa Osuntokun
6c986864ff
routing: fix bug in newRoute, use time lock delta of prior hop, not current
In this commit, we fix an existing bug in the newRoute method. Before
this commit we would use the time lock delta of the current hop to
compute the outgoing time lock for the current hop. This is incorrect as
the time lock delta of the _outgoing_ hop should be used, as this is
what we're paying for "transit" on. This is a bug left over from when we
switched the meaning of the CLTV delta on the ChannelUpdate message
sometime last year.

The fix is simple: use the CLTV delta of the prior (later in the route)
hop.
2018-06-26 17:29:42 -07:00
Olaoluwa Osuntokun
bdecc5bea9
htlcswitch: update forwarding policy verification to use new time lock info 2018-06-26 17:29:42 -07:00
Olaoluwa Osuntokun
7b4c150983
htlcswitch: add new incoming+outgoing timeout fields to htlcPacket 2018-06-26 17:29:41 -07:00
Olaoluwa Osuntokun
2bb5931bb7
htlcswitch: move timelock policy verification logic to HtlcSatifiesPolicy
In this commit, we extract the time lock policy verification logic from
the processRemoteAdds method to the HtlcSatifiesPolicy method. With this
change, we fix a lingering bug within the link: we'll no longer verify
time lock polices within the incoming link, instead we'll verify it at
forwarding time like we should. This is a bug left over from the switch
of what the CLTV delta denotes in the channel update message we made
within the spec sometime last year.
2018-06-26 17:29:41 -07:00
Olaoluwa Osuntokun
74ec9147b1
htlcswitch: extend the HtlcSatifiesPolicy to also accept timelock/height info
In this commit, we extend the existing HtlcSatifiesPolicy method to also
accept timelock and height information. This is required as an upcoming
commit will fix an existing bug in the forwarding logic wherein we use
the time lock policies of the incoming node rather than that of the
outgoing node.
2018-06-26 17:29:40 -07:00
Olaoluwa Osuntokun
6e051a80ff
htlcswitch: fix bug in generateHops, use CLTV delta of prior hop to compute payload
In this commit, we fix a bug in the generateHops helper function. Before
this commit, it erroneously used the CLTV delta of the current hop,
rather than that of the prior hop when computing the payload. This was
incorrect, as when computing the timelock for the incoming hop, we need
to factor in the CTLV delta of the outgoing lock, not the incoming lock.
2018-06-26 17:29:40 -07:00
Olaoluwa Osuntokun
4eb07e8288
htlcswitch: add new TestForwardingAsymmetricTimeLockPolicies test
In this commit, we add a new test to the switch:
TestForwardingAsymmetricTimeLockPolicies. This test ensures that a link
has two channels, one of which has a greater CLTV delta than the latter,
that a payment will successfully be routed across the channels. Atm, the
test fails (including the fix to hop payload generation included in the
next commit).

Atm, due to the way that we check forwarding policies, we'll reject this
payment as we're attempting to enforce the policy of the incoming link
(cltv delta of 7), instead of that of the outgoing link (cltv delta of
6). As a result, atm, the incoming link checks if (incoming_timeout -
delta < outgoing_timeout). For the values in the test case: 112 - 7 <
106 -> 105 < 106, this check fails. The payload is proper, but the check
itself should be applied at the outgoing hop.
2018-06-26 17:29:39 -07:00
Yaacov Akiba Slama
17223c1215 peer: add write timeout within writeMessage
In this commit, we add a timeout within the writeMessage method when we go to write to the socket. We do this as otherwise, if the other peer is blocked for some reason, we'll never actually unblock ourselves, which may cause issues in other sub-systems waiting on this write call. For now, we use a value of 10 seconds, and will adjust in the future if we deem this time period too short.
2018-06-26 17:27:22 -07:00
Oliver Gugger
c943f02c32
Merge branch 'master' into unix-sockets 2018-06-26 09:35:55 +02:00
Olaoluwa Osuntokun
b8fecfca71
Merge pull request #1442 from Roasbeef/async-link-stop
htlcswitch: in removeLink use new goroutine to stop existing link
2018-06-26 04:14:57 +02:00
Olaoluwa Osuntokun
1219e14955
Merge pull request #1399 from Roasbeef/zlib-decoding
lnwire: implement cautious zlib decoding for channel range queries
2018-06-26 04:13:54 +02:00
Olaoluwa Osuntokun
8ddb2bdc57
Merge pull request #1443 from brndnmtthws/add-profile-docs
docs: Add starter doc on debugging lnd.
2018-06-26 04:13:26 +02:00
Olaoluwa Osuntokun
23b1678266
lnwire: ensure zlib short chan id's are sorted 2018-06-25 16:16:37 -07:00
Olaoluwa Osuntokun
940b95aad7
lnwire: update testing.Quick tests to alternate between encoding types 2018-06-25 16:16:36 -07:00
Olaoluwa Osuntokun
5caf3d7310
lnwire: add new package level mutex to limit # of concurrent zlib decodings
In this commit, we add a new package level mutex. Each time we decode a
new set of chan IDs w/ zlib, we also grab this mutex. The purpose here
is to ensure that we only EVER allocate the maxZlibBufSize globally
across all peers. Otherwise, it may be possible for us to allocate up to
64 MB for _each_ peer, exposing an easy OOM attack vector.
2018-06-25 16:16:36 -07:00
Olaoluwa Osuntokun
a0e2f8dbd1 lnwire: implement zlib encode/decode for channel range queries
In this commit, we implement zlib encoding and decoding for the channel
range queries. Notably, we utilize an io.LimitedReader to ensure that we
can enforce a hard cap on the total number of bytes we'll ever allocate
in a decoding attempt.
2018-06-25 16:16:13 -07:00
Olaoluwa Osuntokun
19a0eab804
htlcswitch: in removeLink use new goroutine to stop existing link
In this commit, we modify the removeLink method to be more asynchronous.
Before this commit, we would attempt to block until the peer exits.
However, it may be the case that at times time, then target link is
attempting to forward a batch of packets to the switch (forwardBatch).
Atm, this method doesn't pass in an external context/quit, so we can't
cancel this message/request. As a result, we'll now ensure that
`removeLink` doesn't block, so we can resume the switch's main loop as
soon as possible.
2018-06-25 16:04:24 -07:00
Olaoluwa Osuntokun
c1c4b84757
Merge pull request #1372 from wpaulino/peer-log-unknown-channel
peer: prevent processing close msg if channel is not found
2018-06-26 00:54:58 +02:00
Brenden Matthews
c703418d1a
docs: Add starter doc on debugging lnd. 2018-06-25 16:27:58 -04:00
Wilmer Paulino
b1ba83bf2b
peer: prevent processing close msg if channel is not found 2018-06-25 13:13:12 -07:00
Olaoluwa Osuntokun
18f17ad49b
Merge pull request #1419 from cfromknecht/update-channel-packager-sid
Update channel packager sid
2018-06-21 13:49:00 +01:00
Olaoluwa Osuntokun
ce164a5233
Merge pull request #1418 from halseth/channel-stop
[bugfix] Channel stop bugfixes
2018-06-21 13:45:00 +01:00
Olaoluwa Osuntokun
70217422b5
Merge pull request #1417 from halseth/chanarb-stop
Properly stop ChannelArbitrators/blockEpocs
2018-06-21 13:42:20 +01:00
Johan T. Halseth
d787e74125
contractcourt/channel_arbitrator: stop block epoch on channel attendant exit 2018-06-21 11:13:46 +01:00
Johan T. Halseth
1c43a0cb36
contractcourt/chain_arbitrator: delete watcher from activeWatchers 2018-06-21 11:13:46 +01:00
Conner Fromknecht
56e5eed037
channeldb/channel: update short chan id for fwd packager 2018-06-19 13:48:08 +01:00
Conner Fromknecht
639c9875b2
channeldb/channel_test: test packager source updated 2018-06-19 13:48:08 +01:00
Johan T. Halseth
b56d922ce2
fundingmanager: properly stop channel on error 2018-06-19 12:48:38 +01:00
Johan T. Halseth
55c8741e42
peer: don't stop nil channel 2018-06-19 12:48:11 +01:00
Johan T. Halseth
327420d854
contractcourt/channel_arbitrator: Cancel block epoch in case of error in Start() 2018-06-19 12:20:30 +01:00
Oliver Gugger
4d521da1a3
Merge branch 'master' into unix-sockets 2018-06-19 11:27:24 +02:00
Olaoluwa Osuntokun
fc658dbf60
docs: further clarify --txindex usage for full nodes 2018-06-18 14:01:25 +01:00
Dan Bolser
b5d8cde6fc README: update README to indicate tx index is no longer required for full node backends 2018-06-18 05:58:24 -07:00
Olaoluwa Osuntokun
7c2307984d
Merge pull request #1380 from cfromknecht/nursery-rebroadcast
utxonursery: rebroadcast finalized kinder txns on startup
2018-06-15 16:49:58 -07:00
Olaoluwa Osuntokun
2f6ff2666c
Merge pull request #1296 from parakeety/add-tdt
htlcswitch: add basic table driven tests for ExpectedFee
2018-06-15 16:36:40 -07:00
Olaoluwa Osuntokun
aeca4d6def
Merge pull request #1390 from Roasbeef/sorted-closed-channels
rpc: sort closed channels in order of ascending height
2018-06-15 16:02:30 -07:00
Johan T. Halseth
3bdc968f39
breacharbiter: wait on spend events instead of timeout
This commit handles a racy condition within the breacharbiter's justice
tx procedure. For backends that have no mempool we would check if an
HTLC output was spent and then try broadcasting the justice tx, but this
would fail since we wouldn't detect the spend before it was in a block.
The result was that we would continuously attempt to broadcast the
transaction, effectively ending up in an endless (until the second-level
tx actually comfirmed) loop.

Instead we now register for spend notifications in case broadcasting the
transaction fails, and then wait for any of the notifications to be
sent before trying again.

This is a necessary step to be able to make lnd work well only with
confimed transactions, and was a better solution than introducing
timeouts within the broadcast loop (which complicates integration
tests).
2018-06-15 12:11:13 +02:00