Commit Graph

4394 Commits

Author SHA1 Message Date
Olaoluwa Osuntokun
e3d1fb0d4b
Merge pull request #1339 from cfromknecht/switch-htlc-satisfies-deadlock
htlcswitch/link: remove deadlock in htlc validation
2018-06-06 18:31:10 -07:00
Conner Fromknecht
c180065a84
htlcswitch/link: remove deadlock in htlc validation
This commit removes a possible deadlock in the switch,
which can be triggered under certain failure conditions.
Previously, we would acquire the link's read lock for
the duration of HtlcSatisfiesPolicy, though we only
need to use it grab the current policy. The deadlock could
be caused in the cases where we attempt to log the failure,
which access the read-protected ShortChanID method.
2018-06-06 18:11:36 -07:00
Olaoluwa Osuntokun
849ee5e0dc
Merge pull request #1008 from wpaulino/peer-connection-logic
server: fix inbound/outbound peer connection logic
2018-06-06 18:07:18 -07:00
Wilmer Paulino
077b1fffcc
Revert "rpcserver: flip inbound bool for display, fix internally later"
This reverts commit 5126e431355ea074404064b91c57732e96d0a1e6 since the
underlying issue has now been fixed.
2018-06-06 16:30:41 -07:00
Wilmer Paulino
09253eacc3
server: use correct inbound value for peerConnected calls
In this commit, we address the meaning of the inbound parameter to
peerConnected. An inbound connection is defined as a connection
initiated by the peer, rather than ourselves.

We also update the inbound value for the peerConnected calls within
OutboundPeerConnected and InboundPeerConnected to reflect the definition
above.
2018-06-06 16:30:40 -07:00
Olaoluwa Osuntokun
2b2b83f97c
Merge pull request #1335 from halseth/peer-mutex-relaxation
Peer mutex relaxation
2018-06-06 16:29:53 -07:00
Olaoluwa Osuntokun
782fd9d709
Merge pull request #1327 from cfromknecht/waiting-proof-store-external-consistency
channeldb/waitingproof: improve external consistency of store
2018-06-06 15:50:37 -07:00
Johan T. Halseth
ac1ab6f516
server: hold mutex shorter during broadcast
We remove the internale broadcastMessage method, and instead handle the
mutex handling within BroadcastMessage. This lets us hold the mutex only
when neccessary.
2018-06-06 12:20:25 +02:00
Johan T. Halseth
b8512c3568
server: don't hold mutex while sending to peer
This commit removes the sendToPeer method from the server, and instead
moves the necessary logic into SendToPeer. This let's us make the mutex
acquisition more fine-grained, only holding it while reading from the
peer map. Earlier it was required to be held during the whole call to
sendToPeer, as the method would access the map internally.
2018-06-06 12:20:06 +02:00
Conner Fromknecht
086b44c1f4
channeldb/waitingproof: improve external consistency of store
This commit synchronizes the in-memory cache with the
on-disk state to ensure the waiting proof store is
externally consistent. Currently, there are scenarios
where the in-memory state is updated, and not reverted
if the write fails. The general fix is to wait to apply
modifications until the write succeeds, and use a
read/write lock to synchronize access with db operations.
2018-06-05 21:33:47 -07:00
Olaoluwa Osuntokun
991c9fb7dd
Merge pull request #1332 from Roasbeef/delete-update-index-items
channeldb: ensure items from the update index are actually deleted
2018-06-05 19:34:33 -07:00
Olaoluwa Osuntokun
1d994439e2
Merge pull request #1323 from Roasbeef/accept-duplicate-waiting-proofs
channeldb: don't reject duplicate waiting proofs
2018-06-05 19:20:29 -07:00
Olaoluwa Osuntokun
8f68d0e605
funding+htlcswitch: enforce min fee rate of 253 sat/kw on commitments
In this commit, we add and enforce a min fee rate for commitment
transactions created, and also any updates we propose to the remote
party. It's important to note that this is only a temporary patch, as
nodes can dynamically raise their min fee rate whenever their mempool is
saturated.

Fixes #1330.
2018-06-05 17:50:50 -07:00
Olaoluwa Osuntokun
f9c220cc7b
config: fix bug w/ tor onion services, only disable listen if no v2 or v3 2018-06-05 17:40:48 -07:00
Olaoluwa Osuntokun
dd4cab054d
channeldb: ensure items from the update index are actually deleted
In this commit, we fix an existing bug in the new graph query sync
feature. Before this commit, when a block is pruned, we would never
actually delete the update index entries. This is due to the fact that
we would attempt to delete the entries from the update index _after_ we
had already removed the edges from the update index.

