Commit Graph

149 Commits

Author SHA1 Message Date
Olaoluwa Osuntokun
62473009b5
htlcswitch: within link, with each new block, check to see if commit fee should change
In this commit we add a new case to the main select statement within a
channel link. This select statement will serve as a Sipping Bird which
will check the network fee rate (as returned by the fee estimator) and
compare that to the fee on the commitment transaction. Using the
shouldAdjustCommitFee function, we determine if we should update the
commitment fee. If so, then we’ll send an UpdateFee message and also
trigger a new commitment update.

We also add a new unit test: TestChannelLinkUpdateCommitFee to ensure
that we update the fee accordingly if the fee increases or decreases by
a large portion.
2017-11-23 23:10:19 -06:00
Olaoluwa Osuntokun
c560200ba1
htlcswitch: add new shouldAdjustCommitFee helper function
In this commit, we add a new helper function to the link which will be
utilized in a later commit. This helper function will help us determine
if we should update the commitment fee, in response to a change in the
network fee return by our fee estimators.
2017-11-23 23:10:19 -06:00
Olaoluwa Osuntokun
5a51600f95
htlcswitch: update CloseLink to accept ideal fee rate 2017-11-23 23:10:12 -06:00
Olaoluwa Osuntokun
25082f0b5b
htlcswitch: update WipeChannel on Peer interface to simply take the chanPoint
The WipeChannel method doesn’t need to take the channel itself, as any
relevant indexes should be able to be queried based on the channel
point along.
2017-11-23 23:10:10 -06:00
Olaoluwa Osuntokun
3aabbce551
htlcswitch: update tests to adhere to new FeeEstimator changes 2017-11-23 23:10:10 -06:00
Olaoluwa Osuntokun
b31e94573b
htlcswitch: properly set HtlcBasePoint in createTestChannel 2017-11-16 20:00:08 -08:00
Olaoluwa Osuntokun
6afebfba5d
htlcswitch: update link to match latest ChanSyncMsg API change 2017-11-16 20:00:06 -08:00
Olaoluwa Osuntokun
d7aa769275
htlcswitch: add additional sleep to end of TestChannelLinkBidirectionalOneHopPayments 2017-11-15 18:25:01 -08:00
Olaoluwa Osuntokun
e7e426a1cc
Merge pull request #398 from halseth/sighash-signdesc-hashtype
Use dynamic SigHash type when signing transactions.
2017-11-11 17:30:54 -08:00
Olaoluwa Osuntokun
b6f64932c2
htlcswitch: face race condition in unit tests by returning invoice
In this commit we modify the primary InvoiceRegistry interface within
the package to instead return a direct value for LookupInvoice rather
than a pointer. This fixes an existing race condition wherein a caller
could modify or read the value of the returned invoice.
2017-11-11 16:09:29 -08:00
Olaoluwa Osuntokun
7d10ab3ae8
htlcswitch: increase timeouts of tests due to race condition detector 2017-11-11 15:07:02 -08:00
Olaoluwa Osuntokun
9d6e9c73f1
htlcswitch: modify TestChannelRetransmission to exit on first test failure 2017-11-11 15:06:25 -08:00
Olaoluwa Osuntokun
849abde253
htlcswitch: fix mockInvoiceRegistry implementation of SettleInvoice
In this commit we fix the implementation of SettleInvoice by ensuring
the lock is held for the duration of the method.
2017-11-11 15:05:58 -08:00
Olaoluwa Osuntokun
a702aace9c
htlcswitch: add new concurrentTester wrapper struct
In this commit we add a new wrapper struct for the testing.T struct
that allows multiple clients to attempt to fail a given test at the
same time.
2017-11-11 15:05:15 -08:00
Olaoluwa Osuntokun
632f230fef
htlcswitch: add quit case to initial channel state sync select in channelLink
In this commit we add a quit case to the select statement that’s
entered once a link is created. Before this commit, upon restart it
would be possible that the deamon would never ben able to shutdown as
the link would be waiting for the messages to be sent by the other
side.
2017-11-10 19:51:13 -08:00
Olaoluwa Osuntokun
431f6fc2c8
htlcswitch: update TestChannelRetransmission to print out expected balance when failure 2017-11-10 19:51:08 -08:00
Olaoluwa Osuntokun
9a6e3b5d9c
htlcswitch: disable extra logging within TestChannelRetransmission 2017-11-10 19:51:07 -08:00
Olaoluwa Osuntokun
5e2b2a5cc8
htlcswitch: move retransmissionTests var into scope of test 2017-11-10 19:51:07 -08:00
Olaoluwa Osuntokun
fceec1306d
htlcswitch: update TestChannelLinkBandwidthConsistencyOverflow to account for HTLC fees 2017-11-10 19:51:06 -08:00
Olaoluwa Osuntokun
3e00b2a0a9
htlcswitch: update TestChannelLinkBandwidthConsistency to account for HTLC fees 2017-11-10 19:51:06 -08:00
Olaoluwa Osuntokun
d7cc3c5015
htlcswitch: account for FundingLocked retransmission in TestChannelLinkSingleHopMessageOrdering 2017-11-10 19:51:05 -08:00
Olaoluwa Osuntokun
0dc98d9955
htlcswitch: fix TestChannelLinkMultiHopInsufficientPayment add additional comment 2017-11-10 19:51:05 -08:00
Olaoluwa Osuntokun
a558925978
htlcswitch: correct godoc comment on TestLinkForwardTimelockPolicyMismatch 2017-11-10 19:51:05 -08:00
Olaoluwa Osuntokun
f39ffd67ef
htlcswitch: update getChanID to be aware of FundingLocked
In this commit, we update getChanID to be aware of the FundingLocked
message as it will be retransmitted upon reconnect if both nodes think
that they’re at the very first commitment state.
2017-11-10 19:51:04 -08:00
Olaoluwa Osuntokun
cb85b2bd26
htlcswitch: update createTestChannel to adhere to latest channeldb API's 2017-11-10 19:51:04 -08:00
Olaoluwa Osuntokun
9873d4ece8
htlcswitch: update mockServer to be able to fail test directly 2017-11-10 19:51:03 -08:00
Olaoluwa Osuntokun
a48ceac98f
htlcswitch: update link to adhere to new channeldb API's 2017-11-10 19:51:03 -08:00
Olaoluwa Osuntokun
ea334e4d47
htlcswitch: re-write channel connection re-establishment for correctness
In this commit, we’ve re-written the process of syncing the state of
channels after we reconnect. This re-write ensure correctness, and also
simplified the existing logic which would attempt to launch another
goroutine to handle requests from the switch to ensure that it doesn’t
block. This is no longer necessary as the AddPacket method that the
switch indirectly calls is non-blocking.
2017-11-10 19:51:03 -08:00
Olaoluwa Osuntokun
de3af9b0c0
htlcswitch: modify Bandwidth() method on links to use more accurate accoutning
In this commit, we modify the existing implementation of the
Bandwidth() method on the default ChannelLink implementation to use
much tighter accounting. Before this commit, there was a bug wherein if
the link restarted with pending un-settled HTLC’s, and one of them was
settled, then the bandwidth wouldn’t properly be updated to reflect
this fact.

