Commit Graph
100 Commits
Author SHA1 Message Date
Conner Fromknecht 89bd58786e lnwallet/channel: enforce absolute fee floor of 250 sat/kw
This enforces the _actualized_ fee rate of the  commitment transaction,
rather than the fee floor used for estimation. The new value of 250
sat/kw corresponds to 1 sat/byte, rather than 253 which is only rounded
up during estimation to account for the fact that BOLT 3 rounds down to
the nearest satoshi and that the vbyte fee estimation is lossy.

Previously we would incorrectly fail to sign the next commitment even
though the fee was technically high enough. Restarting with this commit
should solve the issue as long as the channel hasn't already gone to
chain.
2020-04-21 12:37:34 -07:00
Conner Fromknecht 3ab5899853 lnwallet/channel: fix log typo 2020-04-20 22:12:49 -07:00
Conner Fromknecht b467f549b7 htlcswitch/link: return error from AddPacket 2020-04-14 22:34:59 -07:00
Conner Fromknecht 0a3fdf0271 htlcswitch/test_utils: extend PendingCommit timeout
Flakes locally on darwin.
2020-04-14 22:34:59 -07:00
Conner Fromknecht 55f90be2a5 htlcswitch/mailbox: rename Settle/Fail queue to indicate replies
This commit renames the variables associated with processing the
Settle/Fail packets to indicate that they are replies.
2020-04-14 10:51:48 -07:00
Conner Fromknecht ec1b8d874d htlcswitch/link: add pending commit ticker for stall detection
This commit adds a PendingCommitTicker to the link config, which allows
us to control how quickly we fail the link if the commitment dance
stalls. Now that the mailbox has the ability to cancel packets, when the
link fails it will reset the mailbox packets on exit, forcing a
reevaluation of the HTLCs against their mailbox expiries.
2020-04-14 10:51:30 -07:00
Conner Fromknecht 4756c00474 Merge pull request #4188 from cfromknecht/verrpc-typo-fix
lnrpc/verrpc: correct mispelling of compilation
2020-04-14 10:51:11 -07:00
Conner Fromknecht a8977651cc htlcswitch/linkfailure: use whitelist for ShouldSendToPeer 2020-04-14 10:51:06 -07:00
Conner Fromknecht 6fca22be2b htlcswitch/link: use return instead of break out
There is no clean up logic after the loop, done purely to improve
clarity.
2020-04-14 10:50:45 -07:00
Conner Fromknecht 16ad0274c9 htlcswitch/mailbox: fail on duplicate adds 2020-04-14 10:50:25 -07:00
Conner Fromknecht e7ece11c29 htlcswitch/mailbox: fail htlcs when delayed for 1 minute
Now that packet failure is handled by the mailbox, we can now enforce
a delivery deadline and fail the packet if it the deadilne is exceeded.
This gives senders quicker feedback about tried routes, and allows them
to try alternative paths to the destination in the meantime.
2020-04-14 10:50:07 -07:00
Conner Fromknecht 1aa2dde4a4 htlcswithc/mailbox: prioritize settles/fails over adds
This commit splits the packet courier internally into two distinct
queues, one for adds and one for settles+fails. This allows us to
prioritize HTLCs that will clear the commitment transaction and make
space for adds. Previously this responsibility was handled by the
overflow queue.
2020-04-14 10:49:48 -07:00
Conner Fromknecht 37dca27a3d htlcswitch: thread clock from switch to mailbox 2020-04-14 10:49:26 -07:00
Conner Fromknecht 63f3d0b012 htlcswitch/mailbox: advance packet head after delivery
This commit delays the advancement of the pktHead until after the
message has been delivered. This is a prepatory step, as in the future
we may fail to deliver the packet due to a deadline expiring.
2020-04-14 10:48:59 -07:00
Conner Fromknecht 564534c829 htlcswitch: move packet failure to mailbox
This commit moves the current logic for sending failures out of the link
and into the mailbox in preparation for our failing delayed htlcs. We do
so because the mailbox may need to fail packets while the link is
offline, and needs to be able to complete the task without member
methods on the link.
2020-04-14 10:48:40 -07:00
Conner Fromknecht 12bbf28e65 htlcswitch: make handleBatchFwdErrors a pure function 2020-04-14 10:48:23 -07:00
Conner Fromknecht f3051efeb3 htlcswitch/mailbox: block until mailbox shutdown
Fixes a bug where Stop() wouldn't actually wait for the mailbox to exit.
2020-04-14 10:48:06 -07:00
Conner Fromknecht 5b38ed0b3e htlcswitch/link: correct link log statement 2020-04-14 10:47:47 -07:00
Conner Fromknecht d4823161d8 lnrpc/verrpc: correct mispelling of compilation 2020-04-13 23:45:02 -07:00
Conner Fromknecht d6fa2f9092 peer: filter channels loaded into switch via whitelist
This is less brittle than blacklisting states since it may not be clear
that new states needs to be added. Now that HasChanStatus is fixed for
ChanStatusDefault, we can safely implement this.
2020-04-13 15:19:59 -07:00
Conner Fromknecht f93a8ab7d0 cmd/lncli: add version command that reads verrpc.GetVersion 2020-04-10 16:39:31 -07:00
Conner Fromknecht 91cd7e633a lnrpc+rpcserver: expose git commit hash in getinfo 2020-04-10 16:39:31 -07:00
Conner Fromknecht 5c04038c18 bulid: only return semantic version from Version()
The version field in getinfo is kept the same for backwards
compatibility.
2020-04-10 16:39:23 -07:00
Conner Fromknecht a25269c4d3 lnrpc/verrpc: add Versioner RPC server 2020-04-10 16:39:23 -07:00
Conner Fromknecht d66f15d01f make+build: compile go version into binary 2020-04-10 16:39:23 -07:00
Conner Fromknecht 07420835d0 make+build: compile build tags into binary 2020-04-10 16:39:23 -07:00
Conner Fromknecht 75a1a1fbab make+build: compile SHA1 commit hash into binary 2020-04-10 16:39:22 -07:00
Conner Fromknecht b68764f86c build/version: check AppPreRelease semantics in init()
We'll do the validation during construction of the runtime so that we
can safely use the AppPreRelease field externally without needing to
normalize it.
2020-04-10 16:39:22 -07:00
Conner Fromknecht 640aadb61a build/version: expose AppMajor, AppMinor, AppPatch, etc. 2020-04-10 16:39:22 -07:00
Conner Fromknecht 06bd645e5d build/version: fix incomplete semanticAlphabet godoc 2020-04-10 16:39:22 -07:00
Conner Fromknecht 93089aaaf8 channeldb/channel: don't print ChanStatusDefault when it's not
This commit removes ChanStatusDefault from the list of
orderedChanStatusFlags since it is not flag. As with the prior commit,
the logic around these flags assumes everything in the list is a flag,
but ChanStatusDefault is not.

