Commit Graph
100 Commits
Author SHA1 Message Date
Johan T. Halseth 08c2ee05f6 Merge pull request #2107 from vwoo/grpc-ruby-doc-macaroon
gRPC ruby doc updates
2018-10-31 08:26:56 +01:00
Johan T. Halseth e8003af3cd make: ensure make fmt is run with -s flag
Linting will fail if code is not formatted with the -s flag, so make
sure we always use it when formatting.
2018-10-24 19:07:42 -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
Johan T. Halseth 0e683d895b Merge pull request #2074 from Roasbeef/chan-close-summary-fix-short-chan-remote-node
lnwallet: properly set the short chan ID for remote unilateral close …
2018-10-22 18:16:41 -07:00
Johan T. Halseth b9f3c85288 Merge pull request #2024 from bob-333/patch-1
Improve 'updating' instructions
2018-10-22 18:15:42 -07:00
Johan T. Halseth dbf9b4ea4c chainntnfs+queue: move ConcurrentQueue to own package 'queue' 2018-10-18 12:38:10 -07:00
Johan T. Halseth 29acb9f1f8 routing/chainview: new neutrino API 2018-10-16 19:28:29 -07:00
Johan T. Halseth 6db0bc4b05 chainntnfs/neutrino_debug: new neutrino API 2018-10-16 19:27:07 -07:00
Johan T. Halseth e0fd163096 chainntnfs/neutrino: new neutrino API 2018-10-16 19:26:41 -07:00
Johan T. Halseth 146875ba65 lnwallet/btcwallet: remove filter check
GetBestBlock will now return only blocks where the filter header is synced.
2018-10-16 19:24:22 -07:00
Johan T. Halseth 7ad1f9f7d7 dep: update neutrino and btcwallet deps 2018-10-16 19:24:20 -07:00
Johan T. Halseth d8863bea8c routing/chainview: demote logging of new utxos for filter to Trace
It was previously Debug, which would spam the logs at startup, and not
provide very useful (human-readable) information.
2018-10-10 15:00:50 +02:00
Johan T. Halseth b00e43eec1 Merge pull request #2028 from halseth/travis-race-env
travis: correctly set RACE=TRUE in build matrix
2018-10-10 13:22:50 +02:00
Johan T. Halseth 2c62f3e1f6 travis: correctly set RACE=TRUE in build matrix 2018-10-10 11:03:24 +02: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
Johan T. Halseth 54a608d09d htlcswitch+discovery mock: adhere to new lnpeer interface 2018-09-28 09:05:18 +02:00
Johan T. Halseth a433e70575 fundingmanager test: satisfy new interfaces 2018-09-28 09:05:01 +02:00
Johan T. Halseth b712b861f8 peer: make AddNewChannel take OpenChannel
This commit makes the AddNewChannel expect a OpenChannel instead of a
LightningChannel struct. This moves the responsibility for starting the
LightningChannel from the fundingmanager to the peer, and we can defer
the channel restoration until we know that the channel is not already
active.
2018-09-28 08:59:27 +02:00
Johan T. Halseth addb4aed89 funding+server: make FindChannel return OpenChannel instead of LightningChannel 2018-09-28 08:59:27 +02:00
Johan T. Halseth 240318befe peer: return error on newChanReq
Previously the errors weren't returned back to the sender of the new
channel, making it impossible to tell whether it suceeded or not.
2018-09-28 08:59:26 +02:00
Johan T. Halseth 835617b576 Merge pull request #1799 from tailnode/fix-markdown-issue
docs:fix markdown issues in docker/README.md
2018-09-26 10:02:08 +02:00
Johan T. Halseth 0a5f982280 utxonursery: pass broadcastHeight to registerPreschoolConf
In this commit IncubateOutputs are given an extra parameter
broadcastHeight, which is passed from the server and used when called
registerPresschoolConf.

