Commit Graph

1103 Commits

Author SHA1 Message Date
Olaoluwa Osuntokun
95380fee1b
test: add async txn seen notifications to network harness
This commit adds a new feature to the network harness enabling callers
to receive async notifications once a particular transaction is seen on
the network. Such a feature is useful when due to the asynchronous
behavior of node communications.

With this new feature, tests can now wait for a particular transaction
to be seen within the network before proceeding.
2016-08-30 19:34:25 -07:00
Olaoluwa Osuntokun
9eb2a4219f
lncli: update response handling for open/close channel
This commit updates the response handling of the steaming RPC’s to
account for the fact that multiple messages from the server (state
updates) can now be sent over the stream instead of a single final
update.

Currently, all updates other than the “final” update are ignored by the
cli.
2016-08-30 16:54:59 -07:00
Olaoluwa Osuntokun
832fd248cd
lnd: add async updates for [open|close]channel RPC's
This commit modifies the internal workflow for opening or closing a
channel in order to create a path in which RPC clients can receive
updates. Updates are now communicated via channels from the goroutines
spawned by the RPC server to process the request, and the sub-system
within the daemon that actually executes the request.

With this change clients can now receive updates that the request is
pending (final message has been sent to the target client), or that the
request has been completed. Confirmation related updates have not yet
been implemented as that will require some changes to the ChainNotifier
interface.
2016-08-30 16:53:07 -07:00
Olaoluwa Osuntokun
05ac8d3c47
test: speed up integration test harness initialization
This commit speeds up the integration test initialization by launching
the processes of the two seeder nodes concurrently rather than
serially.

Additionally, the harness will now block until the wallets of both the
seeder nodes are fully synced up.
2016-08-30 16:44:51 -07:00
Olaoluwa Osuntokun
d548e56069
lnrpc: OpenChannel and CloseChannel now return "status updates"
This commit modifies the prior protos to make the open/close channel
RPC commands return the “union” status update rather than a concrete
item of that union directly. With this change, RPC clients can now
receive status updates of the current state of the opening or closing
channel.
2016-08-30 16:42:34 -07:00
Olaoluwa Osuntokun
164db26a11
build: install lnd binary within Travis container for integration tests 2016-08-30 11:14:42 -07:00
Olaoluwa Osuntokun
1ace7ede01
lnd: fix build for Go 1.6.3, refer to old context package
This commit fixes the build for version 1.6.3 of golang. In go 1.7, the
“context” package was moved into the standard library, however go 1.6.3
doesn’t have that change, so we must refer to the prior WIP package
until a new version of Go is released.
2016-08-30 11:12:38 -07:00
Olaoluwa Osuntokun
50186f9460
build: remove GO15VENDOREXPERIMENT flag as go1.5 has been dropped 2016-08-29 22:15:49 -07:00
Olaoluwa Osuntokun
b21c8eccf0
lnd: add basic integration test using the networkHarness
This commit adds an initial integration test to the project which
exercises some basic channel opening/closing functionality between two
lnd nodes.
2016-08-29 22:08:00 -07:00
Olaoluwa Osuntokun
2032723efc
lnd: add infrastructure for integration testing
This commit introduces a simple piece of infrastructure for integration
testing: the networkHarness.

The harness allows for the creation and orchestration of a small
testbed of lnd nodes. The harness includes an instance of btcd’s
rpctest.Harness which allows driving certain actions in a mock Bitcoin
network to exercise relevant lnd behavior(s). By default, the harness
creates two instances of lnd (Alice and Bob), then establishes a
peer-to-peer connection between them. Created lnd nodes within the test
network can be driven programmatically by gRPC connections to their
respective RPC severs.

Later on more features will be added such as adding additional nodes,
opening channels between nodes, creating scripting topologies, etc,
2016-08-29 21:55:05 -07:00
Olaoluwa Osuntokun
0085e2a38a
config: add an option to pass in a hex-encoded rpc cert (--rawrpccert)
This commit adds an option to pass in a raw hex-encoded rpc cert via
lnd’s configuration file. Such a change allows for programmatically
creating lnd nodes which can connect to an existing btcd instance
without requiring a file for the rpc cert to be specified.
Additionally, this commit makes the creation of an integration testing
harness easier.
2016-08-29 21:39:06 -07:00
Olaoluwa Osuntokun
a03126ed83
config: remove rpckey parameter 2016-08-29 21:33:12 -07:00
Olaoluwa Osuntokun
9a4a52ed89
docker: revamp docker set up to allow for an LN test cluster
This commit revamps the existing docker configuration to allow for
developer’s to easily bring up/down a Lightning Network testbed
environment.

