Commit Graph

2410 Commits

Author SHA1 Message Date
Olaoluwa Osuntokun
fe2b8ccb29
utxonursery: fix typo in contractMaturityReport definition 2017-09-25 12:48:25 -07:00
Olaoluwa Osuntokun
be5b2d46a5
htlcswitch: ensure the packetQueue can handle total+partial commitment overflows
In this commit, we’ve moved away from the internal queryHandler within
the packetQueue entirely. We now use an internal queueLen variable
internally to allow callers to sample the queue’s size, and also for
synchronization purposes internally.

This commit also introduces a chan struct{} (freeSlots) that is used
internally as a semaphore. The current value of freeSlots reflects the
number of available slots within the commitment transaction. Within the
link, after an HTLC has been removed/modified, then a “slot” is freed
up. The main packetConsumer then interprets these messages as a signal
to attempt to free up a new slot within the queue itself by dumping off
to the commitment transaction.
2017-09-25 12:47:34 -07:00
Olaoluwa Osuntokun
210fc6e714
htlcswitch: eliminate internal queryHandler within packetQueue
This commit removes the internal queryHandler within the packetQueue
itself in order to make way for an upcoming commit which uses atomic
variables to report the length of the queue to outside callers.
Additionally, due to the recent change within the channeling, we no
longer need to report the total value of all pending HTLC’s to the
outside world.
2017-09-25 12:34:56 -07:00
Olaoluwa Osuntokun
64317c04f1
htlcswitch: use atomic integer to track link bandwidth internally
This commit modifies the way the bandwidth of a given channel link is
tracked, and reported externally. The prior approach pushed most of the
logic for tracking channel bandwidth into the link itself, and relied
on a report from the queue in order to determine the total available
bandwidth. This approach at times could inadvertently introduce
deadlocks when working on new features as since the query was handled
internally, it required the link to be _active_ and non-blocked in
order to respond to.

We’ve now abandoned this approach in favor of lifting the bandwidth
accounting to the highest possible abstraction layer within the link
itself. We now maintain a availableBandwidth integer that’s used
atomically within the link in response to: us adding+settling an HTLC,
and the remote party failing one of our HTLC’s.
2017-09-25 12:31:59 -07:00
Olaoluwa Osuntokun
8ecb8c70bb
htlcswitch: properly populate CommitFee for channels created in tests 2017-09-25 11:07:33 -07:00
Olaoluwa Osuntokun
bd63e048d8
server: remove stray logging debugging statement from peerBootstrapper 2017-09-25 11:06:47 -07:00
Olaoluwa Osuntokun
21d151d2ce
lnwallet: ensure the goroutines of all channels are stopped after test execution 2017-09-24 20:20:15 -07:00
Olaoluwa Osuntokun
9164cc218a
lnwallet: modify ReceiveFailHTLC to return value of HTLC failed 2017-09-24 20:17:53 -07:00
Olaoluwa Osuntokun
f576a74bf6
lnwallet: modify SettleHTLC to return value of HTLC settled
This commit adds an additional return value to SettleHTLC in order to
make way for an upcoming change to modify the way bandwidth status from
the link to the switch is reported.
2017-09-24 20:17:14 -07:00
Olaoluwa Osuntokun
2bf8d1b3fb
lnwallet: ensure all channel tests run in parallel 2017-09-24 20:14:30 -07:00
Olaoluwa Osuntokun
c85fcf2885
lnwallet: add test case for ErrInsufficientBalance error in channel state machine 2017-09-24 20:13:46 -07:00
Olaoluwa Osuntokun
815826caac
lnwallet: remove public LocalAvailableBalance method from channel
This commit removes the current active LocalAvailableBalance method
from the channel state machine itself. We still maintain the internal
availableLocalBalance method locally as this is used to ensure that we
don’t add an HTLC which puts our available balance below zero.
2017-09-24 20:13:04 -07:00
Olaoluwa Osuntokun
5ff82c92da
channeldb: add commitment transaction fee to ChannelSnapshot 2017-09-24 20:09:28 -07:00
Olaoluwa Osuntokun
37d03d1e56
peer: avoid possible GC leak by setting popped queue element to nil 2017-09-24 20:08:34 -07:00
Olaoluwa Osuntokun
457aebd16f
htlcswitch: ensure channel state machine is stopped on link stoppage 2017-09-22 15:56:12 -07:00
Olaoluwa Osuntokun
be62188962
htlcswitch: fix minor typos in switch test file 2017-09-22 15:54:43 -07:00
Olaoluwa Osuntokun
6f5ef249e4
htlcswitch: re-write link's packet overflow queue for readability+extensibility
This commit completes a full re-write of the link’s packet overflow
queue with the goals of the making the code itself more understandable
and also allowing it to be more extensible in the future with various
algorithms for handling HTLC congestion avoidance and persistent queue
back pressure.

