Commit Graph

7225 Commits

Author SHA1 Message Date
Olaoluwa Osuntokun
13a95be7c0
build: update glide dependancies 2016-07-26 10:43:20 -07:00
Olaoluwa Osuntokun
7c1ec62e44
cmd/lncli: switch to urfave/cli instead of codegangsta/cli
The original project has been migrated to a new user. Currently git
redirects are served from the old repository to the newness. However
since development has witched to this new repository we update our
imports for clarity.
2016-07-26 10:42:50 -07:00
Olaoluwa Osuntokun
c69661f2a5
build: run all tests after initial build 2016-07-25 16:45:42 -07:00
Olaoluwa Osuntokun
a75b56ce77
build: update travis CI config
This commit updates the previous travis CI config to pin against the
two latest golang versions, and perform installation via Glide.

Additionally, this should allow lnwallet’s integration tests to build
properly as the btcd binary will be available in the build process’
PATH.
2016-07-25 16:39:40 -07:00
Olaoluwa Osuntokun
7f186b3444
elkrem: remove extra prints from serdes tests 2016-07-25 16:37:59 -07:00
Olaoluwa Osuntokun
32ecbcf6c4
lndc: remove extraneous prints from tests 2016-07-25 16:35:25 -07:00
Olaoluwa Osuntokun
09219917a0
elkrem: remove logging statements from tests
This commit removes the logging statements within the elkrem tests as
they become rather spammy when executing on the continuous integration
server.
2016-07-25 16:17:08 -07:00
Olaoluwa Osuntokun
bdc22e67fa
lnwire: remove obsolete dual funder messages 2016-07-25 16:02:00 -07:00
Olaoluwa Osuntokun
82ea6ebf78
lnd: eliminate deadlock bug between htlcSwitch and htlcManager
This commit fixes a concurrency bug between the server’s htlc switch,
and an instance of a peer’s active htlc manager goroutine.

The deadlock condition was triggered when the htlc manager’s downstream
`htlcPacket` channel was full, causing the htlcSwitch’s main loop to
block on a send while the htlcManager was attempting to send a packet
to the switch for forwarding. This scenario created a circular
dependency resting in a deadlock.

The fix for this bug is relatively straight forward, if the destination
interface is found when handling an outgoing payment, then a new
goroutine is spawned to complete the request.
2016-07-24 17:06:19 -07:00
Olaoluwa Osuntokun
06f32cd5bc
lnd: drop the port from the default rpc host
Drop the port from the default RPC host as the proper port will be
filled in depending on which net is chosen.
2016-07-24 16:38:52 -07:00
Olaoluwa Osuntokun
5588aa5c42
lnd: update build+installation instructions to use glide
This commit updates the build, installation, and upgrade instructions to use
Glide which allows for reproducible builds using Golang 1.5 or 1.6.