Configuration related bugs within the prior swarm set up have been
fixed. The launched lnd nodes are now able to properly communicate with
the primary btcd node over RPC. The auto-generated RPC script has been
scrapped in favor of hard-coding a developer-only set of RPC
credentials. With this change, it’s now possible to add/remove
additional lnd nodes in order to test more complex scenarios.

Additionally, the containers now build off of the latest Go version
(1.7).
2016-08-29 15:18:04 -07:00
Olaoluwa Osuntokun
4e416da4cd
htlcswitch: properly update channel bandwidth after payment recv
This commit fixes an omission within the htlcSwitch. With this commit,
a channels bandwidth is now properly updated once an incoming HTLC is
settled.

This also fixes a bug where if a node received a payment, it wouldn’t
be able to then utilize the newly available bandwidth to send further
payments.
2016-08-25 16:30:28 -07:00
Olaoluwa Osuntokun
04e7a88a83
lnwallet: fix bug in lockTimeToSequence function
This commit fixes a bug in the lockTimeToSequence function when mapping
a block-based relative lock time to the proper sequence number.

Applying the mask isn’t necessary since the values are expected to be
blow 65K blocks.
2016-08-25 16:25:32 -07:00
Olaoluwa Osuntokun
37484239fb
build: update Travis to build/test against go 1.7 + go 1.6.3 2016-08-25 14:31:44 -07:00
Olaoluwa Osuntokun
4bc315d061
lnd: minor clean up with comments + go fmt after latest PR merge 2016-08-11 11:56:03 -07:00
Olaoluwa Osuntokun
c0d59a2d85
lnwire: rename routing files to match current naming conventions
This commit drops the “_message” at the end of each of the newly added
routing files.
2016-08-11 11:54:56 -07:00
Olaoluwa Osuntokun
3563d0e6b9
build: update glide dependancies 2016-08-11 11:36:37 -07:00
Olaoluwa Osuntokun
61ba20dfc1
lnrpc: recompile protos to add routing table cmd's 2016-08-11 11:31:21 -07:00
BitfuryLightning
f8c851769f multi: initial integration of routing module
This commit integrates BitFury's current routing functionality into lnd. The
primary ochestration point for the routing sub-system in the routingMgr. The
routingMgr manages all persistent and volatile state related to routing within
the network.

Newly opened channels, either when the initiator or responder are inserted into
the routing table once the channel is fully open. Once new links are inserted
the routingMgr can then perform path selection in order to locate an "optimal"
path to a target destination.
2016-08-11 11:20:27 -07:00
Olaoluwa Osuntokun
fc16159a37
lnd: perform HTLC forwarding to switch in distinct goroutine
This commit optimizes the previous deadlock bug-fix within the peer’s
channelManager which handles driving the LCP state machine with
additional context-specific state.

Rather than forwarding to the HTLC switch within the primary loop which
handles fully locked-in HTLCs, we now launch a distinct goroutine which
is responsible for properly forwarding lock-in HTLC’s to the
htlcSwitch.
2016-08-03 11:29:24 -07:00
Olaoluwa Osuntokun
e5b6270465
README: add travis svg badge showing build status 2016-07-28 11:27:51 -07:00
Olaoluwa Osuntokun
2a5fa0522d
build: update travis script to exclude the vendor dir when running tests 2016-07-28 11:23:48 -07:00
Olaoluwa Osuntokun
4104a9bcde
lnwallet: never create zero-value outputs within the commitment transaction 2016-07-27 12:15:50 -07:00
Olaoluwa Osuntokun
c0614c0478
lnwallet: add basic tests for cooperative channel closure
This commit adds a basic test for cooperative channel closure. The
current test ensures correctness of the cooperative closure procedure
initiated by either the channel initiator, or the channel responder.
2016-07-27 11:32:35 -07:00
Olaoluwa Osuntokun
e01dd7f18d
lnwallet: properly make channelState an enum by using iota 2016-07-27 11:29:49 -07:00
Olaoluwa Osuntokun
8a56fbf196
lnwallet: switch name of package logger to avoid module collision 2016-07-27 11:29:07 -07:00
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