The new design is simpler and consumes much less coroutines (no longer
a new goroutine for each active HLTC). We now implement a simple
synchronized queue using a standard condition variable.
2017-09-22 15:54:16 -07:00
Olaoluwa Osuntokun
94b54f0243 Merge pull request #264 from cfromknecht/sweep-2nd-layer-htlcs
Breach Arbiter Sweep 2nd layer HTLCs
2017-09-20 17:18:47 -07:00
Conner Fromknecht
ec288ddf5b
ba+utxno: final pass for formatting 2017-09-19 19:18:21 -07:00
Conner Fromknecht
47356493f3
lnwallet/signdesc: increases max witness parsing length 2017-09-19 19:18:21 -07:00
Conner Fromknecht
de1063200a
lnwallet/script_utils: adds public receiver+sender htlc revoke w/key derivation 2017-09-19 19:18:21 -07:00
Conner Fromknecht
84abc962c4
lnwallet/witnessgen: adds htlc offered+accepted revoke witness type 2017-09-19 19:18:21 -07:00
Conner Fromknecht
faf1d40bd0
lnwallet/channel: adds directionality htlc retributions
This commit also adds an incoming flag to
        HtlcRetribution struct to allow the breach arbiter to
        generate the appropriate witness based on the htlc's
        directionality.

        It also ensures that the size of the htlc retribution
        slice is now determined by the size of the number of
        htlcs present in the revoked snapshot, which fixes a
        minor bug that could lead to nil pointer deferences.
2017-09-19 19:18:20 -07:00
Conner Fromknecht
7ee7bf840a
breacharbiter_test: properly assigns SignDescriptor w/o ptr 2017-09-19 19:18:20 -07:00
Conner Fromknecht
e32d3024ae
server: instantiate breacharbiter using BreachConfig 2017-09-19 19:18:20 -07:00
Conner Fromknecht
a8d667ba35
breacharbiter: sweep incoming + outgoing htlcs
This commit also adds a BreachConfig to abstract
  the instantiation of the breach arbiter, as well
  as various formatting improvements.
2017-09-19 19:18:20 -07:00
Conner Fromknecht
b64d4356c1
lnd_test: adds breach test for remote hodl
This commit alters the existing retribution
  post breach conf test case with the intention
  of testing the correct response in event that
  the remote party broadcasts a prior state
  while HTLCs have been extended. This serves
  as a preliminary integration for an expansion
  of the breach arbiter integration tests.

  The primary change involves using the new
  htlchodl mode for debugging, which causes the
  remote peer to ignore any intent to settle
  incoming HTLCs. The result is that any
  payments sent to the remote party are held in
  limbo, allowing us to test for these
  conditions more accurately.

  Currently the test case only tests that the
  justice transaction is mined. After we have
  fully integrated the breach arbiter to sweep
  2nd layer HTLCs, this test will be altered
  to check for spends from the appropriate
  inputs.