Earlier the utxonursery used the bestHeight as height hint in this case,
which would be wrong in the cases where we got outputs for incubation
which was confirmed below the best height.
2018-09-20 13:16:39 +02:00
Johan T. Halseth 3a67fe2552 contractcourt+server: make IncubateOutputs take broadcastHeight 2018-09-20 12:54:48 +02:00
Johan T. Halseth 6d0deed885 utxonursery test: run tests in parallel 2018-09-20 12:54:48 +02:00
Johan T. Halseth 9a3e19b77f Merge pull request #1916 from guggero/crash-on-listchaintxns
rpcserver: handle unconfirmed TX properly when listing all transactions
2018-09-17 20:05:26 +02:00
Johan T. Halseth 598904fbb9 lnd_test: restart nodes twice to trigger pruning logic 2018-09-11 10:25:48 +02:00
Johan T. Halseth a926665358 lnd_test: make sure we stay disconnected using WaitInvariant in testGarbageCollectLinkNodes 2018-09-11 10:25:48 +02:00
Johan T. Halseth d742529bb2 rpcserver: set AmtPaidMsat when creating RPC invoice 2018-09-07 14:13:48 +02:00
Johan T. Halseth 90a9f5882a lnrpc: add field amt_paid_msat to Invoice 2018-09-07 14:13:48 +02:00
Johan T. Halseth baee07ef48 Merge pull request #1846 from roeierez/invoice_amt_paid
rpcserver: amount paid should be in satoshis as other fields used for amount
2018-09-05 12:58:59 +02:00
Johan T. Halseth 0d4df54118 autopilot/agent: signal balanceUpdates on own channel 2018-09-04 10:18:15 +02:00
Johan T. Halseth a9a9c9aeb4 autopilot/agent: signal chanPendingOpenUpdates on own channel 2018-09-04 10:17:59 +02:00
Johan T. Halseth 186e6d4da4 autopilot/agent: signal chanOpenFailureUpdates on own channel
We do this to avoid a huge amount of goroutines piling up when autopilot
is trying to open many channels, as they will all block trying to send
the update on the stateUpdates channel. Now we instead send them on a
buffered channel, similar to what is done with the nodeUpdates.
2018-09-04 10:17:33 +02:00
Johan T. Halseth 4a88c61a90 autopilot/agent: signal nodeUpdates on own channel
We do this to avoid a huge amount of goroutines piling up on initial
graph sync, as they will all block trying to send the node update on the
stateUpdates channel. Now we instead make a new buffered channel
nodeUpdates, and just return immediately if there is already a signal in
the channel waiting to be processed.
2018-09-04 10:17:09 +02:00
Johan T. Halseth 3e992f094d autopilot/agent: move signal processing out of select 2018-09-04 10:06:15 +02:00
Johan T. Halseth f82fd5fe86 chainntnfs/bitcoind: fallback to scan manually only in case of err != nil 2018-08-24 14:46:20 +02:00
Johan T. Halseth 01d8953737 chainntnfs/btcd: fallback to scan manually only in case of err != nil 2018-08-24 14:46:20 +02:00
Johan T. Halseth 31dc387e0f chainntnfs/btcd+bitcoind tests: use common TxConfStatus 2018-08-24 14:46:20 +02:00
Johan T. Halseth 79b2ee7da5 chainntnfs/btcd+bitcoind: use common TxConfStatus 2018-08-24 14:46:20 +02:00
Johan T. Halseth b552984fcd chainntnfs: define common TxConfStatus type 2018-08-24 14:46:20 +02:00
Johan T. Halseth 89c33731fe chainntnfs/bitcoind: remove unnecessary check for tx==nil 2018-08-24 14:46:20 +02:00
Johan T. Halseth 4a60887974 chainntnfs/btcd: remove unnecessary check for tx==nil 2018-08-24 14:46:19 +02:00
Johan T. Halseth a91466e9fa chainntnfs/bitcoind tests: check found mempool case 2018-08-24 13:51:54 +02:00
Johan T. Halseth cb3ec07685 chainntnfs/test_util: set 10ms trickleInterval for miner 2018-08-24 13:50:47 +02:00
Johan T. Halseth 8344b05c38 contractcourt/chanarb test: expand TestChannelArbitratorCommitFailure to coop and local force close 2018-08-23 10:04:43 +02:00
Johan T. Halseth 4933120d38 contractcourt/channel arbitrator: add coopCloseTrigger on startup for pendingClose channel 2018-08-23 10:04:43 +02:00
Johan T. Halseth e9066c2d34 peer: print warning if selfPolicy not found 2018-08-23 07:50:18 +02:00
Johan T. Halseth 030eca2347 lnd_test: test payment failing because < min_htlc 2018-08-23 07:50:18 +02:00
Johan T. Halseth 19e3a194fa peer+server: make fetchLastChanUpdate _always_ fetch our own update
This commit fixes a bug that would cause us to fetch our peer's
ChannelUpdate in some cases, where we really wanted to fetch our own.