It turns out we properly special case that if the channel is in
ChanStatusDefault that we only return ChanStatusDefault. However, if any
of the bits are set we would always report ChanStatusDefault since
status&0 == 0. This fixed simply by removing ChanStatusDefault from the
list since we only need the list to express non-default status flags.
2020-04-10 16:11:44 -07:00
Conner Fromknecht f71cc951fd channeldb/channel: fix HasChanStatus for ChanStatusDefault
This commit resovles a lingering issue w/in the codebase wrt how the
ChannelStatus flags are defined. Currently ChannelStatus is improperly
used to define a bit field and the individual flags themselves. As a
result, HasChanStatus accepts queries on particular status (combinations
of flags) and individual flags themselves.

This is an issue because the way HasChanStatus computes whether the
channel has a particular status assumes the provided inputs are all
flags (or at least combinations of flags).

However, ChanStatusDefault is simply the absence of any other flag.
Hence, HasChanStatus will always return true when querying for
ChanStatusDefault because status&0 == 0 is always true.

Longer term we should should consider splitting these definitions into
flags and particular states, and change the way construct or operate on
them, but for now I've just special-cased this one value. Fortunately,
we don't query HasChannelStatus w/ ChanStatusDefault anywhere in the
codebase so we dodge a bullet here, but it'd be nice to have some
greater assurances moving forward.
2020-04-10 16:05:12 -07:00
Conner Fromknecht c1b9b272cd input/size: assert witness size constants
This commit introduces a new test case that asserts all of the witness
size constants currently in the codebase. We also reintroduce the
AcceptedHtlcSuccessWitnessSize and OfferedHtlcTimeoutWitnessSize
constants that were recently removed for the sake of completeness.