2017-09-19 19:18:20 -07:00
Conner Fromknecht
b3a80f7628
lnwallet/size: updated with recent BOLT 5 constants 2017-09-19 19:18:19 -07:00
Conner Fromknecht
f0ac991979
breacharbiter: use BOLT 5 constants 2017-09-19 19:18:19 -07:00
Conner Fromknecht
7f93aec31c
utxonursery: remove use of pointer to lnwallet.Signer iface 2017-09-19 19:18:19 -07:00
Conner Fromknecht
da250cd79b
lnwallet/witnessgen: remove use of pointer to Signer iface 2017-09-19 19:18:19 -07:00
Conner Fromknecht
9cc9977f95
breacharbiter_test: modify test vectors to support new structs 2017-09-19 19:18:19 -07:00
Conner Fromknecht
d88804178e
breacharbiter: unifies ba sweep txn creation 2017-09-19 19:18:14 -07:00
Olaoluwa Osuntokun
a314e661bd
build: update to latest lighting-onion commit
This commit updates `lnd` to the latest version of our Sphinx repo as
it has included a bug fix to use the proper version within the Sphinx
routing header.
2017-09-19 18:11:14 -07:00
whythat
1379488e72 macaroons: rename PermissionsConstraint to AllowConstraint 2017-09-19 16:46:20 -07:00
whythat
7df503575c macaroons: add error reporting for macaroon constraints 2017-09-19 16:46:20 -07:00
whythat
679e86174f macaroons: add IP lock macaroon constraint 2017-09-19 16:46:20 -07:00
whythat
a6b9155150 macaroons: use constraint layer for macaroon tweaking 2017-09-19 16:46:20 -07:00
whythat
5c3493bd30 macaroons: add constraint/checker options layer 2017-09-19 16:46:20 -07:00
nsa
d65f17f1b1 fuzzing: fixed calculation of serializedSize() in features.go
This commit fixes an incorrectly calculated size of a
*FeatureVector in the serializedSize() function. go-fuzz
found that when calling NewFeatureVectorFromReader, if
a flag is invalid, it is not added to f.flags. However,
it will skip the index that wasn't included. This
becomes a problem when serializedSize() calculates the
length of f.flags via len() which can lead to an index
out of range since certain flags may be missing.
2017-09-19 16:21:31 -07:00
Johan T. Halseth
7662ea5d4d invoice: Add invoice package
The invoice package can be used to encoded and decode invoices
in the format defined in BOLT-0011. This format utilizes bech32
encoding to create invoices that can be shared and understood
by the different Lightning implementations.
2017-09-19 12:05:58 -07:00
Johan T. Halseth
ff4ca664e3 lnwire: export SerializeSigToWire and DeserializeSigFromWire 2017-09-19 12:05:58 -07:00
Conner Fromknecht
74322a99be config+htlclink+peer: htlc hodl mode!
This commit adds a new debug mode for lnd
  called hodlhtlc. This mode instructs a node
  to refrain from settling incoming HTLCs for
  which it is the exit node. We plan to use
  this in testing to more precisely control
  the states a node can take during
  execution.
2017-09-19 11:31:52 -07:00
John
8fc14a7308 rpc: add additional go 1.8 TLS cipher suites 2017-09-19 05:45:31 +02:00
Pat White
d0685730bd docker: don't specify datadir in lnd container
In this commit, we fix a lingering issue in the execution 
of the lnd container, after the new macaroon based 
authentication was added. With the new authentication 
feature, if the datadir was changed, but `lncli` wasn't 
updated to point to the macaroon path, then none of 
the commands would work. 

To fix this, we simply omit setting the data directory.
2017-09-19 05:42:48 +02:00
halseth
8693e8babc channeldb: check chanIndex bucket for nilness instead of edges 2017-09-19 05:40:29 +02:00
funyug
90d13cf70c README: fix incorrect links to dev sites
This commit fixes two incorrect links in the readme to
dev.lightning.community and api.lightning.community. The two links were
lacking the http:// prefix, and Github's parser didn't automatically
recognize the new TLD. As a result, the links wouldn't automatically
show as clickable. With this commit, we've added the prefix, ensuring
that the links are properly clickable.
2017-09-18 20:26:23 -07:00
Olaoluwa Osuntokun
f9ca4631ff
lnwire: fix linter error 2017-09-18 17:40:29 -07:00
Olaoluwa Osuntokun
6e7fcac1f5
lnwire: properly encode/decode addrs in NodeAnnouncement msg
This commit fixes an existing deviation in the way we encode+decode the
addresses within the NodeAnnouncement message with that of the
specification. Prior to this commit, we would encode the _number_ of
addresses, rather than the number of bytes it takes to encode all the
addresses.

In this commit, we fix this mistake by properly writing out the total
number of bytes, modifying our parsing to take account of this new
encoding.
2017-09-18 17:27:51 -07:00
Olaoluwa Osuntokun
3e97aa3931
test: within testListPayments also wait for bob to learn of channel 2017-09-18 17:16:47 -07:00