The reason this happened was that we passed the peer's pubkey to
fetchLastChanUpdate, making us match on their policy. This would lead to
ChannelUpdates being sent during routing which would have no effect on
the attempted path.

We fix this by always use our own pubkey in fetchLastChanUpdate, and
also uses the common methods within the server to be able to extract the
update even when only one policy is known.
2018-08-23 07:50:18 +02:00
Johan T. Halseth de5e9e139c server: make extractChannelUpdate extract from set of potential policies 2018-08-23 07:50:17 +02:00
Johan T. Halseth 229fd88289 peer: use custom MinHTLC value at initial link add
This commit fixes a bug within the peer, where we would always use the
default forwarding policy when adding new links to the switch. Mostly
this wasn't a problem, as we most often are using default values for new
channels, but the min_htlc value is a value that is set by the remote,
not us.

If the remote specified a custom min_htlc during channel creation, we
would still use our DefaultMinHtlc value when first adding the link,
making us try to forward HTLCs that would be rejected by the remote.

We fix this by getting the required min_htlc value from the channel
state machine, and setting this for the link's forwarding policy.

Note that on restarts we will query the database for our latest
ChannelEdgePolicy, and use that to craft the forwardingPolicy. This
means that the value will be set correctly if the policy is found in the
database.
2018-08-23 07:50:17 +02:00
Johan T. Halseth f4f7b64b2d lnwallet/channel: add FwdMinHtlc(), returning MinHTLC from localChanCfg 2018-08-23 07:50:17 +02:00
Johan T. Halseth 7eee09c454 lnd_test: check ChannelUpdate for custom min_htlc 2018-08-23 07:50:17 +02:00
Johan T. Halseth e069dd7f04 fundingmanager test: test that custom MinHTLC is in ChannelUpdate 2018-08-23 07:50:17 +02:00
Johan T. Halseth e174fbd759 fundingmanager: use value the _remote_ require us to use in ChannelUpdate
This commit fixes a bug that would make us advertise the remote's
min_htlc value in our channel update.

The min_htlc value is set by a node Alice to limit its exposure to small
HTLCs, and the channel counter party should not forward HTLCs of value
smaller than this to Alice. This means that the value a node Bob should
advertise in its ChannelUpdate, is the min_htlc value the counter party
require all HTLCs to be above.

Instead of populating the ChannelUpdate with the MinHtlc value found in
the remote constraints, we now use the value from the local constraints.
2018-08-23 07:50:17 +02:00
Johan T. Halseth 0c65719613 fundingmgr: check quit channel when sending update
Avoids deadlock during failing fundingmanager tests.
2018-08-23 07:50:16 +02:00
Johan T. Halseth 4c15353116 lnd test: make waitForChannelUpdate take array of updates 2018-08-23 07:50:16 +02:00
Johan T. Halseth fd7b1c2d5e lntest/lnd test: make OpenChannel take channel param struct
Also add option for setting min_htlc value on channel creation.
2018-08-23 07:50:16 +02:00
Johan T. Halseth 6a6d3ff557 funding tests: account for returned err channel 2018-08-23 07:40:41 +02:00
Johan T. Halseth 67d36eb79d funding: make SendAnnouncement return error chan instead of error 2018-08-23 07:40:41 +02:00
Johan T. Halseth 4b04e1afd1 routing: return ErrRejected if found in reject cache
We make sure to return an error other than ErrIgnored, as ErrIgnored is
expected to only be returned for updates where we already have the
necessary information in the database.

