Commit Graph

1176 Commits

Author SHA1 Message Date
Olaoluwa Osuntokun aeb7cce7c3
channeldb: move serialization of outpoint into db txn in CloseChannel 2017-02-02 16:59:22 -08:00
Olaoluwa Osuntokun c1c1cabc4e
server: immediately return to caller when processing sendToPeer
This commit alters the logic of processing sendToPeer requests within
the server to immediately return to the caller after locating the
target peer.
2017-02-02 16:57:25 -08:00
Olaoluwa Osuntokun 3f6afa51b9
rpcserver: fix potential panic when opening channel to peer_id
This commit fixes a potential panic that could arise when one was
attempting to open a channel with the target peer identified by it’s
peerID and an error occurred. In this case, the nodepubKey pointer
would be nil, resulting in a panic when attempting to propagate the
error.

This commit fixes this bug by using a nil byte slice for the node’s
serialized pubkey in the case that the node was identified according to
ti’s peer ID.
2017-02-02 16:50:29 -08:00
Christopher Jämthagen 24a569b047 routing: add proper test for excessive number of hops 2017-02-02 00:24:16 -08:00
Christopher Jämthagen 4200d8a7e0 routing: check route length after edges for route is collected
This fixes the bug reproduced in #114. The prevHop map in newRoute may
include many more edges than what is used to produce the final route, and
thus the check prior to building the route could result with incorrect
errors being reported. We move this check to after the number of edges
to be used for the route is deduced.
2017-02-02 00:24:16 -08:00
Olaoluwa Osuntokun 08f0d0fbea
routing+rpcserver: move route querying+sending to SendPayment
This commit moves much of the logic for querying for a potential route,
constructing the HTLC including the Sphinx packet, and sending the
ultimate payment from the rpcServer to the ChannelRouter.

This movement paves the way for muilt-path path finding as well as
adding automatic retry logic to the ChannelRouter. Additionally, by
having the ChannelRouter construct the Sphinx packet, we’ll be able to
also include the proper time-lock and general per-hop-payload
information properly in the future.
2017-02-01 18:29:55 -08:00
Olaoluwa Osuntokun 4eebc7c994
peer: refactor the queueHandler to aggressively drain queue
This commit refactors the queueHandler slightly to be more aggressive
when attempting to drain the pending message queue.

With this new logic the queueHandler will now attempt to _completely_
drain the pendingMsgs queue by sending it all to the writeHandler
_before_ attempting to accept new messages from the outside
sub-systems. The previous queueHandler was a bit more passive and would
result in messages sitting the the pendingMessage queue longer than
required.
2017-02-01 17:02:03 -08:00
Olaoluwa Osuntokun 8731fadb46
utxonursery: log txid when sending sweep transaction 2017-02-01 16:53:14 -08:00
Olaoluwa Osuntokun 6333dfea8f
peer: fix memory alignment for integers used atomically on 32-bit archs
This commit fixes a panic that can occur on 32-bit systems to the
misalignment of a int64/uint64 that’s used atomically using the atomic
package. To fix this issue, we now move all int64/unit64 variables that
are used atomically to the top of the struct in order to ensure
alignment.

Cleaning up some dead-code, satoshisSent/satoshisReceived have been
removed as they aren’t currently used. Instead those values are
accessed directly from the channel themselves.
2017-01-30 00:53:17 -08:00
Andreas M. Antonopoulos 1bc011ae5a contrib: add basic bash completion for lncli 2017-01-29 18:12:53 -08:00
Cris Perez b0d1247531 Add chmod +x to start scripts in dockerfiles 2017-01-29 18:02:26 -08:00
juscamarena 68c40b05ff cmd/lncli: Update command usage info to match current commands 2017-01-29 18:00:42 -08:00
Olaoluwa Osuntokun 28aa092ac2
test: eliminate sleep by tightly polling for existence of node
This commit elminates a sleep in the testHtlcErrorPropagation test by
instead polling for the existence of our target in a tight loop. This
is a small patch over until we get a “topology client” within the
ChannelRouter. This method is robust and can be applied in future tests
until we get the notification client into the ChannelRouter.
2017-01-29 17:16:58 -08:00
Olaoluwa Osuntokun 51e38d7544
server: fix goroutine closure bug when broadcasting messages to peers
This commit fixes a goroutine closure bug introduced by a prior commit.
A prior commit launched a goroutine for each peer to broadcast the
messages in parallel. However, as written this caused the messages to
only be broadcast to a single peer. When launching goroutines in a
for-loop, the “range” variable is actually re-used and re-assigned
within each iteration of the for-loop. As a result, all goroutines
launched will bind onto the _same_ instance of the variable.

We fix this bug in this commit by properly binding the target peer to a
new variable within the closure that launches the goroutine.

Relevant sources:
  *
https://github.com/golang/go/wiki/CommonMistakes#using-goroutines-on-loo
p-iterator-variables
  * https://golang.org/doc/faq#closures_and_goroutines
