Commit Graph

368 Commits

Author SHA1 Message Date
Johan T. Halseth
54a608d09d
htlcswitch+discovery mock: adhere to new lnpeer interface 2018-09-28 09:05:18 +02:00
Olaoluwa Osuntokun
6afee3d099
Merge pull request #1856 from maurycy/typos
multi: fix various typos in comments
2018-09-27 20:38:10 -07:00
Olaoluwa Osuntokun
68774e3ae4
Merge pull request #1807 from wpaulino/retransmit-zero-stale-channels
discovery/gossiper: check ErrNoGraphEdgesFound for restransmitStaleChannels
2018-09-25 21:14:23 -07:00
Olaoluwa Osuntokun
25145acc46
Merge pull request #1738 from joostjager/validation
payment failure message with attached channel_update not validated
2018-09-17 21:11:02 -07:00
Olaoluwa Osuntokun
c5979c7d80
discovery: fix logging for gossip syncer rate limiting 2018-09-13 15:55:44 -07:00
Joost Jager
b5fd32ff77
discovery+routing: move validation logic to routing package
Previously, gossiper was the only object that validated channel
updates. Because updates can also be received as part of a
failed payment session in the routing package, validation logic
needs to be available there too. Gossiper already depends on
routing and having routing call the validation logic inside
gossiper would be a circular dependency. Therefore the validation
was moved to routing.
2018-09-11 20:12:07 +02:00
Conner Fromknecht
a56e7122d6
discovery/syncer: use rate limiter for gossip queries
This commit replaces the simplistic rate limiting
technique added in 557cb6e2, to use the
golang.org/x/time's rate limiter. This has the
benefit of performing traffic shaping to meet a
target maximum rate, and yet tolerate bursts. Bursts
are expected during initial sync, though should become
more rare afterwards. Performing traffic shaping with
this mechanism should improve the ability of the gossip
syncer to detect sustained bursts from the remote peer,
and penalize them appropriately.

This commit also modifies the default parameters to
accept bursts of 10 queries, with a target rate of 1
reply every 5 seconds.
2018-09-11 00:12:35 -07:00
maurycy
ac24b12bf2
multi: fix various typos in comments 2018-09-07 06:51:49 +02:00
Conner Fromknecht
dc0030f11d
discovery/gossiper: remove go-errors pkg 2018-09-05 22:08:16 -07:00
Conner Fromknecht
045a2c7fff
discovery/syncer_test: add DOS delayed replies test 2018-09-05 22:08:16 -07:00
Conner Fromknecht
557cb6e253
discovery/syncer: delay replies after initial sync to prevent DOS 2018-09-05 22:08:16 -07:00
Olaoluwa Osuntokun
d2a7d910b7
Merge pull request #1825 from Roasbeef/extra-gossip-message-data
channeldb+discovery: ensure we store, validate and propagate announcements with opaque data
2018-09-05 17:53:02 -07:00
Olaoluwa Osuntokun
88aa74be57
discovery: add new set of tests to ensure we validate w/ extra data 2018-09-04 20:52:44 -07:00
Olaoluwa Osuntokun
841e24399c
discovery: ensure we populate ExtraOpaqueData when writing/reading from disk 2018-09-04 20:52:44 -07:00
Olaoluwa Osuntokun
0fc20cee64
discovery: update utils to properly include opaque data in gossip msgs 2018-09-04 20:52:44 -07:00
Conner Fromknecht
8e94e55839
discovery/gossiper: require explict gossip syncer init
This commit removes the fallback in fetchGossipSyncer
that creates a gossip syncer if one is not registered
w/in the gossiper. Now that we register gossip syncers
explicitly before reading any gossip query messages,
this should not longer be required. The fallback also
did not honor the cfg.NoChanUpdates flag, which may
have led to inconsistencies between configuration and
actual behavior.
2018-09-04 17:32:25 -07:00
Wilmer Paulino
6f0fad7946
discovery/gossiper: check ErrNoGraphEdgesFound for
restransmitStaleChannels

In this commit, we add an additional error check for
ErrNoGraphEdgesFound when restransmitting stale channels during the
gossiper's startup. We do this to prevent benign log messages as we'll
log that we were unable to retransmit stale channels when we didn't have
any channels in our graph to begin with.
2018-09-04 16:22:06 -07:00
Olaoluwa Osuntokun
4f43c1c943
Merge pull request #1811 from Roasbeef/autopilot-cpu-usage-fix
autopilot: modify the graph interface to return raw bytes for node pubkeys, not entire key
2018-09-03 19:56:51 -07:00
Olaoluwa Osuntokun
8f843c5eaa
discovery: update autopilot.Node usage to match recent API changes 2018-08-29 15:45:39 -07:00
Wilmer Paulino
a1b1b06b9e
discovery/gossiper: remove optimistic channel announcement request
In this commit, we aim to resolve an issue with nodes requesting for
channel announcements when receiving a channel update for a channel
they're not aware of. This can happen if a node is not caught up with
the chain or if they receive updates for zombie channels. This would
lead to a spam issue, as if a node is not caught up with the chain,
every new update they receive is premature, causing them to manually
request the backing channel announcement. Ideally, we should be able to
detect this as a potential DoS vector and ban the node responsible, but
for now we'll simply remove this functionality.
2018-08-27 15:54:21 -07:00
Olaoluwa Osuntokun
13a6d413ac
discovery: select on peer's QuitSignal to allow caller to unblock if disconnecting
In this commit, we select on the peer's QuitSignal to allow the caller
to unblock if the peer itself is disconnecting. With this change, we now
ensure that it isn't possible for a peer to block on this method and
prevent a graceful exit.
2018-08-25 17:30:16 -07:00
Olaoluwa Osuntokun
19552b0dbf
htlcswitch+funding+discovery: update mock peers to add new QuitSignal method 2018-08-25 17:30:15 -07:00
Johan T. Halseth
c56082006f
discovery/gossiper: formatting 2018-08-23 07:40:40 +02:00
Johan T. Halseth
0bc415c683
discovery/gossiper: don't return on errChan for ChannelUpdate not yet processed
Previosuly we would immediately return nil on the error channel for
premature ChannelUpdates, which would break the expection that a a
returned non-error meant the update was successfully added to the
database. This meant that the caller would believe the update was added
to the database, while it is actually still in volatile memory and can
be lost during restarts.