We fix this by simply swapping the order: first we delete from the
update index, then we delete the edges themselves. A test ensuring that
the entires are cleared (which failed before this commit), has been
added.
2018-06-05 17:30:56 -07:00
Olaoluwa Osuntokun
4af9da40c5
htlcswitch: fix alignment in packetQueue for ARM
Fixes #1328.
2018-06-05 12:55:06 -07:00
Olaoluwa Osuntokun
d98d4523e1
Merge pull request #1159 from wpaulino/onion-service-support
multi: add onion services support
2018-06-04 21:46:51 -07:00
Wilmer Paulino
2e0484be19
multi: ensure addresses are no longer assumed to be TCP addresses only
In this commit, we go through the codebase looking for TCP address
assumptions and modifying them to include the recently introduced onion
addresses. This enables us to fully support onion addresses within the
daemon.
2018-06-04 20:41:49 -07:00
Wilmer Paulino
08f80b6cf3
server: use advertised address when reestablishing inbound connections
In this commit, we update the way we reestablish inbound connections if
we lose connectivity to a node we have an open channel with. Rather than
fetching the node's advertised port, we'll fetch one of their advertised
addresses instead. This ensure that if the remote node is running behind
a proxy, we do not see the proxy's address.
2018-06-04 20:41:48 -07:00
Wilmer Paulino
5b58d24f78
docs: update documentation for inbound connections 2018-06-04 20:41:47 -07:00
Wilmer Paulino
1012f876e1
server: add automatic creation of v2 onion services
In this commit, we allow the daemon to use the recently introduced Tor
Controller implementation. This will automatically create a v2 onion
service at startup in order to listen for inbound connections over Tor.

Co-Authored-By: Eugene <crypt-iq@users.noreply.github.com>
2018-06-04 20:41:45 -07:00
Wilmer Paulino
3bb1733fa2
discovery+server: use network-specific functions for fallback SRV lookup
In this commit, we fix a bug where a fallback SRV lookup would leak
information if `lnd` was set to route connections over Tor. We solve
this by using the network-specific functions rather than the standard
ones found in the `net` package.
2018-06-04 20:41:43 -07:00
Wilmer Paulino
d6d0c26252
rpcserver: add support to connect to onion addresses
In this commit, we now allow connections to onion addresses due to
recently adding support to properly parse them.

Co-Authored-By: Eugene <crypt-iq@users.noreply.github.com>
2018-06-04 20:41:42 -07:00
Wilmer Paulino
3669a40c52
server: add support to advertise onion addresses
In this commit, we allow `lnd` to properly parse onion addresses in
order to advertise them to the network when set through the
`--externalip` flag.

Co-Authored-By: Eugene <crypt-iq@users.noreply.github.com>
2018-06-04 20:41:41 -07:00
Wilmer Paulino
978fc7ba08
config+lnd: update tor config to include onion services flags
In this commit, we update the set of Tor flags to use sane defaults when
not specified. We also include some new flags related to the recent
onion services changes. This allows users to easily get set up on Tor by
only specifying the tor.active flag. If needed, the defaults can still
be overridden.
2018-06-04 20:41:40 -07:00
Wilmer Paulino
d6c2957f3c
tor: add inital tor controller implementation
In this commit, we add our inital implementation of a Tor Controller.
This commit includes the ability for the controller to automatically
signal the Tor daemon to create a v2 onion service. This will be
expanded later on to support creating v3 onion services.

Before allowing the controller to interact with the Tor daemon, the
connection must be authenticated first. This commit includes support for
the SAFECOOKIE authentication method as a sane default.

Co-Authored-By: Eugene <crypt-iq@users.noreply.github.com>
2018-06-04 20:41:36 -07:00
Wilmer Paulino
5d29dea21a
tor: return the connection's actual remote address rather than the proxy's
In this commit, we fix an issue where connections made through Tor's
SOCKS proxy would result in the remote address being the address of the
proxy itself

