Commit Graph

140 Commits

Author SHA1 Message Date
Conner Fromknecht
cf2c371042
multi: fix linting errors 2018-08-02 18:20:50 -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
Olaoluwa Osuntokun
6f60f139f4 multi: switch over import paths from roasbeef/* to btcsuite/* 2018-07-13 17:05:39 -07:00
Conner Fromknecht
30ff91913d
channeldb/channel: use public Read/WriteElements 2018-07-03 17:07:09 -07:00
Conner Fromknecht
56e5eed037
channeldb/channel: update short chan id for fwd packager 2018-06-19 13:48:08 +01: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
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
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
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
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
Conner Fromknecht
2df9fb5510
channeldb/channel: adds fwding package to channeldb 2018-03-09 14:45:30 -08:00
Olaoluwa Osuntokun
705661a39e
channeldb: replace raw keys in ChannelConfig with keychain.KeyDescriptor
In this commit, we remove references to raw keys from the main
ChannelConfig struct and instead replace it with usage of
keychain.KeyDescriptor. We do this, as the ChannelConfig as it stands
is a near complete static description of a channel. In the future, it
will be possible to export these static descriptions as backups. We
prefer the KeyDescriptor of a plain PublicKey, as the KeyLocator
portion of the struct allows a stateless signer to re-derive the keys
as needed when signing.
2018-03-06 16:04:01 -05:00
Johan T. Halseth
004563b20b
channeldb: add todo making feerate explicit type 2018-02-26 22:42:27 +01:00
Johan T. Halseth
65723387fa
channeldb: update ChannelConstraints godoc
This commit changes the definition of the
constraints in the ChannelConstraints struct
to specify that these are all constraints the
*owner* of the set of constraints must *never
violate*.

This is done to make it easier to check that
a particular node is not violating any
constraint for a gien update, as before it
could violate constraints found both in its
local and the remote contraints.
2018-02-08 18:35:24 -05: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
MeshCollider
4b1cc98808 multi: apply roasbeef diff to support incoming socks.ProxiedAddr 2018-02-05 17:37:46 -08:00
MeshCollider
d8f453d9dc channeldb: remove address resolution from channeldb 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
ebb4c84b32
channeldb: add new LatestCommitments and RemoteRevocationStore methods
These methods will allow the chainWatcher to ensure it has the latest
channel state before attempting to construct any resolution objects.
2018-01-22 19:19:51 -08:00
Olaoluwa Osuntokun
b4fc34a93a
channeldb: add ShortChanID to close channel summary 2018-01-22 19:19:35 -08:00
Olaoluwa Osuntokun
5d7119fe9c
channeldb: expose methods to serialize HTLC's on-disk
These new methods will be used by the contract court package to
properly serialize the state of HTLC’s that have yet to be fully
resolved on-chain.
2018-01-22 19:19:35 -08:00
Conner Fromknecht
1d69526874
channeldb/channel: adds IsBorked to OpenChannel 2018-01-05 13:47:17 -08:00
Johan T. Halseth
48e22219c0 channeldb: add ChannelFlags to OpenChannel struct
This commit adds the ChannelFlags field, of type
lnwire.FundingFlags, to the OpenChannel struct,
including serialization for database storage.
This is done to preserve the flags that were
sent during channel opening, currently used
to determine whether a channel should be made
public or not after opening.
2017-12-17 18:35:34 -08:00
Olaoluwa Osuntokun
12e5951434
channeldb: extend ChannelConfig with new HtlcBasePoint key 2017-11-16 20:00:01 -08:00
Olaoluwa Osuntokun
1fb05e0436
channeldb: properly craft key for reading/writing channel commitments
In this commit, we fix an existing bug that arose due to incorrectly
crafting the key we use to store channel commitments. Before this
commit, we tried to copy to a slice that hadn’t been allocated yet. As
a result, the key would only have the 0x00 or 0x01 as its value. We fix
this by properly crafting the key using the built-in append function.
2017-11-10 19:51:12 -08:00
Olaoluwa Osuntokun
699e5327e1
channeldb: don't delete the chainHash bucket in CloseChannel
In this commit, we fix an existing bug wherein if we closed two
channels, then we were unable to read the channel state afterwards as
we deleted the enclosing bucket.
2017-11-10 19:51:12 -08:00
Olaoluwa Osuntokun
3875754e0f
channeldb: also update chanInfo when updating commitment
In this commit, we fix an existing bug wherein we failed to update the
channels state once we accepted a new commitment. As a result, after a
state transition, if the channel state was read from disk, values like
TotalMSatSent wouldn’t be properly updated.
2017-11-10 19:51:11 -08:00
Olaoluwa Osuntokun
1d6e5ad1ef
channeldb: add missing mutex interaction to new methods 2017-11-10 19:51:11 -08:00
Olaoluwa Osuntokun
0178920cba
channeldb: update CloseChannel to adhere to new disk structure
In this commit, we update the CloseChannel method to respect the new
on-disk bucket based structure. Additionally, we now ensure that we
delete the new chainBucket.
2017-11-10 19:50:48 -08:00
Olaoluwa Osuntokun
3cf4ac8237
channeldb: add a new ChainHash field to ChannelCloseSummary 2017-11-10 19:50:48 -08:00
Olaoluwa Osuntokun
da22078995
channeldb: modify FindPreviousState to return a ChannelCommitment 2017-11-10 19:50:47 -08:00
Olaoluwa Osuntokun
5bdff9585b
channeldb: modify RevocationLogTail to return a ChannelCommitment 2017-11-10 19:50:47 -08:00
Olaoluwa Osuntokun
374cab7467
channeldb: rename AppendToRevocationLog to AdvanceCommitChainTail
In this commit, in addition to the renaming we’ve modified the behavior
of AdvanceCommitChainTail as follows: this method now will simply
atomically advance the commitment tail, set the new commitment to the
prior dangling commitment, and update the on-disk revocation log.

The macho expects the new revocation state to already be stored within
the channel. This method is to be called once the remote party revokes
their current commitment state.
2017-11-10 19:50:47 -08:00
Olaoluwa Osuntokun
b89c14616c
channeldb: add new RemoteCommitChainTip method
In this commit, we add a new method: RemoteCommitChainTip. This method
allows callers to poll the database state to check if we have an
un-acked commitment for the remote party. If so, then it should be
retransmitted once a communication channel has been re-established with
the channel peer. This method will return ErrNoPendingCommit if we
don’t currently have a dangling commitment.
2017-11-10 19:50:46 -08:00
Olaoluwa Osuntokun
893cda3ac2
channeldb: add new AppendRemoteCommitChain method
In this commit, we add a new method AppendRemoteCommitChain. This
method is meant to be used once we extend a new state to the remote
party, but before we actually transmit the CommitSig message. With this
method, we store a fully valid CommitDiff on disk which can be used in
the case that we need to retransmit the state to the party as they
didn’t fully receive it.
2017-11-10 19:50:46 -08:00
Olaoluwa Osuntokun
10a54a45fd
channeldb: expand the CommitDiff struct with the addition of LogUpdate
In this commit we finalized the structure of the CommitDiff struct by
adding a set of LogUpdates, and also a valid CommitSig message.

The LogUpdate struct houses a messages that were transmitted and
locked-in with the new commitment state. We include the LogIndex along
with the wire messages itself in order to be able to properly
reconstruct the update log upon restart.

The CommitSig message included should be transmitted after the set of
LogUpdates, and fully covers the new commitment state and any new (or
already present) HTLC’s that were included as part of the state.
2017-11-10 19:50:45 -08:00
Olaoluwa Osuntokun
3e3969eb66
channeldb: modify UpdateCommitment to accept a ChannelCommitment
In this commit, we modify the UpdateCommitment method to accept a full
ChannelCommitment rather than a new transaction, the sig, and a
ChannelDelta. This new structure of this method also takes advantage of
the new bucket structure of the storage schema. Additionally, this
method will now atomically swap in the new passed commitment to point
to the LocalCommitment value within the struct.
2017-11-10 19:50:45 -08:00
Olaoluwa Osuntokun
2dcd82e779
channeldb: add new MarkAsOpen method to OpenChannel struct
In this commit we add a new MarkAsOpen method to the OpenChannel
struct. This method replaces the existing MarkChannelAsOpen method
which targeted the database struct itself.
2017-11-10 19:50:44 -08:00
Olaoluwa Osuntokun
4ae0b008ed
channeldb: modify storage of OpenChannel struct to use new codec.go
In this commit we comptely overhaul the existing storage of the
OpenChannel struct to use the new common serialization defined within
the codec.go file. Additionally, we’ve modified the structure of the
channel database on disk. Rather then use the existing prefix based
segmentation, everything is now bucket based. This has resulted in much
simpler and easier to follow code. The bucket progression is:
openChannelBucket -> nodeBucket -> chainBucket -> channelBucket. We add
a chainBucket as it’s possible that in the future we may have several
channels on distinct chains with a given node.

With the above changes, we’re able to delete much of the existing code
within the file, drastically reducing its size.
2017-11-10 19:50:44 -08:00