In case of a channel ID found in the rejectCache, there was a
possibility that we had rejected an invalid update for this channel
earlier, and when attempting to add the current update we wouldn't
distinguish the failure to add from an outdated/ignored update.
2018-08-23 07:40:40 +02:00
Johan T. Halseth c56082006f discovery/gossiper: formatting 2018-08-23 07:40:40 +02:00
Johan T. Halseth 0bc415c683 discovery/gossiper: don't return on errChan for ChannelUpdate not yet processed
Previosuly we would immediately return nil on the error channel for
premature ChannelUpdates, which would break the expection that a a
returned non-error meant the update was successfully added to the
database. This meant that the caller would believe the update was added
to the database, while it is actually still in volatile memory and can
be lost during restarts.

This change makes us handle premature ChannelUpdates as we handle other
premature announcements within the gossiper, by deferring sending on the
error channel until we have reprocessed the update.
2018-08-23 07:40:40 +02:00
Johan T. Halseth 7bbb2bbc80 discovery/gossiper: return on errChan on ValidationBarrier error 2018-08-23 07:40:40 +02:00
Johan T. Halseth c8ce2aa2d2 discovery/gossiper: reaturn early of no premature to process 2018-08-23 07:40:39 +02:00
Johan T. Halseth d0e8aeece1 discovery/gossiper: return on errChan in case of ChanAnn/Upd on wrong chain
Previously we wouldn't return anything in the case where the
announcement were meant for a chain we didn't recognize. After this
change we should return an error on the error channel in all flows
within the gossiper.
2018-08-23 07:40:39 +02:00
Johan T. Halseth 54f67f72b1 discovery/gossiper: define ErrGossiperShuttingDown 2018-08-23 07:40:39 +02:00
Johan T. Halseth 18e680f192 router: simplify edge outdated logic, return ErrOutdated if old. 2018-08-23 07:40:39 +02:00
Johan T. Halseth bb71856204 contractcourt/channel_arbitrator test: add TestChannelArbitratorEmptyResolutions 2018-08-23 00:03:22 +02:00
Johan T. Halseth ed5db96e05 contractcourt/channel_arbittrator: ignore noResolutions error on startup 2018-08-23 00:03:22 +02:00
Johan T. Halseth b031d87daf contractcourt/briefcase: test FetchContractResolutions error when no resolutions logged 2018-08-23 00:03:22 +02:00
Johan T. Halseth 53286b8cee contractcourt test: add TestChannelArbitratorCommitFailure 2018-08-23 00:03:22 +02:00
Johan T. Halseth f2a033e965 contractcourt/channel_arbitrator: override trigger on startup if IsClosing
At ChannelArbitrator startup we now check the database close status of
the channel. If we detect that the channel is closed, but our state
machine hasn't advanced to reflect that (possibly because of a shutdown
before the state transition was finished), we manually trigger the state
transition to recover.
2018-08-23 00:03:22 +02:00
Johan T. Halseth 1758ad829f contractcourt/[chain|channel]_arbitrator: define IsPendingClose 2018-08-23 00:03:22 +02:00
Johan T. Halseth 6b24ca0387 contractcourt test: add TestChannelArbitratorPeristence 2018-08-23 00:03:21 +02:00
Johan T. Halseth 75df58c68b contractcourt: move responsibility for closing force closes to chanArb
This commit moves the responsibility for closing local and remote force
closes in the database from the chain watcher to the channel arbitrator.

We do this because we previously would close the channel in the
database, before sending the event to the channel arbitrator. This could
lead to a situation where the channel was marked closed, but the channel
arbitrator didn't receive the event before shutdown. As we don't listen
for chain events for channels that are closed, those channels would be
stuck in the pending close state forever, as the channel arbitrator
state machine wouldn't progress.