In asserting the witnes sizes, there were three uncovered discrepancies:
 * OfferedHtlcSuccessWitnessSize overestimated by about 30% because it
   included an extra signature in the calculation.

 * ToLocalPenaltyWitnessSize was underestimated by one byte, because it
   was missing the length byte for the OP_TRUE. This has implications
   the watchtower protocol since the client and server are assumed to
   share the same weight estimates used for signing. This commit keeps
   the current behavior, with the intention of rolling out negotiation
   for which weight estimate to use for a given session.

 * AcceptedHtlcScriptSize was underestimated by one byte because it was
   missing a length byte for the value 32 pushed on the stack when
   asserting the preimage's length. This affects all AcceptedHtlc*
   witness sizes.
2020-04-10 15:34:27 -07:00
Conner Fromknecht f2b6e2af04 input: pass input.Signature to multisig spend
Modifies SpendMultiSig to accept input.Signature, so that we can
ultimately assert the size of multisig witnesses.
2020-04-10 14:27:35 -07:00
Conner Fromknecht 0f94b8dc62 multi: return input.Signature from SignOutputRaw 2020-04-10 14:27:35 -07:00
Conner Fromknecht 37dffb225a input: introduce Signature iface
This commit introduces the Signature interface which will be used by our
witness construction methods instead of passing in raw byte slices. This
will be used later to inject various kinds of mock signatures, e.g.
73-byte signatures for simulating worst-case witness weight.
2020-04-09 12:49:11 -07:00
Conner Fromknecht 2b2c8b5a10 lnwallet/interface_test: wait for bitcoind startup
Flakes locally for me on darwin.
2020-04-09 12:49:07 -07:00
Conner Fromknecht 2ccec4bc5c Merge pull request #4152 from cfromknecht/lncli-invoices-category
cmd/lncli: move invoice-related cmds to Invoices category
2020-04-07 15:48:38 -07:00
Conner Fromknecht b8da7e54fb Merge pull request #4145 from cfromknecht/remove-overflow-queue
htlcswitch: remove overflow queue
2020-04-07 14:33:30 -07:00
Conner Fromknecht f50649d21b htlcswitch/link: remove overflow queue
This commit removes the overflowQueue from the link. We do so in order
to promote better UX for senders, so that HTLCs are failed faster when
the commitment is full. This gives the sender the opportunity to try
another, more open path, rather than perceive the HTLC as being stuck.