We fix this by using an internal proxyConn struct that sets the correct
address at the time of the connection.
2018-06-04 20:41:35 -07:00
Wilmer Paulino
5f1d2524b8
channeldb: add address serialization tests 2018-06-04 20:41:34 -07:00
Wilmer Paulino
3738e68ae2
channeldb: implement serialization of onion addresses
Co-Authored-By: Eugene <crypt-iq@users.noreply.github.com>
2018-06-04 20:41:33 -07:00
Wilmer Paulino
e5987a1ef1
lnwire: extend tests to randomly generate all types of supported addresses 2018-06-04 20:41:32 -07:00
Wilmer Paulino
850f9fbbe9
lnwire: implement serialization of onion addresses
Co-Authored-By: Eugene <crypt-iq@users.noreply.github.com>
2018-06-04 20:41:31 -07:00
Wilmer Paulino
a07397465b
tor: add onion address implementation
Co-Authored-By: Eugene <crypt-iq@users.noreply.github.com>
2018-06-04 20:41:30 -07:00
Wilmer Paulino
eded682f9b
build: update inputs-digest due to removed btcsuite/go-socks dep 2018-06-04 20:41:29 -07:00
Wilmer Paulino
43cbd5a814
tor: streamline package to better follow the Effective Go guidelines
In this commit, we clean up the tor package to better follow the
Effective Go guidelines. Most of the changes revolve around naming,
where we'd have things like `torsvc.TorDial`. This was simplified to
`tor.Dial` along with many others.
2018-06-04 20:41:28 -07:00
maurycy
3be08e69cf multi: 64bit aligment of atomic vars on arm/x86-32 2018-06-04 20:02:34 -07:00
Olaoluwa Osuntokun
d2bcb708f3
server: demote 'sending message' log to trace 2018-06-04 19:50:44 -07:00
Olaoluwa Osuntokun
cc12cf428b
Merge pull request #1325 from Roasbeef/gossip-syncer-fixes
discovery: ensure gossiper syncer has idempotent exit/start, fix deadlock
2018-06-04 19:17:47 -07:00
Olaoluwa Osuntokun
3cb24e57cc
Merge pull request #1324 from Roasbeef/fix-routing-hint-panic
rpc: ensure we don't attempt to create a routing hint with a nil edge
2018-06-04 18:46:00 -07:00
Olaoluwa Osuntokun
b915da427b
Merge pull request #1322 from Roasbeef/sync-feature-lazy-check
lnwire: only check payload for proper size if encoding type is sorted…
2018-06-04 18:42:38 -07:00
Olaoluwa Osuntokun
4d37508417
rpc: ensure we don't attempt to create a routing hint with a nil edge
In this commit, we fix an existing panic bug related to the recently
added routing hints feature. If it's the case that the remote node
didn't send us their edge, then when we go to compare the public keys to
see if they match, we may attempt to deref an nil pointer.

In order to fix this, we'll instead check the edgeInfo, which is
guaranteed to also exist if the channel was found in the database. As a
defensive step, before we go to actually aces the struct, we'll check
that's it's non-nil and proceed if it is nil.
2018-06-04 17:21:42 -07:00
Olaoluwa Osuntokun
e6d46f681b
discovery: if gossipSyncer is shutting down, don't filter messages 2018-06-04 17:18:54 -07:00
Olaoluwa Osuntokun
0ec4a06e6b
discovery: fix deadlock by ensure we don't hold sync mutex during send
In this commit, we fix an existing deadlock in the
gossiper->server->peer pipeline by ensuring that we're not holding the
syncer mutex while we attempt to have a syncer filter out the rest of
gossip messages.
2018-06-04 17:18:17 -07:00
Olaoluwa Osuntokun
a9340d22c4 discovery: ensure stopping/starting a gossipSyncer is idempotent 2018-06-04 17:18:07 -07:00
Olaoluwa Osuntokun
3bc026aece
Merge pull request #1319 from halseth/chain-height-resend-commitsig
[bugfix] lnwallet/channel: use FullySynced to check chanSync special case
2018-06-04 17:06:34 -07:00
Olaoluwa Osuntokun
ece5a29374
channeldb: don't reject duplicate waiting proofs
In this commit, we modify the waiting proof slightly to acept dupliacte
waiting proofs, rather than reject them. Otherwise, it's possible that
the remote node first sends us their half of the waiting proof (before
we do), we write that to disk, then upon restart, we'll try to add it
again, but be rejected by the system.

Fixes #1315.
2018-06-04 16:37:33 -07:00
Olaoluwa Osuntokun
1c8c1cba96
lnwire: only check payload for proper size if encoding type is sorted plain
In this commit, we fix a slight bug in the parsing of encoded short
channel ID's. Before this commit, we would always assume that the remote
peer was sending us the sorted+encoded variant of the short channel
ID's. In the case that they weren't (as there isn't yet a feature bit),
we would assert this check and fail early as atm we don't support any
sort of compression.
2018-06-04 16:31:22 -07:00
Rudy Godoy
3ee4f5fbd4 docs/docker: fixed link to /docker/README.md
Link must be /docker/README.md, relative to the repository's root. Previously it was relative to /docs, resulting in 404.
2018-06-04 16:13:17 -07:00
Johan T. Halseth
07629e5da1
lnwallet/channel: use FullySynced to check chanSync special case
We check if the channel is FullySynced instead of comparing the local
and remote commit chain heights, as the heights might not be in sync.
Instead we call FullySynced which recently was modified to use compare
the message indexes instead, which is _should_ really be in sync between
the chains.

The test TestChanSyncOweRevocationAndCommitForceTransition is altered to
ensure the two chains at different heights before the test is started, to
trigger the case that would previously fail to resend the commitment
signature.
2018-06-04 15:09:51 +02:00
Olaoluwa Osuntokun
2fa2644aec
Merge pull request #618 from wpaulino/change-wallet-password
Change wallet password
2018-06-01 17:49:40 -07:00
Olaoluwa Osuntokun
7e4abb4f55
Merge pull request #1301 from halseth/fundingmanager-double-error
Reduce fundingmanager chan send deadlock scenarios
2018-06-01 17:36:02 -07:00