We fix this by letting the ChannelArbitrator close the channel in the
database. After the contract resolutions are logged (in the state
callback before transitioning to StateContractClosed) we mark the
channel closed in the database. This way we make sure that it is marked
closed only if the resolutions have been successfully persisted.
2018-08-23 00:03:21 +02:00
Johan T. Halseth c11e0940c2 contractcourt/channel_arbitrator test: test new coop close actions 2018-08-23 00:03:21 +02:00
Johan T. Halseth ad1d78884a contractcourt: move responsibility for closing coop close channel to chanArb 2018-08-23 00:03:21 +02:00
Johan T. Halseth 3549f2bc17 contractcourt/[channel|chain]_arbitrator: define MarkChannelClosed 2018-08-22 23:51:04 +02:00
Johan T. Halseth 740db4716f contractcourt/channel_arbitrator test: test state transitions 2018-08-22 23:51:04 +02:00
Johan T. Halseth 862c7ae223 contractcourt/channel_arbitrator test: check both respChan and errChan
// Both are sent on, so in some cases we would read from errChan first,
making the test fail.
2018-08-22 23:51:04 +02:00
Johan T. Halseth 06c683d48d contractcourt/channel_arbitrator: move next state commit out of stateStep 2018-08-22 23:51:04 +02:00
Johan T. Halseth 6df302d7f5 contractcourt/channel_arbitrator: remove state callback
This commit removes the state callback, and instead logs the contract
resolutions directly after receiving the unilateral close event. The
resolutions won't change so there's not really necessary to wait to log
them, and this greatly simplifies the code.
2018-08-22 23:51:04 +02:00
Johan T. Halseth 245dae0071 contractcourt/channel_arbitrator: properly commit to next state 2018-08-22 23:51:04 +02:00
Johan T. Halseth 7b1ac0a979 lnd test: check inactive channel disables in testSendUpdateDisableChannel 2018-08-17 23:24:14 +02:00
Johan T. Halseth 52941cec53 lntest: add SuspendNode 2018-08-17 23:24:13 +02:00
Johan T. Halseth 53d319ad10 lnd_test: use shutdownAndAssert 2018-08-17 23:24:13 +02:00
Johan T. Halseth 4581aa313c server: handle case where both policies are not present in fetchLastChanUpdateByOutPoint 2018-08-17 23:24:13 +02:00
Johan T. Halseth 5deffd228c peer: call disableChannel with disabled=false after loading channels
This to ensure now active channel is available in the router, for path
finding, as it might have been disabled if the peer has been offline a
while.
2018-08-17 23:24:13 +02:00
Johan T. Halseth e9cc7492a9 server: add goroutine watchChannelStatus
This commit adds a goroutine watchChannelStatus to the server, which
will query the switch for the status of all open channels every
InactiveChanTimeout / 4. If a channel's status has remained unchanged
during the last InactiveChanTimeout it'll send out a ChannelUpdate
setting the disabled bit accordingly.
2018-08-17 23:24:13 +02:00
Johan T. Halseth 9e44b38eee config: define InactiveChanTimeout 2018-08-17 23:24:13 +02:00
Johan T. Halseth b5bfdd72b5 server+peer: rename disableChannel->announceChanStatus
Now takes a boolean whether to disable/activate, and keeps track of the
last update sent to avoid sending duplicates.
2018-08-17 23:24:12 +02:00
Johan T. Halseth 887722f38f htlcswitch/switch: add method HasActiveLink 2018-08-17 23:24:12 +02:00
Johan T. Halseth 940d0735f8 lnd_test: use dave to listen for ChannelUpdates in testSendUpdateDisableChannel
This commit changes the test testSendUpdateDisableChannel to use Dave to
listen for channel updates, as was originally intended.

Since a ChannelUpdate won't propagate in the network if the channel is
already closed (if the closing transaction has been mined), we change
the closing procedure to initiate the closing process, wait for the
ChannelUpdates, then finally mining the closing transaction. This avoids
a propagation race between the mined block and the ChannelUpdate.
2018-08-17 23:24:12 +02:00
Johan T. Halseth 304577f617 server: make sure timestamp always increases when creating new ChannelUpdate 2018-08-17 23:24:12 +02:00
Johan T. Halseth 8826db32e8 server: let gossiper hand policy update to router
ProcessLocalAnnouncement will attempt to call UpdateEdge with the new
policy. If we call it manually before handing it to the gossiper, that
call will fail with "Outdated" and the announcement won't propagate.
2018-08-17 23:24:12 +02:00
Johan T. Halseth a57a972b26 dep: remove gographviz dependency 2018-08-17 09:38:50 +02:00
Johan T. Halseth c39c2d7c37 lncli: remove --render option from describegraph 2018-08-17 09:36:56 +02:00
Johan T. Halseth 2a3b52535e autopilot: check if already connected before returning error
This commit fixes a small bug that could cause us to disconnect an
already connected peer if no addresses where provided to the ConnectPeer
method. Now we instead first check if we are already connected, and
return early.
2018-08-17 09:26:54 +02:00