At the same time, we remove the total number of active goroutines in lnd
by a factor of N where N is the number of active channels.
2020-04-07 13:20:36 -07:00
Conner Fromknecht 68d1753dcb htlcswitch/test_utils: send htlcs before waiting for result
This commit is preparation for the test added in the subsequent commit.
We modify makeHoldPayment to return any failures direectly when trying
to add an HTLC to the switch. This lets us know that the HTLC was indeed
sent without failure when the method returns.
2020-04-07 11:56:22 -07:00
Conner Fromknecht 5a057de5c4 htlcswitch/mailbox: remove errors from AckPacket, Start, Stop
A following commits will move/modify callsites of AckPacket, Start, and
Stop, none of which use the return value and ultimately cause the linter
to complain. However, none of these in-memory operations can fail so we
just remove the returned errors altogether.
2020-04-07 11:55:54 -07:00
Conner Fromknecht e86ddf6ae7 htlcswitch/link: remove unused isReProcess argument 2020-04-07 11:55:25 -07:00
Conner Fromknecht 759d7a122f htlcswitch/test_utils: add missing return
This commit corrects a bug in the testing harness that could cause
more than one error to be returned on the error channel.
2020-04-07 11:54:56 -07:00
Conner Fromknecht 310e20f8b7 invoices/invoiceregistry: remove debug spew 2020-04-07 11:54:29 -07:00
Conner Fromknecht 77041c131a htlcswitch/switch_test: add t.Helper() to assertion 2020-04-07 11:54:02 -07:00
Conner Fromknecht 028345daea htlcswithc/link_test: rm unused arg from generateHtlc
Linter started complaining.
2020-04-07 11:53:36 -07:00
Conner Fromknecht 2c3641e915 htlcswitch/link_test: fix preimage assertion
This flakes locally for me on darwin.
2020-04-07 11:53:15 -07:00
Conner Fromknecht 425b2c712f htlcswitch/switch_test: increase checkHtlcEvents timeout
This flakes locally for me on darwin.
2020-04-07 11:52:50 -07:00
Conner Fromknecht 3233388750 cmd/lncli: move invoice-related cmds to Invoices category
The Payments category is getting quite large, so this commit breaks out
the invoice-related commands into their own category.
2020-04-06 14:24:08 -07:00
Conner Fromknecht 4aceaba1be cmd/lncli: move invoice commands to cmd_invoice.go 2020-04-06 14:23:21 -07:00
Conner Fromknecht 978ff82f1f contractcourt/chain_watchter: fix broken log stmts 2020-04-03 15:29:18 -07:00
Conner Fromknecht 3f4dc0decd lnwallet/channel: increase htlc validation strictness
This commit adds an additional santity check that rejects zero-value
HTLCs, preventing them from being added to the channel state even if the
channel config's minhtlc value is zero.
2020-04-02 18:03:06 -07:00
Conner Fromknecht ae41623a91 lntest/itest/lnd_test: wait when calling OpenChannel
In #4130, OpenChannel was changed to assert that the wallet is fully
synced before allowing a channel open. This introduced flakes on travis,
which are resolved here by using a wait predicate when calling
OpenChannel.

Note there is one existing call that was not converted, because it is
interested in the returned error. This call does not have a wait
predicate surrounding it, but this shouldn't cause a flake because other
channels are opened earlier in the test that will have already waited
for the wallet to sync up.
2020-04-02 17:56:00 -07:00
Conner Fromknecht 184939c81a Merge pull request #4138 from Roasbeef/cnct-logging
contractcourt: add additional logging of commitments at play
2020-04-02 17:54:30 -07:00
Conner Fromknecht b0c3072ff7 lnwallet/channel_test: assert commit sorting of commit diff htlcs
This commit adds a test to exercise that HTLC signatures are sent in the
correct order, i.e. they match the sorting of the HTLC outputs on the
commitment after applying BOLT 3's BIP69+CLTV sort.
2020-04-02 17:51:02 -07:00
Conner Fromknecht 3ea3b1d0b5 lnwallet/channel: tie-break HTLCs by cltv when locating
This commit fixes #4118 by properly sorting the HTLC signatures sent
over the wire to match the BOLT3 BIP69+CLTV sorting of the commitment
outputs.

To do so, we expose the slice of cltv deltas for HTLCs on the unsigned
commitment after applying the commitment sorting. This will be used to
locate the proper output index, as the CLTV serves as a tie breaker
between HTLCs that otherwise have the same payment hash and amount.