This change makes us handle premature ChannelUpdates as we handle other
premature announcements within the gossiper, by deferring sending on the
error channel until we have reprocessed the update.
2018-08-23 07:40:40 +02:00
Johan T. Halseth
7bbb2bbc80
discovery/gossiper: return on errChan on ValidationBarrier error 2018-08-23 07:40:40 +02:00
Johan T. Halseth
c8ce2aa2d2
discovery/gossiper: reaturn early of no premature to process 2018-08-23 07:40:39 +02:00
Johan T. Halseth
d0e8aeece1
discovery/gossiper: return on errChan in case of ChanAnn/Upd on wrong chain
Previously we wouldn't return anything in the case where the
announcement were meant for a chain we didn't recognize. After this
change we should return an error on the error channel in all flows
within the gossiper.
2018-08-23 07:40:39 +02:00
Johan T. Halseth
54f67f72b1
discovery/gossiper: define ErrGossiperShuttingDown 2018-08-23 07:40:39 +02:00
Valentine Wallace
1ffc3bb82e
multi: update to latest RegisterBlockEpochNtfn interface 2018-08-10 01:08:57 -07:00
Conner Fromknecht
cf2c371042
multi: fix linting errors 2018-08-02 18:20:50 -07:00
Conner Fromknecht
1ded697e8d
multi: sort import paths with gofmt 2018-08-02 18:20:49 -07:00
Olaoluwa Osuntokun
88bedec65b
discovery: update unit tests to account for new ChainNotifier API 2018-07-31 21:28:57 -07:00
Olaoluwa Osuntokun
c41d1a0a44
Merge pull request #1596 from wpaulino/syncer-cfg-chunk-size
discovery/syncer: store chunk size within gossiperSyncerCfg
2018-07-31 20:55:10 -07:00
Conner Fromknecht
54c4b09f87
discovery/gossiper: copy bolt key to prevent panic
Corrects an instance that holds a reference to a boltdb
byte slice after returning from the transaction. This
can cause panics under certain conditions, which is
avoided by creating a copy of the key.
2018-07-30 18:30:19 -07:00
Wilmer Paulino
c61b037628 discovery/syncer: store chunk size within gossiperSyncerCfg
In this commit, we allow the gossiper syncer to store the chunk size for
its respective encoding type. We do this to prevent a race condition
that would arise within the unit tests by modifying the values of the
encodingTypeToChunkSize map to allow for easier testing.
2018-07-30 13:49:36 -07:00
Johan T. Halseth
d7b2977e8c
multi test: remove mempool bool from RegisterSpendNtfn 2018-07-22 23:09:08 +02:00
Wilmer Paulino
6d4da72156
discovery/gossiper: update to latest NotifyWhenOnline changes 2018-07-19 12:34:08 -07:00
Wilmer Paulino
3ab17063ff
multi: satisfy new lnpeer interface 2018-07-19 12:32:29 -07:00
Olaoluwa Osuntokun
daf4a25fd9
discovery: fix missing formatting argument
Fixes #1576.
2018-07-17 16:43:06 -07:00
Olaoluwa Osuntokun
6f60f139f4 multi: switch over import paths from roasbeef/* to btcsuite/* 2018-07-13 17:05:39 -07:00
Wilmer Paulino
9ecfdb3c32
discovery/gossiper: hold ref to block epoch stream and cancel when stopped 2018-06-13 19:20:53 -07:00
Olaoluwa Osuntokun
dddbfa7efe
Merge pull request #1205 from wpaulino/initial-peer-bootstrap
server: improve initial peer bootstrapping
2018-06-13 16:51:41 -07:00
Olaoluwa Osuntokun
f2273d9503
discovery: log failed attempts in replyShortChanIDs 2018-06-13 16:44:59 -07:00
Wilmer Paulino
800b1363ab
discovery: randomize order of different bootstrappers
In this commit, we randomize the order of the different bootstrappers in
order to prevent from always querying potentially unreliable
bootstrappers first.
2018-06-13 08:59:37 -07:00
Olaoluwa Osuntokun
1a15924d65
discovery: fix log for adding new gossip syncers
In this commit, we fix the logging when adding new gossip syncers. The
old log would log the byte array, rather than the byte slice. We fix
this by slicing before logging.
2018-06-11 22:58:30 -07:00
Conner Fromknecht
bf515a2341
discovery/gossiper: mostly deprecate SendToPeer
This commit changes the gossiper to direct messages to
peer objects, instead of sending them through the
server every time. The primary motivation is to reduce
contention on the server's mutex and, more importantly,
avoid deadlocks in the Triangle of Death.
2018-06-08 16:29:48 -07:00
Conner Fromknecht
769f0f0a94
discovery/gossiper_test: mock out new lnpeer.Peer 2018-06-08 13:47:57 -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
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
maurycy
3be08e69cf multi: 64bit aligment of atomic vars on arm/x86-32 2018-06-04 20:02:34 -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
b3ac3492a0
discovery: if unable to find gossipSyncer for peer, create one
In this commit we fix an existing bug caused by a scheduling race
condition. We'll now ensure that if we get a gossip message from a peer
before we create an instance for it, then we create one on the spot so
we can service the message. Before this commit, we would drop the first
message, and therefore never sync up with the peer at all, causing them
to miss channel announcements.
2018-05-31 17:54:45 -07:00
Olaoluwa Osuntokun
994d9cf7e4
discovery: attempt to request the full chan ann for stray chan updates
In this commit, we extend the AuthenticatedGossiper to take advantage of
the new query features in the case that it gets a channel update w/o
first receiving the full channel announcement. If this happens, we'll
attempt to find a syncer that's fully synced, and request the channel
announcement from it.
2018-05-31 16:31:01 -07:00
Olaoluwa Osuntokun
6a6700e629
discovery: add new SyncState method to gossipSyncer
This new method allows outside callers to sample the current state of
the gossipSyncer in a concurrent-safe manner. In order to achieve this,
we now only modify the g.state variable atomically.
2018-05-31 16:31:00 -07:00
Olaoluwa Osuntokun
55dfc17c05
discovery: de-duplicate node announcements with legacy chan graph sync
Fixes #1072.
2018-05-31 16:30:58 -07:00
Olaoluwa Osuntokun
0016b3f458
discovery+lnd: create new chanSeries impl of the ChannelGraphTimeSeries interface
In this commit, we create a new concrete implementation for the new
discovery.ChannelGraphTimeSeries interface. We also export the
createChannelAnnouncement method to allow the chanSeries struct to
re-use the existing code for creating wire messages from the database
structs.
2018-05-31 16:30:55 -07:00
Olaoluwa Osuntokun
45bd544f11
discovery: update AuthenticatedGossiper to be aware of new gossipSyncers
In this commit, we update the logic in the AuthenticatedGossiper to
ensure that can properly create, manage, and dispatch messages to any
gossipSyncer instances created by the server.

With this set of changes, the gossip now has complete knowledge of the
current set of peers we're conneted to that support the new range
queries. Upon initial connect, InitSyncState will be called by the
server if the new peer understands the set of gossip queries. This will
then create a new spot in the peerSyncers map for the new syncer. For
each new gossip query message, we'll then attempt to dispatch the
message directly to the gossip syncer. When the peer has disconnected,
we then expect the server to call the PruneSyncState method which will
allow us to free up the resources.

Finally, when we go to broadcast messages, we'll send the messages
directly to the peers that have gossipSyncer instances active, so they
can properly be filtered out. For those that don't we'll broadcast
directly, ensuring we skip *all* peers that have an active gossip
syncer.
2018-05-31 16:30:53 -07:00
Olaoluwa Osuntokun
5789ef7c10
discovery: add new gossipSyncer struct to manage sync state for each peer
In this commit, introduce a new struct, the gossipSyncer. The role of
this struct is to encapsulate the state machine required to implement
the new gossip query range feature recently added to the spec. With this
change, each peer that knows of this new feature will have a new
goroutine that will be managed by the gossiper.

Once created and started, the gossipSyncer will start to progress
through each possible state, finally ending at the chansSynced stage. In
this stage, it has synchronized state with the remote peer, and is
simply awaiting any new messages from the gossiper to send directly to
the peer. Each message will only be sent if the remote peer actually has
a set update horizon, and the message isn't before or after that
horizon.

A set of unit tests has been added to ensure that two state machines
properly terminate and synchronize channel state.
2018-05-31 16:30:53 -07:00
Conner Fromknecht
3854c1ed68
discovery/gossiper: exit early on validation barrier quit 2018-05-08 16:32:08 -07:00
Dimitris Tsapakidis
4009f7f874 multi: fix typos in comments 2018-04-17 19:03:27 -07:00
practicalswift
663c396235 multi: fix a-vs-an typos 2018-04-17 19:02:04 -07:00
Jim Posen
4b2cb68fe6 discovery: Fix formatting issue in log line. 2018-04-09 20:49:23 -07:00
Olaoluwa Osuntokun
3fa2e08665
test: update testUpdateChannelPolicy to ensure Bob's link uses the proper policies
In this commit, we update the testUpdateChannelPolicy to exercise the
recent set of changes within the switch. If one applies this test to a
fresh branch (without those new changes) it should fail. This is due to
the fact that before, Bob would attempt to apply the constraints of the
incoming link (which we updated) instead of the outgoing link. With the
recent set of changes, the test now properly passes.
2018-04-06 14:52:01 -07:00
Olaoluwa Osuntokun
9d4cea93f0
discovery: fix deadlock in processChanPolicyUpdate
In this commit, we fix an existing deadlock in the
processChanPolicyUpdate method. Before this commit, within
processChanPolicyUpdate, we would directly call updateChannel *within*
the ForEachChannel closure. This would at times result in a deadlock, as
updateChannel will itself attempt to create a write transaction in order
to persist the newly updated channel.

We fix this deadlock by simply performing another loop once we know the
set of channels that we wish to update. This second loop will actually
update the channels on disk.
2018-04-06 14:51:57 -07:00
Johan T. Halseth
ed6682ea4a
multi test: make mock adhere to api change 2018-04-03 22:04:02 +02:00
Olaoluwa Osuntokun
2326d4afeb
discovery: bump rejected edges up to the trace logging level 2018-03-23 15:50:56 -07:00
Olaoluwa Osuntokun
ce85632390
discovery: ensure target host for DNS fallback is fully qualified
In this commit, fix the inability of some users to connect to the DNS
seed using our direct TCP fallback. We do this as some resolvers filter
out our large SRV requests due to their size (they also include public
keys). Instead, we’ll use a direct TCP resolution in this case.
However, after a recent change, we forgot the period at the end of the
target DNS host. This is an issue as the domain needs to be fully
qualified.

The fix is easy, add a period within our string formatting to target
the proper sub-domain and SRV target.

Fixes #854.
2018-03-18 16:05:10 -07:00
Matt Drollette
1b7b35a8bc discovery: format log message with Errorf 2018-03-16 16:25:18 -07:00
Olaoluwa Osuntokun
30019538c4
discovery: update DNS bootstrapper to adhere to new query schema
In this commit, we update the DNS bootstrapper to match the new query
semantics expected by the new DNS server. We no longer hard code the
target DNS host, and instead, we’ll re-use the same target endpoint as
we only need the soaShim in order to establish a direct TCP connection
for the queries.
2018-03-14 18:27:29 -07:00
Olaoluwa Osuntokun
800eea931f
build+multi: switch from bolt to bbolt
In this commit, we switch from boltbd/bolt to coreos/bbolt as the
former is no longer being actively maintained.
2018-03-10 19:01:13 -08:00
Olaoluwa Osuntokun
e7e4cdcf49
discovery: avoid always validating ECDSA sigs by asking router if item is fresh
In this commit, we reduce the amount of unnecessary work that the
gossiper can carry out. When CPU profiling some nodes, I noticed that
we’d spend a lot of time validating the signatures for an announcement,
only to realize that the router already had it.

To remedy this, we’ll use the new methods added to the channel router
in order to avoid unnecessarily validating an announcement that is
actually stale. This should reduce memory usage (since it uses big
int’s under the scenes), and also idle CPU usage.
2018-03-06 13:34:51 -05:00
practicalswift
b8e1351cf3 multi: fix some recently introduced typos 2018-02-18 15:27:29 -08:00
Olaoluwa Osuntokun
bf05e47780
discovery: add additional gossiper level reject cache
In this commit, we’ll add a new reject cache to ensure that we don’t
attempt to re-process any announcements already rejected by the
ChannelRouter.
2018-02-06 20:14:35 -08:00
Olaoluwa Osuntokun
cd9d2d7e6f
discovery: update graph API usage to match recent API changes 2018-02-06 20:14:32 -08:00
Daniel McNally
8543497dcc multi: fixing it's/its typos in comments 2018-02-06 19:13:07 -08:00
practicalswift
a93736d21e multi: comprehensive typo fixes across all packages 2018-02-06 19:11:11 -08:00
nsa
e132ad8433 torsvc: Added new module to house Tor functions
This commit adds a new module named 'torsvc' which houses all Tor
functionality in an attempt to isolate it and make it reusable in
other projecs. Some additional tweaks were made to config.go and
to the bootstrapper.
2018-02-05 17:37:46 -08:00
nsa
e2142c778f multi: Added Tor support
This commit adds Tor support. Users can set the --TorSocks flag
to specify which port Tor's SOCKS5 proxy is listening on so that
lnd can connect to it. When this flag is set, ALL traffic gets
routed over Tor including DNS traffic. Special functions for
DNS lookups were added, and since Tor doesn't natively support
SRV requests, the proxySRV function routes connects us to
a DNS server via Tor and SRV requests can be issued directly
to the DNS server.

Co-authored-by: MeshCollider <dobsonsa68@gmail.com>
2018-02-05 17:37:46 -08:00
Olaoluwa Osuntokun
0a4de859a2
discovery+routing: reduce number of active validation barrier jobs
In order to reduce high CPU utilization during the initial network view
sync, we slash down the total number of active in-flight jobs that can
be launched.
2018-01-28 14:55:32 -08:00
Johan T. Halseth
a55c74f80c
discovery/gossiper: restrict database access per channel ID
This commit uses the multimutex.Mutex to esure database
state stays consistent when handling an announcement, by
restricting access to one goroutine per channel ID.

This fixes a bug where the goroutine would read the
database, make some decisions based on what was read,
then write its data to the database, but the read data
would be outdated at this point. For instance, an
AuthProof could have been added between reading the
database and when the decision whether to announce
the channel is made, making it not announce it.
Similarly, when receiving the AuthProof, the edge
policy could be added between reading the edge state
and adding the proof to the database, also resulting
in the edge not being announced.
2018-01-24 10:26:40 +01:00
Johan T. Halseth
3e01529de4
discovery/gossiper: don't reset batch after broadcast
This commit fixes a bug that could cause annoucements
to get lost, and resultet in flaky integration tests.
After a set of announcements was broadcastet, we would
reset (clear) the announcement batch, making any
annoucement that was added between the call to Emit()
and Reset() to be deleted, without ever being broadcast.

We can just remove the Reset() call, as the batch will
actually be reset within the call to Emit(), making
the previous call only delete those messages we hadn't
sent yet.
2018-01-24 10:26:39 +01:00
Olaoluwa Osuntokun
69e6ec9954
peer+funding: remove unneeded channel handoff code with the breach arbiter
We no longer need to hand off new channels that come online as the
chainWatcher will be persistent, and always have an active signal for
the entire lifetime of the channel.
2018-01-22 19:19:50 -08:00
Olaoluwa Osuntokun
8807d1d752
fundingmgr: add new function closure to send new channels to the ChainArbitrator 2018-01-22 19:19:38 -08:00
Olaoluwa Osuntokun
ebd97b83f3
discovery: ensure we only send node announcements that have active channels 2018-01-16 17:18:21 -08:00
Johan T. Halseth
483abbee5b
discovery: make sure ChannelUpdates always have incremented timestamp
This commit ensures that we always increment the timestamp of
ChannelUpdates we send telling the network about changes to
our channel policy. We do this because it could happen
(especially during tests) that we issued an update, but the
ChannelUpdate would have the same timestamp as our last
ChannelUpdate, and would be ignored by the network.
2018-01-12 22:57:03 +01:00
Johan T. Halseth
8370fa2cde
discovery/gossiper: apply TimeLockDelta to edge when processing policy update
Also rename various instances of "FeeUpdate" to "PolicyUpdate"
2018-01-12 22:56:32 +01:00
Johan T. Halseth
3f0a525331
discovery test: update gossiper test to account for timestamp deduping 2018-01-09 13:09:28 +01:00
Johan T. Halseth
ea95f37277
discovery: keep newest messages when deduping in gossiper
This commit makes the gossiper aware of the timestamps
of ChannelUpdates and NodeAnnouncements, such that it
only keeps the newest message when deduping. Earlier
it would always keep the last received message, which
in some cases could be outdated.
2018-01-09 13:09:25 +01:00
Johan T. Halseth
2ddd139084 discovery: check proof for nilness before creating chanAnn
This commit makes sure we are not attempting to create a
channel announcement with a nil ChannelAuthProof, as that
could cause a crash at startup whe the gossiper would
attempt to reprocess an edge coming from the fundingmanager.

It also makes sure we check the correct error returned from
processRejectedEdge.
2018-01-02 19:51:38 +01:00
Olaoluwa Osuntokun
6b0f984e31
discovery: update tests to reflect new broadcast related changes 2017-12-26 16:29:37 +01:00
Olaoluwa Osuntokun
38715ca768
discovery: refactor re-processing rejected announcements into new method 2017-12-26 16:28:23 +01:00
Olaoluwa Osuntokun
68dabe3594
discovery: update usage of d.cfg.Broadcast to reflect recent API change
When broadcasting a set of messages, we must now call broadcast for
each (msg, …senders) tuple, rather than just calling it once for the
entire batch.
2017-12-26 16:26:34 +01:00
Olaoluwa Osuntokun
f45502f890
discovery: update message processing to emit networkMsg rather than lnwire.Message
In this commit, we make an incremental step towards page of the new
feature of deDupedAnnoucnements to return the set of senders for each
message. All methods the process new channel announcements, will now
return an instance of networkMsg rather than lnwire.Message. This will
allow passing the returned announcement directly into
deDupedAnnoucnements.AddMsg().
2017-12-26 16:23:12 +01:00
Olaoluwa Osuntokun
f1b40e0b4d
discovery: modify deDupedAnnouncements to keep track of senders for each msg
In this commit, we modify the deDupedAnnouncements struct slightly. The
element of this struct will now keep track of the set of senders that
sent a particular message. Each time a message is added, we’ll replace
the new message with the old (as normal), but we’ll also add the new
sender to the set of known senders.

With this new feature, we’ll be able to avoid re-sending a message to
the peer that sent it to us in the first place.
2017-12-26 16:19:03 +01:00
Matt Drollette
d6172ca8b4 discovery: correctly format ipv6 addresses from dns seed 2017-12-22 20:12:35 +01:00
Johan T. Halseth
c3aa23f061 discovery test: update gossiper test for new database structure 2017-12-19 13:01:59 -06:00
Johan T. Halseth
e3ae204fcb discovery: make gossiper able to resend failed AnnounceSignatures
This commit makes the gossiper track the state of a local
AnnounceSignature message, such that it can retry sending
it to the remote peer if needed. It will also persist this
state in the WaitingProofStore, such that it can resume
from this state at startup.
2017-12-19 13:01:59 -06:00
Matt Drollette
adf0d98194 multi: fix several typos in godoc comments 2017-12-17 18:40:05 -08:00
Johan T. Halseth
b74a281b57 discovery test: test for remote ChannelUpdate for unknown channel
This commit adds a test that ensures that if we receive a
ChannelUpdate for a channel we don't know about, it will
be reprocessed after we receive a ChannelAnnouncement for
that channel.
2017-12-17 18:35:34 -08:00
Johan T. Halseth
db829cd0c5 discovery: reprocess premature ChannelUpdates
This commit makes the gossiper store received ChannelUpdates
that is not for any known channel in a map, such that they
can be reprocessed when the ChannelAnnouncement arrives.

This is done to handle the case where we receive a ChannelUpdate
from our channel counterparty before we have been able to process
our own local ChannelAnnouncement.
2017-12-17 18:35:34 -08:00
Johan T. Halseth
10b838e9b4 gossiper: private channel cleanup + comments
This commit adds some comments and does some cleanup
of the logic that makes sure non-public channels
(channels with no AuthProof) are not broadcasted
to the network.
2017-12-17 18:35:34 -08:00
nsa
dab7f31e44 gossiper: Only send channel updates for edges with AuthProof. 2017-12-17 18:35:34 -08:00
Olaoluwa Osuntokun
37c54153fa
discovery: properly set node's color when syncing graph state
This commit fixes an existing bug wherein we would blank out a node’s
color instead of properly setting the field when syncing graph state
with another node This would cause the node to reject the node
announcement and we would generate an we would invalidate the signature
of the node announcement. We fix this simply by properly setting the
node announcement.
2017-12-02 18:33:21 -08:00
Olaoluwa Osuntokun
ee7c3ff01c
discovery: properly set node's color field when adding NodeAnnouncement to router
In this commit, we fix an existing bug when processing new node
announcement. Before this commit, we wouldn’t also copy over the color
field of a node’s announcement. As a result, when went to synchronize
our graph state with that of a connecting peer, we would generate an
invalid node announcement. We fix this by properly setting the color
field of a node.
2017-12-02 18:28:41 -08:00
Olaoluwa Osuntokun
3802cb90df
discovery: publicly export announcement validation related functions 2017-12-01 19:31:54 -08:00
Olaoluwa Osuntokun
12a0488bc6
discovery: use lnwire.ChanUpdateFlag masks when examinig ChannelUpdate msgs
In this commit, we now properly examine the Flag field within the
ChannelUpdate message as a bitfield. Before this commit we would
manually check the flags for zero or one. This was incorrect as a their
bit has now been defined. To properly dispatch the messages, we’ll now
treat it properly as a bitmask.
2017-11-30 22:37:21 -08:00
Olaoluwa Osuntokun
3e3de26ac9
discovery: set proper flag within createChanAnnouncement
In this commit, we fix an existing bug within the
createChanAnnouncement function. Before we would set the flag to be 0,
or 1 depending on which edge it was. This was incorrect as since then
additional flags have been defined. We now properly set the entire
flag, rather than taking a shortcut. With this, we’ll properly
advertise all ChannelUpdate announcements.
2017-11-30 22:33:00 -08:00
Olaoluwa Osuntokun
c0b8c29382
discovery: continue in loop after processing announcement signatures 2017-11-29 18:35:19 -08:00
Olaoluwa Osuntokun
4ab16b5c91
discovery: process AnnouncementSignatures msgs serially 2017-11-29 17:53:21 -08:00
Olaoluwa Osuntokun
3067d05ae8
discovery: validate incoming announcements in parallel 2017-11-29 16:45:14 -08:00
Olaoluwa Osuntokun
2dcd2b8a6d
discovery: add a mutex in order to make deDupedAnnouncements thread-safe 2017-11-29 16:21:16 -08:00
Olaoluwa Osuntokun
2861f6e5f4
discovery: add additional comments to TestDeDuplicatedAnnouncements 2017-11-15 18:25:33 -08:00
Laura Cressman
918ef2808f gossiper_test: add tests for deDupedAnnouncements struct
Add tests for new deDupedAnnouncements struct in gossiper_test.
Test the various functionalities of the struct - that empty
struct contains no announcements, that announcements of each type
can be added and properly de-duplicated, that the batch of
announcements is delivered correctly, and that after reset the
struct again contains no announcements.
2017-11-15 16:50:19 -08:00
Laura Cressman
ed6ad22e85 config+server+networktest: make trickleDelay configurable
Add option to set trickleDelay for AuthenticatedGossiper in
command line, with default value of 300 milliseconds. Pass this
value to newServer, which uses it when creating a new instance of
AuthenticatedGossiper. Also set this value to 300 milliseconds when
creating nodes in integration tests.
2017-11-15 16:50:19 -08:00
Laura Cressman
39d38da732 discovery: create deDupedAnnouncements struct in gosspier.go
For Part 1 of Issue #275. Create isolated private struct in
networkHandler goroutine that will de-duplicate
announcements added to the batch. The struct contains maps
for each of channel announcements, channel updates, and
node announcements to keep track of unique announcements.

The struct has a Reset method to reset stored announcements, an
AddMsg(lnwire.Message) method to add a new message to the current
batch, and a Batch method to return the set of de-duplicated
announcements.

Also fix a few minor typos.
2017-11-15 16:50:19 -08:00
Olaoluwa Osuntokun
8c181b6f4e
discovery: return an error if ChannelUpdate has unknown flags
In this commit, we fix an existing bug that could result in a panic if
we received a ChannelUpdate message with an unknown set of flags. If
the flag wasn’t set to zero or one, then the pubKey parameter would be
still nil when we attempted to validate it, causing an error to occur.

We remedy this by instead returning an error if the flags are unknown.
In a future commit, we will properly handle the set of flags that
indicates the channel should be disabled.
2017-11-11 14:59:16 -08:00
Olaoluwa Osuntokun
65cf83489a
discovery: fix linter warning 2017-10-30 19:04:00 -07:00
Olaoluwa Osuntokun
5b226a9d37
discovery: add TCP fallback for DNSSeedBootstrapper
In this commit, we add a TCP fallback option for the
DNSSeedBootstrapper. We’ve received many reports of users unable to
bootstrap properly to the network due to the size of the SRV records we
currently return. It has been observed that many revolvers will simply
truncate and ignore the response due to the (current size).

To resolve (no pun intended) we now attempt to detect this failure mode
and will fallback to a manual TCP resolution in the case that our SRV
query over UDP fails. We do this by querying the special record at the
"soa." sub-domain of supporting DNS servers. The retuned IP address
will be the IP address of the authoritative DNS server. Once we have
this IP address, we'll connect manually over TCP to request the SRV
record. This is necessary as the records we return are currently too
large for a class of resolvers, causing them to be filtered out.
2017-10-30 19:00:27 -07:00
Conner Fromknecht
3b2e4caa93 discovery/gossiper: isolate sync with node from query
This commit refactors the SynchronizeNode logic such that
  it can be called without interacting with the gossiper's
  main execution loop. This method does not require access
  to any of the gossiper's internal state, making the change
  fairly straightforward. The primary motivation behind
  this change is to minimize the possibility of introducing
  deadlock scenarios between the gossiper and server.
2017-10-27 15:48:37 -07:00
Jim Posen
9fd77a6e40 multi: Update lnd to use new feature vector API. 2017-10-17 22:47:20 -07:00
Olaoluwa Osuntokun
03f9479eb4
discovery: only interpret remote announcements as pre-mature
This commit fixes a slight bug in the announcement processing logic
within the AuthenticatedGossiper. Before this commit, it was possible
for us to ignore one of our now announcements due to it being
pre-mature, rendering (atm) the channel unusable by the ChannelRouter
itself. To fix this, we know only check for a pre mature announcement
iff the message is coming from a remote node.
2017-10-17 19:44:13 -07:00
Olaoluwa Osuntokun
490e0d0f46
discovery: broadcast OG chan ann in retransmitStaleChannels 2017-10-04 20:46:12 -07:00
Olaoluwa Osuntokun
0d28bb14cb
discovery: also return latest ChannelAnnouncement from updateChannel
This commit adds an additional return value to the updateChannel
method. We also now return the original ChannelAnnouncement, this can
be useful as it let’s the caller ensure that the channel announcement
will be broadcast along side the new channel update.
2017-10-04 20:46:10 -07:00
Olaoluwa Osuntokun
4be2e95a78
discovery: fix boltdb deadlock bug in ann retrans, retrans at start
This commit does two things. First we fix a deadlock bug within boltdb
that could arise when the channel router attempted to open a
transaction, while the retransmission loop was attempting to send a
message to the channel router (circular wait). Second, we’ve refactored
out the retransmission into its own function. This allows us to kick
off retransmission as soon as the AuthenticatedGossiper is created.
2017-10-04 20:46:10 -07:00
Olaoluwa Osuntokun
e81689057a
discovery+routing: remove DeleteEdge from ChannelGraphSource interface
This commit removes the recently added DeleteEdge method from the
ChannelGraphSource interface as it’s no longer needed.
2017-10-04 20:46:08 -07:00
Olaoluwa Osuntokun
81cd954cfc
discovery: don't prune *our* channels during retransmission tick
This commit modifies the recently modified logic for self-channel
retransmission to exclude pruning *our* channels which haven’t been
updated since the broadcastInterval. Instead, we only re-broadcast
channels of ours that haven’t been updated in 24 hours.
2017-10-04 20:46:08 -07:00
Brandon
cce75bbb14 discovery: add retransmit delay to gosipper_test 2017-10-04 20:42:27 -07:00
Brandon
e1ea0aafe8 discovery: adding DeleteEdge to gossiper_test 2017-10-04 20:42:17 -07:00
Brandon
3907ae65c2 routing+discovery: implement 2-week network view pruning 2017-10-04 20:40:21 -07:00
Olaoluwa Osuntokun
c529597ff9
discovery: add more detail to error logging in processNetworkAnnouncement 2017-09-12 17:12:22 +02:00
Olaoluwa Osuntokun
fe0a7b6a09
multi: fix linter errors 2017-09-03 17:05:11 -07:00
Olaoluwa Osuntokun
f823a860c8
discovery: add new interface NetworkPeerBootstrapper w/ 2 impls
This commit adds a new interface the to discovery package:
NetworkPeerBootstrapper. The NetworkPeerBootstrapper interface is meant
to be used to bootstrap a new peer joining the network to the set of
existing active peers within the network. Callers are encouraged to
utilize several boostrappers in series as redundant sources of
information. The MultiSourceBootstrap function will takes a set of
boostrappers, and compose their outputs into a single unified set of
addresses.

Two concrete implementations of the NetworkPeerBootstrapper interface
have been added as a part of this commit: the ChannelGraphBootstrapper
and the DNSSeedBootstrapper. The former will utilize the authenticated
node advertisements within the calling nodes view to boostrap new
connections. The latter will use a set of BOLT-0010 compliant DNS seeds
to query. This DNS seeding more will likely be used by nodes initial
joining the network, as they may not yet have the channel graph as they
haven’t connected to any peers.
2017-09-03 16:51:17 -07:00
Olaoluwa Osuntokun
0b4ff2aabb
discovery: ignore any incoming channel ann's for an unknown chain
This commit fixes an existing bug in the announcement processing of the
authenticated gossiper. We will now only examine an incoming
announcement for validity if it targets the chain that we’re currently
active on.
2017-09-03 16:41:09 -07:00
Olaoluwa Osuntokun
1e513875e5
discovery: rename service.go to gossiper.go 2017-09-03 16:21:10 -07:00
Olaoluwa Osuntokun
f1501ebc95
discovery: rename validation.go to ann_validation.go 2017-09-03 16:18:28 -07:00
Olaoluwa Osuntokun
d0b192c636
discovery: print proper error message when sigs fail to validate 2017-08-23 11:34:47 -07:00
Olaoluwa Osuntokun
ff997eab3e
discovery: ensure ChainHash field is populated when crafting new ChannelUpdates
This commit ensures that we *always* populate the ChainHash field when
we’re crafting new channel update messages either due to the periodic
broadcast, or when we’re updating the routing policies of a set of
target channels. Previously, this wasn’t set which would cause nodes to
reject the newly crafted ChannelUpdate messages.
2017-08-22 20:13:04 -07:00
Olaoluwa Osuntokun
2b2a3714c1
multi: fix linter errors 2017-08-22 01:00:12 -07:00
Olaoluwa Osuntokun
862af6f2d4
discovery: update initial graph synchronization to recent API changes 2017-08-22 00:53:09 -07:00
Olaoluwa Osuntokun
812c2f1ce6
discovery: add new PropagateFeeUpdate method
This commit adds a new method to the AuthenticatedGossiper:
PropagateFeeUpdate. This new method will allow callers to update the
fee schedule advertised for a particular channel, or all currently
active channels. With this method exposed, the AuthenticatedGossiper
will now craft the new channel update messages, sign the new state,
commit the new policy to the underlying graph, and finally add the
message to the next announcement epoch batch.
2017-08-22 00:53:06 -07:00
Olaoluwa Osuntokun
69b3b96deb
discovery: update tests to match latest API+verification changes 2017-08-22 00:52:45 -07:00
Olaoluwa Osuntokun
e268658f0e
discovery: fill in ChainHash, and Features in ChannelAnnouncement 2017-08-22 00:52:42 -07:00
Olaoluwa Osuntokun
240f34ccf6
discovery: modify message validation to match BOLT-0007
This commit implements the simplification within the latest version of
BOLT-0007. With this change, we simply sign the message hash directly
with the bitcoin keys, rather than signing the node keys themselves.
2017-08-22 00:52:40 -07:00
Olaoluwa Osuntokun
43b736225b
multi: add new method to generate fresh node announcments 2017-08-04 18:32:33 -07:00
Johan T. Halseth
889a4eb48b discovery: send channel announcements before node announcements.
According to BOLT#7, nodes will ignore node announcements
for nodes not found in any previous channel announcements.
This commit makes the discovery service send its known
channels before its known nodes when syncing the channel
graph with a peer.
2017-08-02 15:58:58 -07:00
Andrey Samokhvalov
8fa2b95c12 lnd: remove seelog logger
The btclog package has been changed to defining its own logging
interface (rather than seelog's) and provides a default implementation
for callers to use.

There are two primary advantages to the new logger implementation.

First, all log messages are created before the call returns.  Compared
to seelog, this prevents data races when mutable variables are logged.

Second, the new logger does not implement any kind of artifical rate
limiting (what seelog refers to as "adaptive logging").  Log messages
are outputted as soon as possible and the application will appear to
perform much better when watching standard output.

Because log rotation is not a feature of the btclog logging
implementation, it is handled by the main package by importing a file
rotation package that provides an io.Reader interface for creating
output to a rotating file output.  The rotator has been configured
with the same defaults that btcd previously used in the seelog config
(10MB file limits with maximum of 3 rolls) but now compresses newly
created roll files.  Due to the high compressibility of log text, the
compressed files typically reduce to around 15-30% of the original
10MB file.
2017-06-25 14:19:56 +01:00
Olaoluwa Osuntokun
1be4d67ce4
multi: run all test instances in parallel 2017-06-17 01:00:07 +02:00
Olaoluwa Osuntokun
1c0712ca03
discovery: update to recent lnwire.ChannelUpdate changes 2017-06-16 22:48:14 +02:00
Olaoluwa Osuntokun
2486097554
discovery+lnwallet: fix tests by making mock notifiers compliant to new interface 2017-05-11 15:58:41 -07:00
Andrey Samokhvalov
8e4199ee92 discovery+server: make waiting proofs persistent
In this commit waiting proofs array have been replaced with persistant
boltd storage which removes the possibility for the half proof to be
lost during half proof exchange.
2017-05-05 17:02:49 -07:00
Andrey Samokhvalov
337a4a4f56 discovery: fix silent remote orphan announcement proof rejection
In case of the situation when we receive remote announcement with
channel id which pointing out to unknown channel the announcement have
been silently rejected. Now such announcement will be added to the
waiting proof map.

Such solution has a serious drawback - by adding the announcement proof
without information about channel itself (that this announcement have
been received from the node eligible to sending it), we allow
overwriting the waiting proof map by `Eve` node.
2017-04-26 22:05:37 -07:00
Olaoluwa Osuntokun
655618b2a1
discovery: properly log unit64 version of shortChanID in logs 2017-04-23 19:07:15 -07:00
Olaoluwa Osuntokun
4fd285236e
discovery: update to latest wire msg API changes 2017-04-20 16:18:20 -07:00
Olaoluwa Osuntokun
0ab1c47d31
discovery+funding: update wire message usage to latest API changes 2017-04-19 16:20:53 -07:00
Olaoluwa Osuntokun
0f9c2e1d17
discovery: modify SignAnnouncement to take a MessageSigner
This commit modifies the SignAnnouncement helper function to instead
take a MessageSigner interface rather than the deprecated MessageSigner
struct.  We also modify the function to explicitly take the identity
public key to use when signing.
2017-04-14 11:08:32 -07:00
Olaoluwa Osuntokun
f7c8938e7d
discovery: use debug logging level for rejected announcements 2017-04-13 14:30:48 -07:00
Olaoluwa Osuntokun
0f4b9d9763
discovery: fix linter error 2017-04-03 11:03:39 +02:00
Olaoluwa Osuntokun
ca053e5273
multi: minor coding style and comment clean ups post-discovery merge
This commit implements some minor coding style, commenting and naming
clean up after the recent major discovery service was merged into the
codebase.

Highlights of the naming changes:
* fundingManager.SendToDiscovery -> SendAnnouncement
* discovery.Discovery -> discovery.AuthenticatedGossiper

The rest of the changes consist primary of grammar fixes and proper
column wrapping.
2017-04-01 20:14:05 +02:00
Olaoluwa Osuntokun
1894a208bd
discovery: utilize exactly 9 bytes for serialized waitingProofKey 2017-04-01 20:14:01 +02:00
Andrey Samokhvalov
d4055d7830 discovery+funding: add validation of the announcement messages
Add validation functions and include validation checks in the
annoncement process function.
2017-03-29 19:49:05 -07:00
Andrey Samokhvalov
fbf766e3c6 discovery+funding: add 'AnnounceSignature' proof exchange
Add the interaction between nodes of announce signature messages, which
will allow us to exhcnage the half channel announcemen proofs later.
2017-03-29 19:49:05 -07:00
Andrey Samokhvalov
07076cce21 routing+channeldb: add AddProof method
Originally we adding the edge without proof in order to able to use it
for payments path constrcution. This method will allow us to populate
the announcement proof after the exchange of the half proofs and
constrcutrion of full proof finished.
2017-03-29 19:49:05 -07:00
Andrey Samokhvalov
4bca54e30c routing: add validation of utxo
Add check that the edge that was received really exist in the blockchain
and that the announced funding keys and capcity corresponds to reality.
2017-03-29 19:49:05 -07:00
Andrey Samokhvalov
c3b2854428 lnwire: converge discovery part of messages with specification
Change the name of fields of messages which are belong to the discovery
subsystem in a such way so they were the same with the names that are
defined in the specification.
2017-03-29 19:49:05 -07:00
Andrey Samokhvalov
b4ac7071ff discovery+routing: split 'routing' package on 'routing' and 'discovery'
In this commit the routing package was divided on two separete one,
this was done because 'routing' package start take too much responsibily
on themself, so with following commit:

Routing pacakge:
Enitites:
* channeldb.ChannelEdge
* channeldb.ChannelPolicy
* channeldb.NodeLightning

Responsibilities:
* send topology notification
* find payment paths
* send payment
* apply topology changes to the graph
* prune graph
* validate that funding point exist and corresponds to given one
* to be the source of topology data

Discovery package:
Entities:
* lnwire.AnnounceSignature
* lnwire.ChannelAnnouncement
* lnwire.NodeAnnouncement
* lnwire.ChannelUpdateAnnouncement

Responsibilities:
* validate announcement signatures
* sync topology with newly connected peers
* handle the premature annoucement
* redirect topology changes to the router susbsystem
* broadcast announcement to the rest of the network
* exchange channel announcement proofs

Before that moment all that was in the 'routing' which is quite big for
one subsystem.

split
2017-03-29 19:49:05 -07:00