To fix this, we’ve done away with the manual accounting and instead
grab the current balances from two sources: the set of active HTLC’s
within the overflow queue, and the report from the link itself which
includes the pending HTLC’s and factors in the amount we’d need to (or
not need to) pay in fees for each HTLC.
2017-11-10 19:51:02 -08:00
Olaoluwa Osuntokun
70ed50738a
htlcswitch: utilize memoryMailBox within link, no longer spawn goroutine to forward in switch
In this commit, we’ve modified the link and the switch to start to use
the new mailBox in place of the existing synchronous message send
directly into the link’s upstream/downstream channels. With his change,
we no longer need to spawn a new goroutine each time an HTLC needs to
be forwarded, or a user payment is initiated.
2017-11-10 19:51:02 -08:00
Olaoluwa Osuntokun
890559edfa
htlcswitch: add new mailBox abstraction to the package
In this commit, we add a new abstraction to the package: the mailBox.
The mailBox is a non-blocking, concurrent safe, in-order queue for
delivering messages to a given channelLink instance. With this
abstraction in place, we can now allow the switch to no longer launch a
new goroutine for each forwarded HTLC, or instantiated user payment.
2017-11-10 19:51:01 -08:00
Andrey Samokhvalov
9247168c5d not finished index persistence 2017-11-09 16:38:58 -08:00
Andrey Samokhvalov
a10ed36e8f htlcswitch+lnwallet: add malformed payment descriptor 2017-11-09 16:38:58 -08:00
Andrey Samokhvalov
e29193d550 htlcswitch+channel: remove cancel reasons from channel link 2017-11-09 16:38:58 -08:00
Andrey Samokhvalov
1b4e723a5d htlcswicth+channel: switch to store onion blobs in payment descriptor
After addition of the retransmission logic in the channel link, we
should make the onion blobs persistant, the proper way to do this is
include the onion blobs in the payment descriptor rather than storing
them in the distinct struct in the channel link.
2017-11-09 16:38:57 -08:00
Andrey Samokhvalov
3555c4c463 htlcswitch: fix clean of channel link 2017-11-09 16:38:57 -08:00
Andrey Samokhvalov
291232f0c3 htlcswicth: fix deadlock
After addition of the channel reestablish message exchange we couldn't
use the Bandwidth() function, at least in the test framework.
2017-11-09 16:38:57 -08:00
Andrey Samokhvalov
d70ffe93e4 htlcswitch+channel: add channel states synchronization
In this commit BOLT№2 retranmission logic for the channel link have
been added. Now if channel link have been initialised with the
'SyncState' field than it will send the lnwire.ChannelReestablish
message and will be waiting for receiving the same message from remote
side. Exchange of this message allow both sides understand which
updates they should exchange with each other in order sync their
states.
2017-11-09 16:38:57 -08:00
Andrey Samokhvalov
bea9c0b52b htlcswitch: make stop of the link not in the goroutine
In order to be able to properly restart switch several times we should
have the sequential process of channel link stop. In other words if we
stopped the switch we should be sure that all channel links have been
stopped too. Addition of the goroutine during the force close was added
because of the deadlock:

Trace:
1. link:force_close_notification
2. link:wipe_channel
3. peer:switch_remove_link
4. switch:stop_link
5. link:wait <-- deadlock
2017-11-09 16:38:57 -08:00
Andrey Samokhvalov
25efbb61a4 htlcswicth.test: add 'future' payment response
Add js-like future object which might be used to wait for the response
to be received or return the error otherwise.
2017-11-09 16:38:57 -08:00
Andrey Samokhvalov
e170b43615 htlcswitch.test: add server error channel to concurrent access panic
This commit where added as a measure to avoid the panic during several
server simultanoius fault. The panic happened becuase *t.Testing
structure is not concurrent safe.
2017-11-09 16:38:57 -08:00
Andrey Samokhvalov
1eb906bcfb htlcswitch.test: add message interceptor handler
Add message interceptor which checks the order and may skip the
messages which were denoted to be skipeed.
2017-11-09 16:38:56 -08:00
Johan T. Halseth
df17a680c4
htlcswitch test: use signDesc.HashType instead of SigHashAll in mock
signer.
2017-11-06 14:31:22 +01:00
Jim Posen
a13ad0a339 multi: Fix various typos. 2017-10-25 13:20:54 -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
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
e02af3f877
htlcswitch: as exit node check for invoice and HTLC value match after existence 2017-10-22 18:37:00 -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
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