Commit Graph

359 Commits

Author SHA1 Message Date
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
Olaoluwa Osuntokun
d129e7c890
channeldb: update ChannelView to return new EdgePoint struct
In this commit, we update the ChannelView method to be compatible with
the new set of interfaces that require the script to be passed in in
addition to the outpoint. In order to do this, we introduce a new
EdgePoint struct which packages together a channel point along with the
funding pkScript. Along the way, we've copied over a utility method from
the lnwallet package to avoid having to deal with an import cycle.
2018-07-31 21:28:54 -07:00
Johan T. Halseth
6cdf0e2d6e
channeldb/channel: methods for marking borked+dataloss commitPoint in db 2018-07-31 15:16:22 +02:00
Johan T. Halseth
ea6aca26a5
channeldb: make chanStatus unexported
Since the ChanStatus field can be changed from concurrent callers, we
make it unexported and add the method ChanStatus() for safe retrieval.
2018-07-31 15:07:30 +02:00
Conner Fromknecht
5aa96758e4
channeldb/db: return all channels if multiple chains exist 2018-07-30 23:39:40 -07:00
Olaoluwa Osuntokun
ef4c7d2a78
channeldb: add new TestAddChannelEdgeShellNodes test 2018-07-22 21:05:52 -07:00
Olaoluwa Osuntokun
2e75499787
channeldb+routing: move adding shell nodes into db txn of AddChannelEdge
In this commit, we fix a slight race condition that can occur when we go
to add a shell node for a node announcement, but then right afterwards,
a new block arrives that causes us to prune an unconnected node. To
ensure this doesn't happen, we now add shell nodes within the same db
transaction as AddChannelEdge. This ensures that the state is fully
consistent and shell nodes will be added atomically along with the new
channel edge.

As a result of this change, we no longer need to add shell nodes within
the ChannelRouter, as the database will take care of this operation as
it should.
2018-07-22 21:02:53 -07:00
Olaoluwa Osuntokun
8519ea869d
channeldb: add logging for nodes pruned from the channel graph 2018-07-22 21:00:51 -07:00
Olaoluwa Osuntokun
6bf15e8f2b
channeldb: fix bug in pruneGraphNodes by switching to using ref counting
In this commit, we fix an existing bug in the pruneGraphNodes method.
Before this commit, if a node was involved in a channel, but only one of
the edges was advertised, then either it, or the other node would be
erroneously pruned from the graph. They shouldn't be pruned as there's
still an edge connecting the, although only 1/2 of the edge is actually
advertised.

In order to fix this, we'll now do two passes: the first pass will
populate a ref count map of all known nodes in the graph, the second
pass will increment the ref count each time a node is found in the
graph. With this two pass method, we ensure that nodes are only deleted
if there are absolutely no edges pointing to them within the graph.
2018-07-22 18:59:36 -07:00
Olaoluwa Osuntokun
131eea4960
channeldb: modify TestPruneGraphNodes to test nodes w/ single edge
In this commit, we extend the TestPruneGraphNodes test to also test the
case of when a node is involved in a channel, but only a single edge for
that channel has been advertised. In order to test this, we add an
additional node to the graph, and also a new channel. However, this
channel will only have a single edge advertised. As result, when we
prune the set of edges, the only node remaining should be the node that
didn't have any edges at all.
2018-07-22 18:57:18 -07:00
Olaoluwa Osuntokun
0645261e5e
channeldb: add nwe PruneGraphNodes method to prune unconnected nodes 2018-07-21 19:49:59 -07:00
Olaoluwa Osuntokun
3a465c64b5
channeldb: modify pruneGraphNodes to prune nodes if no edges exist 2018-07-21 19:49:16 -07:00
Olaoluwa Osuntokun
bca926d6af
Merge pull request #1371 from wpaulino/prune-link-nodes
server: prune link nodes without any open channels
2018-07-21 18:55:38 -07:00
Wilmer Paulino
0aa1f39af8
channeldb+server: prune link nodes on startup
In this commit, we extend the server's functionality to prune link nodes
on startup. Since we currently only decide whether to prune a link node
from the database based on a channel close, it's possible that we have
link nodes lingering from before this functionality was added on.
2018-07-17 17:35:31 -07:00
Wilmer Paulino
0e4d350e56
channeldb: prune nodes with no open channels left from the graph 2018-07-17 17:35:29 -07:00
Wilmer Paulino
4578eec8a1
channeldb: garbage collect link nodes with no open channels remaining 2018-07-17 17:35:27 -07:00