Commit Graph

374 Commits

Author SHA1 Message Date
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
785efcfaa2
channeldb: also ignore the EOF error when trying to read ExtraOpaqueBytes
In this commit, we account for the additional case wherein the
announcement hasn't yet been written with the extra zero byte to
indicate that there aren't any remaining bytes to be read. Before this
commit, we accounted for the case where the announcement was written
with the extra byte, but now we ensure that legacy nodes that upgrade
will be able to boot properly.
2018-09-05 16:42:23 -07:00
Olaoluwa Osuntokun
16b5a67c3a
Merge pull request #1842 from wpaulino/dedup-chan-updates-horizon
channeldb: dedup channel edges returned from ChanUpdatesInHorizon
2018-09-04 21:24:40 -07:00
Olaoluwa Osuntokun
48072f8e82
channeldb: add limit on the max number of opaque bytes per announcement
In this commit, we add a new limit on the largest number of extra opaque
bytes that we'll allow to be written per vertex/edge. We do this in
order to limit the amount of disk space that we expose, as it's possible
that nodes may start to pad their announcements adding an additional
externalized cost as nodes may need to continue to store and relay these
large announcements.
2018-09-04 20:52:45 -07:00
Olaoluwa Osuntokun
a35bdd4233
channeldb: extend set of graph tests to include opque data where pertinent 2018-09-04 20:52:43 -07:00
Olaoluwa Osuntokun
f5c582d8d7
channeldb: add new ExtraOpaqueData to edge policy+update and node ann
In this commit, we add a mirror set of fields to the ones we recently
added to the set of gossip wire messages. With these set of fields in
place, we ensure that we'll be able to properly store and re-validate
gossip messages that contain a set of extra/optional fields.
2018-09-04 20:52:43 -07:00
Wilmer Paulino
3f58c2dea4
channeldb/graph: dedup channel edges returned from ChanUpdatesInHorizon
In this commit, we ensure that we de-duplicate the set of channel edges
returned from ChanUpdatesInHorizon. Other subsystems within lnd use this
method to retrieve and send all the channels with updates within a time
series to network peers. However, since the method looks at the edge
update index, which can include up to two entries per edge for each
policy, it's possible that we'd send channel announcements and updates
twice, causing extra bandwidth.
2018-09-04 18:48:21 -07:00
Wilmer Paulino
d3cf3168d2
channeldb/graph_test: ensure policies for an edge have different
timestamps

In this commit, we ensure policies for edges we create in
TestChanUpdatesInHorizon have different update timestamps. This ensures
that there are two entries per edge in the edge update index. Because of
this, the test will fail because ChanUpdatesInHorizon will return
duplicate channel edges due to looking at all the entries within the
edge update index. This will be addressed in a future commit to allow
the set of tests to pass once again.
2018-09-04 18:36:25 -07:00
Wilmer Paulino
85ea08fd17
channeldb: add migration to properly prune edge update index
In this commit, we introduce a migration to fix some of the recent
issues found w.r.t. the edge update index. The migration attempts to fix
two things:

1) Edge policies include an extra byte at the end due to reading an
extra byte for the node's public key from the serialized node info.

2) Properly prune all stale entries within the edge update index.

As a result of this migration, nodes will have a slightly smaller in
size channeldb. We will also no longer send stale edges to our peers in
response to their gossip queries, which should also fix the fetching
channel announcement for closed channels issue.
2018-09-04 18:33:43 -07:00
Wilmer Paulino
c1633da252
channeldb/graph_test: extend prune edge update index test to update edges
In this commit, we extend TestChannelEdgePruningUpdateIndexDeletion test
to include one more update for each edge. By doing this, we can
correctly determine whether old entries were properly pruned from the
index once a new update has arrived.
2018-09-04 18:33:41 -07:00
Wilmer Paulino
8dec659e10
channeldb/graph_test: properly check entries within edge update index
Due to entries within the edge update index having a nil value, the
tests need to be modified to account for this. Previously, we'd assume
that if we were unable to retrieve a value for a certain key that the
entry was non-existent, which is why the improper pruning bug was not
caught. Instead, we'll assert the number of entries to be the expected
value and populate a lookup map to determine whether the correct entries
exist within it.
2018-09-04 18:33:40 -07:00
Wilmer Paulino
2f22e6c35f
channeldb/graph: properly determine old update timestamp for an edge
In this commit, we fix a lingering issue within the edge update index
where entries were not being properly pruned due to an incorrect
calculation of the offset of an edge's last update time. Since the
offset is being determined from the end to the start, we need to
subtract all the fields after an edge policy's last update time from the
total amount of bytes of the serialized edge policy to determine the
correct offset. This was also slightly off as the edge policy included
an extra byte, which has been fixed in the previous commit.