Note that #3412 fixed the issue partially by ensuring the commitment was
constructed properly (and the second-level prev outpoint's txid was
correct), but failed to address that the HTLC signatures were still sent
out in the incorrect order. With this, we pass the test case introduce
in the next commit.
2020-04-02 17:51:02 -07:00
Conner Fromknecht 294e13eefc lnwallet/commitment: split our/theirBalance comment 2020-04-02 17:51:02 -07:00
Conner Fromknecht 97761833d2 lnwallet/channel: populate htlc indexes from disk commit
We currently write each HTLCs OutputIndex to disk, but we don't use it
when restoring. The restoration is modified to use these directly, since
we will have lost access to the sorting of CLTVs after the initial
signing process.
2020-04-02 17:50:59 -07:00
Conner Fromknecht d1fa33c8eb rpcserver: only block co-op close for frozen chans
This commit fixes a recent issue from #4081 that would prevent a frozen
channel from being force closed via the rpc. We correct this, so that
only the co-op path is inhibited.
2020-04-02 17:40:08 -07:00
Conner Fromknecht 3c371dd633 rpcserver: remove NewLightningChannel usage in CloseChannel 2020-04-02 17:39:47 -07:00
Conner Fromknecht ec784db511 multi: remove returned error from WipeChannel
The linter complains about not checking the return value from
WipeChannel in certain places. Instead of checking we simply remove the
returned error because the in-memory modifications cannot fail.
2020-04-02 17:39:29 -07:00
Conner Fromknecht 9385b8cdc6 channeldb+lnwallet: move ActiveHtlcs calc to OpenChannel 2020-04-02 17:39:10 -07:00
Conner Fromknecht 422928b8a3 lnwallet/channel: remove unused RemoteCommitHeight method 2020-04-02 17:38:54 -07:00
Conner Fromknecht 0b49783650 Merge pull request #4124 from halseth/travis-lint-concurrency
travis+lint+make: limit lint concurrency only on travis
2020-03-31 16:09:50 -07:00
Conner Fromknecht 66d02504f9 rpcserver: align OpenChannel+OpenChannelSync req parsing
This commit consolidates our request parsing for OpenChannel and
OpenChannelSync which removes a good deal of code duplication.
2020-03-31 11:24:13 -07:00
Conner Fromknecht c1f9c56e5b rpcserver: add self-node check in OpenChannelSync 2020-03-31 10:21:29 -07:00
Conner Fromknecht 303d441d4d rpcserver: ensure OpenChannel+OpenChannelSync parse NodePubkey 2020-03-31 10:21:29 -07:00
Conner Fromknecht 1823840ed6 rpcserver: add missing channel limit check to OpenChannelSync 2020-03-31 10:21:29 -07:00
Conner Fromknecht 5660a26b60 rpcserver: add wallet sync check to OpenChannel 2020-03-31 10:21:24 -07:00
Conner Fromknecht 6a55f3c305 Merge pull request #4125 from bhandras/betweenness_centrality
Addressing final comments from beteweenness centrality PR
2020-03-30 14:20:55 -07:00
Conner Fromknecht 8fd5d13c75 Merge pull request #4064 from breez/optimistic-batch-limit
Use batch for historical confirmations filters request.
2020-03-23 13:59:10 -07:00
Conner Fromknecht 4e793497c8 Merge pull request #2669 from cfromknecht/use-netann-in-discovery
netann+discovery+server: consolidate network announcements to netann pkg
2020-03-23 13:38:06 -07:00
Conner Fromknecht 92456d063d discovery: remove unused updateChanPolicies struct 2020-03-19 13:43:57 -07:00
Conner Fromknecht 5c2fc4a2d6 discovery/gossiper: use netann pkg for signing channel updates 2020-03-19 13:43:39 -07:00
Conner Fromknecht b6a0bfcabe Merge pull request #3848 from carlaKC/htlcnotifier-3-addhtlcnotifierrpc
[htlcnotifier 4/4]: lnrpc: Add HTLC Event Subscription
2020-03-17 16:37:52 -07:00
Conner Fromknecht 5147a6d63d netann/channel_update: set timestamp via modifier 2020-03-17 16:25:22 -07:00
Conner Fromknecht f6c194c3cd netann/node_announcement: consolidate signing logic 2020-03-17 16:25:02 -07:00
Conner Fromknecht 089ac647d8 discovery/chan_series: use netann.ChannelUpdateFromEdge helper 2020-03-17 16:24:25 -07:00
Conner Fromknecht 7b0d564692 discovery: move remotePubFromChanInfo to gossiper, remove utils 2020-03-17 16:24:10 -07:00
Conner Fromknecht 6a813e3433 discovery/multi: move CreateChanAnnouncement to netann 2020-03-17 16:23:54 -07:00
Conner Fromknecht d82aacbdc5 discovery/utils: use netann.ChannelUpdateFromEdge 2020-03-17 16:23:37 -07:00
Conner Fromknecht 9d92cfd2b4 netann/channel_update: use generic SignAnnouncement 2020-03-17 16:23:19 -07:00
Conner Fromknecht df44d19936 discovery/multi: move SignAnnouncement to netann 2020-03-17 16:23:01 -07:00
Conner Fromknecht fcecc5cc39 Merge pull request #4066 from guggero/unlock-stdin
lncli: allow unlock with password from stdin
2020-03-10 17:58:55 -07:00
Conner Fromknecht ae815f221f input/size: correct NestedP2WSHSize comment 2020-03-10 11:53:58 -07:00
Conner Fromknecht 7a1013fb9e make+travis: verify compiled protos on travis 2020-03-10 13:03:01 +01:00
Conner Fromknecht 852ab592bb Merge pull request #4034 from cfromknecht/nested-size-fix
input/size: correct NP2WKH and NP2SH input count
2020-03-09 18:24:52 -07:00
Conner Fromknecht 8a5d846f94 Merge pull request #3996 from guggero/lncli-json
lncli+proto: use original name in jsonpb marshaler and remove json_name fields in proto
2020-03-07 11:08:14 -08:00
Conner Fromknecht ecf7d82904 Merge pull request #4055 from cfromknecht/remove-failed-channels
peer: remove unused failedChannels channels map
2020-03-06 16:50:57 -08:00
Conner Fromknecht e4090c3c67 peer: remove unused failedChannels channels map 2020-03-06 15:45:34 -08:00
Conner Fromknecht 089953ea97 Merge pull request #4045 from cfromknecht/list-channels-with
cmd/lncli: add --with flag to list channels
2020-03-06 12:38:34 -08:00
Conner Fromknecht 11532df5f3 cmd/lncli: add --peer flag to list channels
This commit adds a flag to listchannels that filters by remote pubkey.
2020-03-05 20:44:18 -08:00
Conner Fromknecht c2ec4a450d Merge pull request #4040 from cfromknecht/fee-report-sid
lnrpc+rpcserver: expose short chan id on feereport
2020-03-05 20:16:11 -08:00
Conner Fromknecht 5c9b336a61 lnrpc+rpcserver: expose short chan id on feereport
This commit adds each channel's short chan id to the `feereport` rpc.
Without this, it can be tedious to lookup more info about a particular
channel since most rpcs only accept short chan ids and not channel
points. For instance, now one can take a channel id from `feereport` and
look it up directly via `getchaninfo` to examine the policy in more
detail.
2020-03-04 15:37:17 -08:00
Conner Fromknecht 4c2bc7bc79 lnwallet+input: move size_test.go to input pkg 2020-03-04 08:01:37 -08:00
Conner Fromknecht 4c402ab9d4 lnwallet/size_test: refactor and expand unit tests 2020-03-04 08:00:48 -08:00
Conner Fromknecht 6eb7f2800d input/size: correct NP2WKH and NP2SH input count
This commit corrects a bug in TxWeightEstimator that could result in
underestimations for transactions involving NestedP2WPKH and NestedP2WSH
inputs. The scriptSig data push is now accounted for in a proper size
constant, and the input count is now incremented in both. This would
only be detectable in the event that the number of non-nested inputs and
the total number of inputs straddle the discontinuities in the
CompactSize encoding, e.g. 253, 2^16-1, or 2^32-1.
2020-03-04 08:00:33 -08:00
Conner Fromknecht be74d94c48 lnwallet/size_test: add test exercising nested input count bug
This commit modifies the NP2WKH and NP2WSH input tests to ensure the
input count is properly incremented and accounted for in the size
estimate. 253 is chosen because it is the lowest value that, when
serialized, occupies more than one byte on the wire.
2020-03-04 08:00:09 -08:00
Conner Fromknecht 1467cd4dd3 Merge pull request #4035 from elkanatovey/master
fix typo
2020-03-02 07:23:59 -03:00