Commit Graph
448 Commits
Author SHA1 Message Date
Olaoluwa Osuntokun 24d97b5ee5 channeldb: add new test to exercise invoice time series index 2018-07-06 12:21:58 -07:00
Olaoluwa Osuntokun 532975588d channeldb: update existing invoice tests to due to recent field additions 2018-07-06 12:21:57 -07:00
Olaoluwa Osuntokun 24ae13d3a5 channeldb: add two methods to allow seeking into the invoice time series
In this commit, we add two new methods: InvoicesAddedSince and
InvoicesSettledSince. These methods will be used by higher level
sub-systems that implement notifications to deliver any notifications
backlog based on the last add index, and last settle index that the
client knows of.

It's important to note that care has been taken to ensure that this new
API can be used in a backwards compatible manner. If a client specifies
and index of 0 for either of the methods, then no backlog will be sent.
This is due to the fact that current users of the API don't expect any
backlog notifications to be sent. Additionally, the index actually
starts at 1, instead of 0.
2018-07-06 12:21:57 -07:00
Olaoluwa Osuntokun 5d20c02ea8 channeldb: add new add+settle index to invoice database
In this commit, we add two new indexes to the invoice database: the add
index, and the settle index. These to indexes essentially form a time
series index on top of the existing primary index bucket. Each time an
invoice is added, we'll advance the addIndex seqno, and then create a
mapping from seqNo -> invoiceNum. Each time an invoice is settled, we'll
do the same, but within the settle index.

This change is required in order to allow callers to effectively seek
into the current invoice database in order to obtain notifications for
any invoices they may have missed out on while they were disconnected.
This will allow us to implement robust streaming invoice notifications
within lnd to ensure that clients never miss an event.
2018-07-06 12:21:56 -07:00
Olaoluwa Osuntokun fc0f0d33b2 channeldb: add new AmtPaid field to the Invoice struct
In this commit, in order to allow the caller to specify the amount that
was ultimately accepted for an invoice, the SettleInvoice method has
gained a new parameter: amtPaid. SettleInvoice will now populate the
final amount paid in the database upon db commit.
2018-07-06 12:21:56 -07:00
Olaoluwa Osuntokun dbf7e4525a lntest: ensure we always cancel active streaming notifications 2018-07-06 12:21:54 -07:00
Conner Fromknecht 75d7436f7a channledb/codec: add net.Addr and []net.Addr to codec 2018-07-03 17:07:10 -07:00
Conner Fromknecht 4cb7953f66 channledb/addr: remove silent encoding failure for unknown types 2018-07-03 17:07:10 -07:00
Conner Fromknecht c6c442f6b6 channledb/addr_test: add negative test for unknown types 2018-07-03 17:07:10 -07:00
Conner Fromknecht 21674c05e5 channeldb/codec: add concrete error for unknown types 2018-07-03 17:07:09 -07:00
Conner Fromknecht 1d5189bd25 channeldb/forwarding_log: use public Read/WriteElements 2018-07-03 17:07:09 -07:00
Conner Fromknecht 30ff91913d channeldb/channel: use public Read/WriteElements 2018-07-03 17:07:09 -07:00
Conner Fromknecht ec029ac7fd channeldb/codec: exposes Read/WriteElements 2018-07-03 17:07:09 -07:00
Olaoluwa Osuntokun e5f802c33c Revert "channeldb: explicitly store the FinalCltvDelta within the ContractTerm struct"
This reverts commit 8dcfeeaef5.
2018-06-29 12:40:42 -07:00
Olaoluwa Osuntokun 8dcfeeaef5 channeldb: explicitly store the FinalCltvDelta within the ContractTerm struct
In this commit, we move to explicitly storing a bit more information
within the invoice. Currently this information is already stored in the
payment request, but by storing it at this level, callers that may not
be in the state to fully decode a payment request can obtain this data.

We avoid a database migration by appending this data to the end of an
invoice. When decoding, we'll try to read out this extra information,
and simply return what we have if it isn't found.
2018-06-26 19:49:49 -07:00
Conner Fromknecht 56e5eed037 channeldb/channel: update short chan id for fwd packager 2018-06-19 13:48:08 +01:00
Conner Fromknecht 639c9875b2 channeldb/channel_test: test packager source updated 2018-06-19 13:48:08 +01: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 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
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 5f1d2524b8 channeldb: add address serialization tests 2018-06-04 20:41:34 -07:00
Wilmer PaulinoandEugene 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
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 70dffe7e99 channeldb: ensure that when we delete a channel we delete entry in edge update index
In this commit, we ensure that all indexes for a particular channel have
any relevant keys deleted once a channel is removed from the database.
Before this commit, if we pruned a channel due to closing, then its
entry in the channel update index would ever be removed.
2018-05-31 16:30:59 -07:00
Olaoluwa Osuntokun 12e73f55e9 channeldb: add database migration for new node+edge update indexes
In this commit, we add a new database migration required to update old
database to the version of the database that tracks the update index for
the nodes and edge policies. The migration is straight forward, we
simply need to populate the new indexes for the all the nodes, and then
all the edges.
2018-05-31 16:30:54 -07:00
Olaoluwa Osuntokun baed4d1f47 channeldb: add new methods required to implement new discovery.ChannelGraphTimeSeries interface
In this commit, we add a series of methods, and a new database index
that we'll use to implement the new discovery.ChannelGraphTimeSeries
interface interface. The primary change is that we now maintain two new
indexes tracking the last update time for each node, and the last update
time for each edge. These two indexes allow us to implement the
NodeUpdatesInHorizon and ChanUpdatesInHorizon methods. The remaining
methods added simply utilize the existing database indexes to allow us to
respond to any peer gossip range queries.

