Commit Graph

416 Commits

Author SHA1 Message Date
Johan T. Halseth
70aeda1589
channeldb/graph: don't create node bucket in PruneGraph
Instead return ErrSourceNodeNotSet directly. This would be returned from
the call pruneGraphNodes -> sourceNode anyway.
2018-12-06 10:22:16 +01:00
Johan T. Halseth
9d467d3534
channeldb/graph: reuse nodes bucket in deleteLightningNode
Lets us avoid passing the tx from pruneGraphNodes
2018-12-06 10:22:16 +01:00
Johan T. Halseth
1b9ca06563
channeldb/graph: reuse nodes bucket when fetchin source node 2018-12-06 10:22:16 +01:00
Johan T. Halseth
86d40636cd
channeldb/graph: don't create bucket in delEdgeUpdateIndexEntry
We are deleting what's in the bucket, so if it doesn't exist, just
return early with a non-error.
2018-12-06 10:22:16 +01:00
Johan T. Halseth
84de318553
channeldb/graph: don't create bucket in UpdateEdgePolicy
instead return ErEdgeNotFound, which would be returned anyway when
querying the edgeIndex for the channel.
2018-12-06 10:22:15 +01:00
Johan T. Halseth
9722323161
channeldb/graph: don't create node bucket in DeleteChannelEdge
Instead return ErrGraphNodeNotFound directly. If the node bucket was
created it would be empty, and the call delChannelByEdge ->
fetchChanEdgePolicies -> fetchChanEdgePolicy ->
deserializeChanEdgePolicy -> fetchLightningNode would return this error
anyway.
2018-12-06 10:22:15 +01:00
Johan T. Halseth
351f4aab79
channeldb/graph: don't create buckets in DeleteChannelEdge
Instead return ErrEdgeNotFound if buckets don't exist. This would be
returned anyway, when the chanIndex is checked for the channel point in
question.
2018-12-06 10:22:15 +01:00
Johan T. Halseth
5d8d99b7bc
channeldb/graph: don't create bucket in UpdateChannelEdge
It would return ErrEdgeNotFound when edge not found in bucket anyway.
2018-12-06 10:22:15 +01:00
Johan T. Halseth
81fe6e73ed
router+graph: return ErrGraphNodesNotFound if no nodes to prune
Avoids creating a bucket unneccessarily.
2018-12-06 10:22:15 +01:00
Johan T. Halseth
3d7bbd6d72
channeldb/graph: write max 80 sig len for nodes 2018-12-05 09:31:26 +01:00
Olaoluwa Osuntokun
1fd3aac925
multi: switch from bolt packge to bbolt package for all imports 2018-11-29 20:33:49 -08:00
Johan T. Halseth
b1a35fc8f4
channeldb/migrations_test: add TestMigrateOptionalChannelCloseSummaryFields 2018-11-21 13:36:42 +01:00
Johan T. Halseth
da3f515f12
channeldb/db_test: add TestFetchClosedChannelForID 2018-11-21 10:28:56 +01:00
Johan T. Halseth
45b132a954
channeldb/db: define FetchClosedChannelForID
FetchClosedChannelForID is used to find the channel close summary given
only a channel ID.
2018-11-21 10:28:56 +01:00
Johan T. Halseth
0b9a323fcb
channeldb/channel: add LastChanSync field to CloseChannelSummary
This commit adds an optional field LastChanSyncMsg to the
CloseChannelSummary, which will be used to save the ChannelReestablish
message for the channel at the point of channel close.
2018-11-21 10:28:43 +01:00
Johan T. Halseth
46c961aa17
channeldb/migrations: migrate ChannelCloseSummary 2018-11-21 10:27:58 +01:00
Johan T. Halseth
28b15dcbbb
channeldb/channel: write boolean to indicate presence of ChannelCloseSummary fields 2018-11-21 10:27:58 +01:00
Johan T. Halseth
149a8ce94f
channeldb/legacy_serialization: add deserializeCloseChannelSummaryV6
This commit adds a new file legacy_serialization.go, where a copy of the
current deserializeCloseChannelSummary is made, called
deserializeCloseChannelSummaryV6.