Instead of continuing the slicing approach however, we'll switch to
deserializing the raw bytes of an edge's policy to ensure this doesn't
happen in the future when/if the serialization methods change or extra
data is included.
2018-09-04 18:33:38 -07:00
Wilmer Paulino
492d581df6
channeldb/graph: fix off-by-one public key slice
In this commit, we fix an off-by-one error when slicing the public key
from the serialized node info byte slice. This would cause us to write
an extra byte to all edge policies. Even though the values were read
correctly, when attempting to calculate the offset of an edge's update
time going backwards, we'd always be incorrect, causing us to not
properly prune the edge update index.
2018-09-04 18:31:38 -07:00
Wilmer Paulino
06344da62e
channeldb/graph: refactor UpdateEdgePolicy to use existing db transaction 2018-09-04 18:31:37 -07:00
Wilmer Paulino
aa3e2b6ba4
channeldb/graph: identify edge chan id on failure 2018-09-04 18:31:36 -07:00
Olaoluwa Osuntokun
4f20905ac1
Merge pull request #1719 from cfromknecht/duplicate-payments
Control Tower: Sender-side checks for duplicate payments #2
2018-08-22 21:22:38 -07:00
Olaoluwa Osuntokun
9f4685228e
Merge pull request #1763 from valentinewallace/listinvoices-pagination
channeldb+rpc: add pagination of listinvoices
2018-08-21 20:14:18 -07:00
Conner Fromknecht
86b347c996
channeldb/payments: make payment status helper methods
This commit splits FetchPaymentStatus and
UpdatePaymentStatus, such that they each invoke
helper methods that can be composed into different
db txns. This enables us to improve performance on
send/receive, as we can remove the exclusive lock
from the control tower, and allow concurrent calls
to utilize Batch more effectively.
2018-08-21 19:23:25 -07:00
Conner Fromknecht
0865ac7cf6
channeldb/migrations_test: assert locally-sourced circuits...
in the circuit map are marked StatusInFlight. We also
check that hashes contained in forwarded circuits are
not updated.
2018-08-21 19:23:25 -07:00
Conner Fromknecht
11bb5685f9
channeldb/migrations: mark locally-sourced payments as InFlight...
by reading the payment hash from the circuit map.
2018-08-21 19:23:25 -07:00
Conner Fromknecht
e7c0f4c5dc
channeldb/payments: touch up docs 2018-08-21 19:23:23 -07:00
Conner Fromknecht
3a579f3305
channeldb/migrations_test: touch up docs 2018-08-21 19:23:23 -07:00
Conner Fromknecht
93e5f9a545
channeldb/migrations: touch up documentation 2018-08-21 19:23:23 -07:00
Conner Fromknecht
9f46727507
channeldb/meta_test: restore migration helper + godocs 2018-08-21 19:23:23 -07:00
Conner Fromknecht
090e97cd3b
channeldb/db_test: move migration helper back to meta_test 2018-08-21 19:23:23 -07:00
Conner Fromknecht
79a4203346
channeldb/db: add comment describing migration 2018-08-21 19:23:23 -07:00
Vadym Popov
41e31e0909
channeldb: applying payment statuses migration to current database 2018-08-21 19:23:22 -07:00
Vadym Popov
24e3310f13
channeldb: payment statuses migration test 2018-08-21 19:23:21 -07:00
Vadym Popov
f405376b8b
channeldb: add migration for payment statuses for completed payments 2018-08-21 19:23:21 -07:00
Vadym Popov
7f6fbd4533
channeldb: test of payment statuses transitions 2018-08-21 19:23:21 -07:00
Vadym Popov
7296cfb425
channeldb: add payment statuses: ground, in flight, completed 2018-08-21 19:23:18 -07:00
Wilmer Paulino
f315b5b0d1
channeldb: support querying for invoices within a specific time range
In this commit, we introduce support for querying the database for invoices
that occurred within a specific add index range. The query format includes an
index to start with and a limit on the number of returned results.