As a result, if one wishes to ensure they've properly installed lnd, the `go
get` command can no longer be used to install lnd.
2016-07-23 16:12:40 -07:00
Olaoluwa Osuntokun
32cde069b5
add entry in gitignore to exclude the local vendor folder 2016-07-22 19:00:30 -07:00
Olaoluwa Osuntokun
c8e58147b6
add glide dependency management for fully reproducible builds
This commit adds glide integration in order to make lnd builds fully
reproducible. Rather than using “go get” users should now manually pull down
the repo, use glide to fetch+install the dependancies, then manually install
all related binaries.

With this change we no longer have to chase dependancies making breaking API
changes under us. We can manually update the managed dependancies once a new
stable release of a defendant package is released.

Additionally, reproducible builds are a strong requirement in order to securely
distribute future major releases of lnd.
2016-07-22 18:53:35 -07:00
Olaoluwa Osuntokun
adb23a366f
lnd: implement update pipelining and htlc trickling+batching
This commit *significantly increases* the payment throughput per-core,
per-channel of the daemon.

With this commit updates are properly pipelined respecting the current
revocation window, htlc updates are batched, a timer is checked to push
chain convergence, and htlc update below the batch size are
periodically flushed to the remote chain.

The current pending update timer, trickle timer, and batch size have
been arbitrarily chosen based on my local tests. In the future these
parameters should be chosen to optimize response-time and throughput
after measurements are gathered.
2016-07-21 17:10:49 -07:00
Olaoluwa Osuntokun
c0a28e3b7f
lnd: buffer upstream/downstream channels for htlc managers 2016-07-21 16:53:15 -07:00
Olaoluwa Osuntokun
2bb65a3fb8
lnwallet: add PendingUpdates method to channel state machine
This commit adds a new method, “PendingUpdates” to the channel state
machine which is intended to be a source to give callers a hint as to
when an additional commitment signature should be sent independent of
any request/response book keeping.
2016-07-21 16:52:18 -07:00
Olaoluwa Osuntokun
4063171918
lnwallet: partition state update logs within channel state machine
This commit patrons the state update logs properly within the channel
state machine. This change fixes a number of bugs caused by treating a
central log as two logically distinct logs. Rather than having a bit
indicating if the entry is incoming/outgoing, an entry is added to a
remote or local log depending on which modification method is used.

As a result the code is much easier to follow due to separation of
concerts.

Finally, when attempting to sign a new update with an exhausted
renovation window a distinct error is returned in order to allow higher
level callers to properly back-off and handle the protocol event.
2016-07-21 16:50:38 -07:00
Olaoluwa Osuntokun
35bca369e7
lnd: rpcServer now asynchronously handles bi-di sendpayment streams 2016-07-21 16:23:06 -07:00
Olaoluwa Osuntokun
979b43a3b8
lnd: add log ticker to htlcSwitch, log metrics before forwarding
This commit adds a ticker which attempts to print the total volume
sent/recv over the last 10 seconds if any updates took place during
that interval.

Additionally, when selecting a link to forward an htlcPacket insert a
break after selection in order to properly terminate the loop.
2016-07-21 16:21:33 -07:00
Olaoluwa Osuntokun
65435bd8e6
cmd/lncli: close sendpayment stream after recv
We now close the send payment stream after receiving a response.
Otherwise if the RPC server is asynchronously handling requests then,
closing the stream would result in the server returning an EOF error,
terminating the request.
2016-07-21 16:18:56 -07:00
Olaoluwa Osuntokun
504c8bf5f3
channeldb: bucket not found during .Wipe() is no longer an error
This commit changes the current behavior around channeldb.Wipe().
Previously if a channel had never been closed, and a wipe was
attempted, then wipe operation would fail and the transaction would be
rolled back.

This commit fixes this behavior by checking for bolt.ErrBucketNotFound
error, and handling the specific error as a noop.
2016-07-21 16:16:28 -07:00
Olaoluwa Osuntokun
6283eb29bf
lnd: add synchronization to RPC initiated HTLC payments
With this commit, calls to htlcSwitch.SendHTLC() are now synchronous,
only returning after the payment has been fully settled. This will
allow one to accurately measure the commitment update speed with the
current state machine implementation which is missing a number of
low-hanging optimizations.

The htlcManager for each channel now keeps a map of cleared HTLC’s
keyed by the index number of the add entry within the state machine’s
HTLC log. This map of HTLC’s will later be used to properly implement
time outs

Additionally, a slight refactoring has been executed w.r.t handling
upstream/downstream messages. This cleans up the main htlcManager loop,
freeing it up for the addition of future logic to properly observe
timeouts as well as, proper batching+trickling of HTLC updates, and a
commitment signature ticker.
2016-07-16 18:21:01 -07:00
Olaoluwa Osuntokun
b60270f3f7
lnwallet: include htlcs to settle in returned set of htlc's to forward
This commit fixes a slight bug in the channel state machine’s code
executed when processing a revocation messages. With this commit after
processing a revocation, log entries which we should forward to the
downstream or upstream peer for settling/adding HTLC’s are now properly
returned.

The testa have also been updated to ensure to correct htlc’s are
returned “for forwarding”.
2016-07-16 18:12:49 -07:00
Olaoluwa Osuntokun
2c303a1879
lnwallet: AddHTLC now returns log index of created log entry 2016-07-16 18:02:09 -07:00
Olaoluwa Osuntokun
2a57f9182a
lndc+lnd: fix panic when connecting to multiple peers, plus duplicate conn detection 2016-07-16 18:01:05 -07:00
Olaoluwa Osuntokun
9780f06faf
lnd: don't print error messages twice during initialization 2016-07-16 17:56:32 -07:00
Olaoluwa Osuntokun
62fb3a9fee
docker: add single command docker build+run for btcd+lnd
This commit adds two Dockerfiles, along with a docker-compose file
which links the two docker files together allowing for single-command
deployment.

Using the docker-compose file, two containers are deployed. One running
btcd, and the other running lnd. Both containers share the same shared
volume mounted to the file system in order to allow land to read btcd’s
certificates for the TLS RPC connections.

Additionally, the btcd instance comes will an automatic RPC
configuration generated allowing one to use btcctl out of the box via
calls to “docker-compose exec btcctl …”.
2016-07-16 17:55:29 -07:00
Olaoluwa Osuntokun
14aadc8c2e
cmd/lncli: add validation of address for connectpeer 2016-07-16 17:43:47 -07:00
Olaoluwa Osuntokun
a14246c5bb
lnwallet: use two-value read from conf channel to detect closure 2016-07-14 16:17:10 -07:00
Olaoluwa Osuntokun
32e5de301d
lnrpc: recompile generated files after updating to latest proto compiler
Soon we’ll be using dependency management/pinning to avoid having to
continually do this dance…
2016-07-14 16:16:19 -07:00
Olaoluwa Osuntokun
a56ab46e97
lnd: properly switch RPC port with target net change
With this commit, support for changing the target network (testnet,
simnet, etc) has been finalized. Previously a command line option was
present to swap networks, but the RPC port wouldn’t automatically be
updated to reflect the network.
2016-07-13 18:37:59 -07:00
Olaoluwa Osuntokun
98fae7f329
lnd: properly disconnect peer and clean up resources after critical errors 2016-07-13 16:40:07 -07:00
Olaoluwa Osuntokun
5912322995
lnd: unregister to htlcSwitch with nil chanPoint deletes all inks for interface 2016-07-13 16:35:52 -07:00
Olaoluwa Osuntokun
b9c29ad9fc
lnd: consolidate peerManager and queryHandler 2016-07-13 16:34:27 -07:00
Olaoluwa Osuntokun
496d1e8edc
lnd: manually set sig pending bit in commitment state machine
This commit fixes a class of bug which would trigger a never ending
loop of “null” commitment updates between two peers.
2016-07-13 16:31:50 -07:00
Olaoluwa Osuntokun
2926988710
cmd/lncli: implement one-off HTLC payments 2016-07-12 17:47:30 -07:00
Olaoluwa Osuntokun
91509681df
lnd: implement bi-directional streaming SendPayment in rpcserver 2016-07-12 17:46:31 -07:00
Olaoluwa Osuntokun
88949e181a
lnd: implement per-channel state-machine driver within peer
With this commitment, the daemon is now able to properly send+redeem
single-hop HTLC’s with another daemon running on the same network.

The htlcManager gains an additional channel which is reads from
receiving updates from either downstream peers, or the rpc server. An
htlcManager is spawned for each active channel with the remote peer. As
a result, the readHandler must now de-multiplex any messages which
update a known channel to the proper htlcManager.

Batching HTLC add updates with a trickle timer has not yet been
implemented, but will be in the near future along with several other
optimizations.
2016-07-12 17:45:36 -07:00
Olaoluwa Osuntokun
af7cfd6c8b
lnd: add basic HtlcSwitch logic for forwarding L2 payments 2016-07-12 17:40:39 -07:00
Olaoluwa Osuntokun
9b29fa3a52
lnd: use channel barriers to synchronize on-chain events and a peer's readHandler 2016-07-12 17:38:14 -07:00
Olaoluwa Osuntokun
09f6ecef1f
lnrpc: add bi-directional streaming SendPayment RPC 2016-07-12 17:36:40 -07:00
Olaoluwa Osuntokun
7dea354711
lnwallet: properly handle HTLC settles in channel state-machine
We no longer track HTLC’s by their r-hash within the log into the
index, as we may have multiple HTLC’s that can be redeemed by the same
pre-image. Instead we now use a separate index which is keyed by a
log-index.

Additionally, the SettleHTLC method now also returns the index of the
HTLC being settled which allows the remote party to quickly locate the
HTLC within their log.

This commit also introduces a few trace/debug log messages which will
likely be pruned in the near future
2016-07-12 17:35:57 -07:00
Olaoluwa Osuntokun
06f062e678
lnwallet: sync revocation state after receiving a revocation 2016-07-12 17:32:42 -07:00
Olaoluwa Osuntokun
14d669dfd1
lnwallet: decrease initial revocation window to 4 2016-07-12 17:31:01 -07:00
Olaoluwa Osuntokun
56fb414767
channeldb: add method to sync revocation state to disk 2016-07-12 17:26:53 -07:00
Olaoluwa Osuntokun
e1d5878df4
lnd: introduce the InvoiceRegistry
This commit introduces the invoice registry which is a central
repository of all outstanding invoices related to the daemon.

This registry will be used by the goroutines which manage the htlc’s
for a particular channel, and later by the point-to-point workflow
which negotiates the conditions for payment along with signed recipes.
2016-07-12 17:14:16 -07:00
Olaoluwa Osuntokun
0b86c01067
lnwire: fix CommitSignature max payload length
This commit increase the max allowed payload length for the
CommitSignature method in order to account for the added 8 byte log
index.
2016-07-12 17:07:40 -07:00
Olaoluwa Osuntokun
c8de0924ba
lnwire: properly display channel points in .String() methods 2016-07-12 17:05:18 -07:00
Olaoluwa Osuntokun
9b5e487893
lndc: remove print debug print statements 2016-07-12 17:04:14 -07:00
Olaoluwa Osuntokun
850feed877
lnd: switch to nested a main function, fix defer execution
This commit adds a new nested main function “lndMain”, within the
packages’s normal main function. This nesting is required in order to
properly execute all queued defer statements in the case of a forced
exit.
2016-07-12 17:03:33 -07:00