The rationale is to keep old deserialization code around to be used
during migration, as it is hard maintaining compatibility with the old
format while changing the code in use.
2018-11-21 10:12:05 +01:00
Wilmer Paulino
e795f7fce4
channeldb/graph: add method to determine if a node is public
In this commit, we add a method to the ChannelGraph struct that
determines whether a node is seen as public based on graph's source
node's point of view.
2018-10-24 17:28:53 -07:00
Johan T. Halseth
9cba3e813a
Merge pull request #1992 from halseth/listinvoices-offset
Make reversed listinvoices consistent in edge cases
2018-10-24 17:25:54 -07:00
Wilmer Paulino
28cf413055
channeldb: add method to retrieve a node's node announcement 2018-10-23 18:42:25 -07:00
Olaoluwa Osuntokun
4c0ca37174
Merge pull request #1389 from Bluetegu/noprivate-describegraph-1037
Add --noprivate flag to describegraph rpc to filter out private channels
2018-10-16 20:01:35 -07:00
Olaoluwa Osuntokun
3fda1029c0
Merge pull request #1786 from Roasbeef/golang-1.1
build+docs: bump to golang 1.11
2018-10-08 13:26:07 +09:00
Olaoluwa Osuntokun
d8e6085c17
multi: update to go 1.11 gofmt 2018-10-07 14:37:38 +09:00
Conner Fromknecht
59b459674d
multi: init subsystem loggers via build pkg 2018-10-05 13:04:45 +09:00
bluetegu
bd75a56855 Add unit test for db Wipe. 2018-10-04 13:35:42 -04:00
Olaoluwa Osuntokun
13802b4218
Merge pull request #1963 from wpaulino/create-chan-buckets-once
channeldb: ensure channel buckets are only created once
2018-09-28 17:06:39 -07:00
Johan T. Halseth
22d0e5b43e
channeldb/invoice test: add more tests for edge cases 2018-09-28 13:00:57 +02:00
Johan T. Halseth
0c51e31d1c
channeldb/invoices+test: don't return invoices on reversed query at index 1
Previously a call to QueryInvoices with reversed=true and index_offset=1
would make the cursor point to the first available invoice (num 1) that
would be returned as part of the response. This is inconsistent with the
othre indexes, so we instead just return an empty list in this case.

A test case for this situation is also added.
2018-09-28 13:00:57 +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
Wilmer Paulino
f13c1d2787
channeldb: ensure channel buckets are only created once
In this commit, we ensure that we only create the sub-bucket for
channels once: at the time of creation. We do this as otherwise it's
possible that a method that mutates a channel's state is called after it
has already been closed on-chain, leading to the channel bucket being
recreated.
2018-09-21 17:14:59 -07:00
Joost Jager
ab67b9a4de
rpcserver+lnrpc+lncli: add AbandonChannel rpc call
Using AbandonChannel, a channel can be abandoned. This means
removing all state without any on-chain or off-chain action.
A close summary is the only thing that is stored in the db after
abandoning.

A specific close type Abandoned is added. Abandoned channels
can be retrieved via the ClosedChannels RPC.
2018-09-18 12:20:27 -07:00
Conner Fromknecht
974ec02d24
channeldb/migrations: improve performance of edge update migration
This commit modifies the edge update index
migration to avoid repetitive calls to
Cursor.First(). Instead, we construct a set
of all edge update keys to remove, and then do
a second pass to remove each from the bucket.
Additional log messages are included to notify
users on progress, as some have reported long
migration times.
2018-09-17 00:05:24 -07:00
Olaoluwa Osuntokun
3b2c807288
channeldb: fix bug in migration from 0.4 to 0.5
In this commit, we fix a bug in the latest database migration when
migrating from 0.4 to 0.5. There's an issue in bolt db where if one
deletes a bucket that has a key with a nil value, it thinks that's a sub
bucket and attempts a bucket deletion. This will fail as it's not
actually a sub-bucket.  We get around this by using a cursor to manually
delete items in the
bucket.

Fixes #1907.
2018-09-14 12:39:44 -07:00
Olaoluwa Osuntokun
9e99f13f8d
Merge pull request #1898 from Roasbeef/fix-migration
channeldb: don't use KeyN in latest migration
2018-09-13 14:12:52 -07:00
Wilmer Paulino
7e6eb44cf8
channeldb/invoice_test: refactor TestQueryInvoices and add reverse test cases 2018-09-12 22:11:57 -07:00
Wilmer Paulino
0fe35e0014
channeldb/invoices: extend invoice queries to allow backwards pagination 2018-09-12 22:11:56 -07:00
Olaoluwa Osuntokun
034198ffb7
channeldb: don't use KeyN in latest migration
In this commit, we fix a bug in the latest migration that could cause
the migration to end in a panic. Additionally, we modify the migration
to exit early if the bucket wasn't found, as in this case, no migration
is required.

Fixes #1874.
2018-09-12 22:06:11 -07:00
Olaoluwa Osuntokun
09924f3f2c
channeldb: relax bucket assumptions for latest db migration
In this commit, we no longer assume that the bucket hierarchy has been
created properly when applying the latest DB migration. On older nodes
that never obtained a channel graph, or updated _before_ the query sync
stuff was added, then they're missing buckets that the migration expects
them to have.

We fix this by simply creating the buckets as we go, if needed.
2018-09-11 16:09:25 -07:00
Olaoluwa Osuntokun
3e67321aa7
channeldb: fix bucket creation hierarchy in createChannelDB
In this commit, we fix a bug in the bucket creation code in
createChannelDB. This bug can cause migrations on older nodes to fail,
as we expect the bucket to already have been created. With this commit,
we ensure that all the buckets under the main node and edges bucket are
properly created. Otherwise, a set of the newer migrations will fail to
apply for nodes updating from 0.4.
2018-09-09 15:49:28 -07:00
Olaoluwa Osuntokun
874002022f
channeldb: remove unused fwdPackageLogBucket key
In this commit, we move the declaration of the key for an unused bucket.
In the past, this bucket was used to store the revocation forwarding
package log. However, this has been moved under the key
`fwdPackagesKey`.
2018-09-09 15:47:52 -07:00
maurycy
ac24b12bf2
multi: fix various typos in comments 2018-09-07 06:51:49 +02: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
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