2017-01-29 17:15:25 -08:00
Olaoluwa Osuntokun f18a21fc54
test: correct error message for htlc error propagation test 2017-01-29 17:08:02 -08:00
Olaoluwa Osuntokun 07f8dab560
cmd/lncli: rename --draw to --render for describegraph 2017-01-29 15:38:28 -08:00
Olaoluwa Osuntokun 1ee4c661bc
server: optimize message broadcast+targeted send
This commit slightly optimizes the process of broadcasting a message to
a list of peers, and also sending a set of messages to a target peer.

When broadcasting a message to a set of target peers, we now launch a
goroutine for each send as to not block the ChannelRouter on an
individual send. When sending a set of messages to a target peer, we
now give up the mutex as soon as we’ve access the map, rather than
holding onto it until the sending is complete.
2017-01-29 15:03:05 -08:00
Olaoluwa Osuntokun d94777acf6
zpay32: ensure argument to Decode is not an empty string
This commit fixes a possible panic which can arise within the library
due to poor user-data. We now explicitly check for an empty string,
exiting early if found within the Decode method.
2017-01-29 14:58:15 -08:00
Olaoluwa Osuntokun 629d276409
cmd/lncli: use jsonpb to son pretty-printing to disable omitempty
This commit uses protobuf’s jsonpb library rather than the built-in
json/encoding library to print the JSOn representation of the responses
from gRPC. By using this library, we are now able to properly display
any values from the response which are “non-truthy” (0, false, etc).
2017-01-29 14:56:39 -08:00
Olaoluwa Osuntokun f4f92bb8e7
cmd/lncli: ensure gRPC client is closed after request 2017-01-29 14:51:42 -08:00
Olaoluwa Osuntokun 3aaf291409
cmd/lncli: [describegraph] -- if rendering fails, display error 2017-01-25 18:29:32 -08:00
Olaoluwa Osuntokun a5d2dbf219
cmd/lncli: remove Z prefix from vertexes in describegraph rendering
This commit removes the prior work around to display a prefix of the
node’s public key as a vertex. It turns out that if you quote the
string, the it will escape all characters enclosed. This allows us the
drop the hacky “Z” prefix that we used before.
2017-01-25 18:27:35 -08:00
Olaoluwa Osuntokun 780203e287
rpcserver: display the number of satoshis sent/recv'd and ping time in ListPeers 2017-01-25 18:25:12 -08:00
Olaoluwa Osuntokun 3c5a23b2c1
peer: estimate RTT to peer using the ping and pong messages
This commit enhances the peer struct slightly be attempting to measure
the ping time to the remote node based on when we send a ping message
an dhow long it takes for us to receive a pong response.

The current method used to measure RTT is rather rough and could be
make much more accurate via the usage of an EMA/WMA and also via
attempting to measure processing time within the readMessage and
writeMessage functions.
2017-01-25 18:21:01 -08:00
Olaoluwa Osuntokun 3988473d45
lnrpc: add ping time to peer to the ListPeers response 2017-01-25 18:16:37 -08:00
Olaoluwa Osuntokun eb52f7f695
cmd/lncli: use .svg for graph rendering add weighted edge thickness 2017-01-24 18:07:23 -08:00
Olaoluwa Osuntokun 160317c9fa
cmd/lncli: correct usage for openchannel 2017-01-24 17:50:50 -08:00
Olaoluwa Osuntokun 9906e07087
peer: correct logging messages (to:writeMessage, from:readMessage) 2017-01-24 17:49:17 -08:00
Olaoluwa Osuntokun a658fabf48
funding: disallow channel creation before lnd is synced to the chain
This commit adds a new restriction around funding channels at the
daemon level: lnd nodes will not allow either the initiation or the
acceptance of a channel before the node is fully synced to the best
known chain.

This fixes a class of bug that arises when a new node joins the network
and either attempts to open a channel or has a channel extended to them
before the node is fully synced to the network.
2017-01-24 17:12:57 -08:00
Olaoluwa Osuntokun 73d5daa2c3
server: asynchronously handle internal broadcast/send requests
This commit modifies the request handling within the sever’s
queryHandler goroutine to ensure that requests from the ChannelRouter
or other related sub-systems don’t block the main processing loop.

We do this simply by launching a goroutine to handle the dispatch of
the request.
2017-01-24 17:06:32 -08:00
Olaoluwa Osuntokun ddc3c3ab35
server: ensure handleListPeers is threadsafe
Before this commit there was the possibility of a race occurring
between a call to the “lispers” cli command and the normal operation of
peers being connected and disconnected. With this commit, we now ensure
such a race doesn’t occur by properly acquiring the lock for peersByID
before accessing it.
2017-01-24 16:52:54 -08:00
Olaoluwa Osuntokun 019edc9035
peer: display the src peer when logging read error 2017-01-23 20:33:29 -08:00
Olaoluwa Osuntokun 318cfb0080
server: properly close TCP connection when duplicate req detected 2017-01-23 20:32:54 -08:00
Olaoluwa Osuntokun 3ec4eeb5e2
cmd/lncli: add ability to render graph to 'describegraph'
This commit adds an ability to render the channel graph as returned by
the ‘displaygraph’ command. The rendering of the graph itself is
carried about the by the ‘dot’ command which eventually calls out to
graphviz.