Co-authored-by: Valentine Wallace <valentine.m.wallace@gmail.com>
2018-08-21 18:00:08 -07:00
Conner Fromknecht
af6c4e5174
channeldb/channel: adds readLogKey for chanids
Adds helper method to parse short chanids used as keys in the forwarding package.
2018-08-21 00:30:26 -07:00
Conner Fromknecht
81778664a7
channeldb/channel: expose AckAddHtlc and AckSettleFail 2018-08-21 00:30:26 -07:00
Conner Fromknecht
215a47e6bf
channeldb/forwarding_package: loosen Add/SettleFailRef acking
This commit loosens the fwdpkg reference acking to be more tolerant
of prior deletions. Specifically, we won't fail if certain channels
are not found or fwdpkgs do not exist. This will make us more
tolerant to future changes where we:
 - remove fwdpkgs on channel close
 - defensively cleanup stray responses
2018-08-21 00:30:23 -07:00
Olaoluwa Osuntokun
9353ab00b1
channeldb: ensure that we remove update index entries for nodes upon deletion 2018-08-16 18:22:55 -07:00
Olaoluwa Osuntokun
06d03b55a3
channeldb: add new TestNodePruningUpdateIndexDeletion test
In this commit, we add a new test to expose a lurking bug within the
graph database code. As is, when we go to delete a node from the
database, we don't also remove the entries within the update index. As a
result, if a user attempted to call NodeUpdatesInHorizon (or typically
as part of the p2p handshake), we would error out, as we would try to
read a node that no longer existed in the graph, as it was pruned.
2018-08-16 18:20:58 -07:00
Olaoluwa Osuntokun
90cdc9da8f
channeldb: add String() method for EdgePoint
In this commit we fix a minor logging artifact. After the switch to
EdgePoint, the FilteredChainView implementations will try to log the
struct directly, as prior they would have an outpoint object. We restore
this behavior by adding a String() method to EdgePoint which will simply
proxy through to the outpoint so we can log that directly.
2018-08-15 21:43:39 -07:00
Olaoluwa Osuntokun
26032f5956
channeldb: extend TestFetchClosedChannels to populate local chan cfg properly 2018-08-14 19:11:41 -07:00
Olaoluwa Osuntokun
d5863d03ae
Merge pull request #1660 from lightningnetwork/fetch-allll-channels
channeldb/db: return all channels if multiple chains exist
2018-08-09 20:59:28 -07:00
Olaoluwa Osuntokun
0f3c0ccf85
channeldb: add new FetchOtherNode method to ChannelEdgeInfo
In this commit, we add a new method to the ChannelEdgeInfo that will
allow the path finding logic to get the node opposite the pivot node
without first creating a new db transaction. The new method is able to
use an existing db transaction, or create a new one if needed.
2018-08-09 20:47:01 -07:00
Olaoluwa Osuntokun
ce7bfae4f7
channeldb: ensure we always check error from fetchChanEdgePolicy 2018-08-09 20:46:04 -07:00
Olaoluwa Osuntokun
0109672835
channeldb: add new db field for ChannelEdgeInfo to allow new methods 2018-08-09 20:45:39 -07:00
Joost Jager
6c918a1806 channeldb: store unknown policies in database
The commit ensures that for every channel, there will always
be two entries in the edges bucket. If the policy from one or
both ends of the channel is unknown, it is marked as such.

This allows efficient lookup of incoming edges. This is
required for backwards payment path finding.
2018-08-09 20:23:40 -07:00
Olaoluwa Osuntokun
8379bbaa9b
Merge pull request #1673 from cfromknecht/prevent-db-reversions
channeldb: fail Open on db reversion
2018-08-07 15:47:02 -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
Conner Fromknecht
dff7706d04
channeldb/meta_test: adds TestMigrationReversion
Adds a test asserting that we will fail to open
a channeldb with a version higher than the
highest known version to the current build of
lnd.
2018-08-02 18:18:49 -07:00
Conner Fromknecht
e23fc40d63
channeldb/db: check for db reversions on startup 2018-08-02 16:46:17 -07:00
Conner Fromknecht
ee34b9c7b0
channeldb/error: adds ErrDBReversion error
Adds an error for signaling that we detected
the case where a user is trying to revert
to prior version before a db migration.
2018-08-02 16:45:03 -07:00