A set of new unit tests has been added to exercise the added logic.
2018-05-31 16:30:54 -07:00
Olaoluwa Osuntokun fc3d711cf0 Merge pull request #1248 from halseth/close-channel-fix
[bugfix] Wait for confirmation before marking channel cooperatively closed
2018-05-24 18:28:31 -07:00
Johan T. Halseth 72d9726e7f channeldb/channel: update IsPending godoc
The pending state definitin in ChannelCloseSummary was slightly changed
in such a way that channels that has had their commitment broadcasted
now is no longer considered "pending close". They now instead stay in
the open chan bucket with the ChanStatus "CommitmentBroadcasted" until
their commitment is confirmed. This commit updates the IsPending godoc
to reflect this.
2018-05-23 12:07:35 +02:00
Olaoluwa Osuntokun 71d7d4952f channeldb: remove premature buf.Grow optimization
This optimization isn't needed as a bytes.Buffer already comes
pre-allocated with 64-bytes as a fast path.
2018-05-22 17:52:45 -07:00
Olaoluwa Osuntokun 3f2aa1c368 channeldb: modify updateChanBucket to no longer auto-create buckets
In this commit, we modify the existing updateChanBucket function to no
longer auto-create buckets if they don't exist. We do this in order to
fix a class of bug that could arise wherein after a channel has actually
be closed (and the parent buckets removed) a method that mutates the
channel state is called, which then re-creates the relevant set of
buckets. As a result, subsequent calls to any RPCs which need to read
all the channels will fail as most of the fields won't actually be
populated.

After this commit, the fullSync method is the only one that's able to
create the full bucket hierarchy.
2018-05-22 16:32:36 -07:00
Conner Fromknecht f963f91a3c multi: use mutex-guarded ShortChanID() on OpenChannel 2018-05-09 16:06:49 -07:00
Conner Fromknecht 19b5eaa4dc channeldb/channel_test: adds RefreshShortChanID test 2018-05-09 16:06:49 -07:00
Conner Fromknecht 7ad56943c7 channeldb/channel: adds RefreshShortChanID 2018-05-09 16:06:49 -07:00
Johan T. Halseth f26ec38a74 channeldb: return ErrNoPendingCommit in case of no channel bucket 2018-05-08 13:41:52 +02:00
Olaoluwa Osuntokun 1ec5dc3c2d channeldb: additionally store static channel information in CloseChannelSummary
In this commit, we extend the CloseChannelSummary by also storing: the
current unrevoked revocation for the remote party, the next pending
unused revocation, and also the local channel config. We move to store
these as the provide an extra level of defense against bugs as we'll
always store information required to derive keys for any current and
prior states.
2018-05-03 21:29:23 -07:00
Conner Fromknecht 1b6101b0c0 channeldb/channel: add NextLocalHtlcIndex 2018-05-02 01:12:17 -07:00
Johan T. Halseth 0735b8e0b7 channeldb: add method for fetching channels waiting for closing tx
This commit adds a new method FetchWaitingCloseChannels to the database,
used for fetching OpenChannels that have a ChanStatus != Default. These
are channels that are borked, or have had a commitment broadcasted, and
is now waiting for it to confirm.

The fetchChannels method is rewritten to return channels exclusively
based on wheter they are pending or waitingClose.
2018-04-25 09:37:25 +02:00
Johan T. Halseth c51f6352c3 channeldb test: rename ForceClose->RemoteForceClose 2018-04-25 09:37:24 +02:00
Johan T. Halseth cde862e7e0 channeldb/codec: add ChannelStatus 2018-04-25 09:37:24 +02:00
Johan T. Halseth b7bb53a8b8 channeldb/channel: add property ChanStatus in place of IsBorked to OpenChannel
This commit changes the bool `IsBorked` in OpenChannel to a `ChanStatus`
struct, of type ChannelStatus. This is used to indicated that a channel
that is technically still open, is either borked, or has had a
commitment broadcasted, but is not confirmed on-chain yet.

The ChannelStatus type has the value 1 for the status Borked, meaning it
is backwards compatible with the old database format.
2018-04-25 09:37:23 +02: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
Olaoluwa Osuntokun 7a13378671 channeldb+contractcourt: add additional logging around co-op channel closes 2018-04-12 17:13:37 -07:00
Conner Fromknecht f594a242ea channeldb/channel_test: test ShortChanID is updated in-mem
Modifies TestFetchPendingChannels to verify that calls to
MarkAsOpen also modify the in-memory state. Previously we
only tested the persistent state loaded immediately after.
2018-03-27 17:07:15 -07:00
Conner Fromknecht 9fd73af589 channeldb: update chanid in-mem during MarkAsOpen
Modifies the MarkAsOpen operation to also update the
ShortChanID and IsPending fields in-memory. Before,
only the on-disk representation was updated, which
may have lead to stale data channel states being
passed in-memory.
2018-03-27 17:05:22 -07:00
Conner Fromknecht 5df8b52dae multi: set initiator funding txn 2018-03-11 15:06:22 -07:00
Conner Fromknecht db88c82169 channeldb/channel: add serialization for single funder funding txn 2018-03-11 13:58:40 -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