Currently the graph is always saved to the same file in the local
directory, but in a later commit the location of the file will be made
configurable.

Finally, the attributes sent to the ‘dot’ command used to render the
graph are still a bit in flux. The parameters will likely be tuned once
the channel graph on testnet grows a bit more.
2017-01-23 20:32:23 -08:00
Olaoluwa Osuntokun eb73d14a92
lnd: revert usage of default port in connmgr persistent connections
This commit reverts a prior commit as it broke the integration tests
based on the assumption that all peers use the default port within the
network. The issue which was attempted to be fixed will be remedied
with a patch to the connmgr that allows a caller to cancel a persistent
connection that has failed.
2017-01-22 15:59:01 -08:00
Olaoluwa Osuntokun de70175be6
lnwallet+funding: properly propagate NewLightningChannel errors
This commit ensures that we now properly handle and propagate errors
that arise when attempting to create a new channel after the funding
transaction is believed to be confirmed.

A previous edge case would arise when a user attempted to create a new
channel, but their corresponding btcd node wasn’t yet fully synced.
2017-01-22 15:06:41 -08:00
Olaoluwa Osuntokun db40b4322e
routing: rebroadcast our outgoing channels with a long period
This commit adds new behavior to the ChannelRouter struct: we know
rebroadcast our outgoing channels every 30 minutes. This new behavior
should ensure that both directions of an advertised channel edge are
always propagated though the network, fixing the issue of “ghost” edges
which exist but aren’t advertised.
2017-01-22 14:40:09 -08:00
Olaoluwa Osuntokun 97bb8744c4
peer: fix logging message when receiving updates for unknown channel
The previous logging message was broken as that target chanpoint was
being overshadowed by the local variable declaration. The new logging
message will properly print the unknown channel point as well as the
peer who sent the message.
2017-01-22 14:37:08 -08:00
Olaoluwa Osuntokun 8c4b5ae0fc
peer: increase ping interval to 1 minute 2017-01-22 14:35:32 -08:00
Olaoluwa Osuntokun 4634db4f80
lnd: use the default peer port when launching persistent conn goroutines
This commit fixes a slight bug in the deamon. Previously we would store
the *net.TCPAddr that we observed when we either connected out to the
peer, or the peer connected to us. When making an outgoing connection
the host+port combination would be correct, but when responding to an
incoming connection, the port assigned after the TCP handshake would be
stored in the database. This would cause many goroutines to repeatedly
fail connections within the connmgr. Atm within the connmgr, it isn’t
possible to cancel requests for failed connection even after we’ve
already established a connection.

This commit fixes that issues by using the default peer port when
attempting to establish outbound connections to our channel peers.
2017-01-22 14:34:44 -08:00
Olaoluwa Osuntokun f623729b64
channeldb: fix panic in query for nonexistent channel ID
This commit fixes a panic that would arise when the daemon attempts to
query for a channel that doesn’t currently exist. The bug was the
result of a typo which checked for the nil existence of the incorrect
variable.
2017-01-22 14:28:36 -08:00
Olaoluwa Osuntokun 8fd4d7ea6b
routing: fix bug in channel capacity display by ensuring properly typed arithmetic
This commit fixes a slight bug in the storage of the capacity of a
channel. Previously, we were subtracting a the hard coded fee amount
without first casting the integer to a btcutil.Amount which results in
a display/rounding error when the amount is converted to BTC.
2017-01-22 14:21:58 -08:00
Olaoluwa Osuntokun dd42fa2f70
lnd: bump version to v0.1.1-alpha 2017-01-17 18:36:31 -08:00
Trevin Hofmann 40c7bac3aa multi: fix a variety of typos throughout the repo 2017-01-17 17:02:56 -08:00
Andrey Samokhvalov 49df1b0737 docker: make 'lnd' dockerfile download project from github rather than mount it localy 2017-01-17 16:56:28 -08:00
Andrey Samokhvalov 0325b0c77a docker: add 'Connect to faucet lightning node' section in readme 2017-01-17 16:56:28 -08:00
Andrey Samokhvalov 0948bc3579 docker: add BITCOIN_NETWORK param 2017-01-17 16:56:28 -08:00
Andrey Samokhvalov 67b300fdc4 docker: make blockchain persistant 2017-01-17 16:56:28 -08:00
Andrey Samokhvalov be66e039f1 docker: general improvements
* rename set_env->set_default
* fix bug with return from bash func
* make '--miningaddr' optional
2017-01-17 16:56:28 -08:00
Christopher Jämthagen 5c6d196ff8 test: reject non-standard transactions in integration tests 2017-01-17 16:23:50 -08:00