Commit Graph
100 Commits
Author SHA1 Message Date
Johan T. Halseth e28c5a1e89 Merge pull request #3762 from halseth/mobile-subserver-goimports
mobile: run goimports on generated files
2019-12-04 11:28:07 +01:00
Johan T. Halseth a6ef03c777 Merge pull request #3743 from cfromknecht/in-order-sids
lnwire: assert sorted short channel ids
2019-12-04 08:56:02 +01:00
Johan T. Halseth 4d2813900e Merge pull request #3776 from matheusdtech/random-ports
lntest: Use TCP ports not based in nodeID
2019-12-04 08:46:37 +01:00
Johan T. Halseth e8e5fd7abc mobile: run goimports on generated files
Subservers might depend on each other (notably walletrpc depends on
signrpc) so running goimports ensures they properly import each other.
2019-11-26 14:57:17 +01:00
Johan T. Halseth ddbd7a68ac lntest/node: add numActiveNodesMtx
Fixes a slight race condition that could happen since Alice and Bob are
created in different goroutines, leading to using the same listening
ports.
2019-11-21 13:57:30 +01:00
Johan T. Halseth 08803e2e41 lnd_test: fix race condition on simultanous force closes
This fixes an issue that would lead to a flake during intergration
tests. Carol would start up with a outdated state and attempt to force
close the channel. At the same time she would connect to Dave,
triggering the dataloss protection. Dave would respond by force closing
the channel, and Dave transaction would in some cases have a higher fee,
resulting Carol's tx being replaced.

We fix this by suspending Dave until Carol's close tx is mined.
2019-11-21 13:43:29 +01:00
Johan T. Halseth 2754f5dea0 mobile: 80 char limit readme 2019-11-21 12:35:52 +01:00
Johan T. Halseth 27abe4a301 mobile: halseth/falafel -> lightninglabs/falafel 2019-11-21 12:34:38 +01:00
Johan T. Halseth 1b543b919e mobile: add comments to build script 2019-11-21 12:33:48 +01:00
Johan T. Halseth b1e6d9c5cf Merge pull request #1152 from guggero/macaroon-integrationtest
itest: add tests for macaroon authentication
2019-11-21 09:22:28 +01:00
Johan T. Halseth 8755a35860 Merge pull request #3667 from cfromknecht/log-fixes
fundingmanager+routing log touch ups
2019-11-20 15:57:05 +01:00
Johan T. Halseth 79051ac63f Merge pull request #2520 from yancyribbens/choose-git-state-during-docker-prod-build
specify a tag, branch or commit during docker prod build
2019-11-19 14:56:09 +01:00
Johan T. Halseth d4d8b03d5b Merge pull request #3705 from joostjager/payment-fail-log
routing+htlcswitch: improve failed payment logging
2019-11-15 10:41:48 +01:00
Johan T. Halseth 840051cc3d Merge pull request #3644 from joostjager/commit-sweep-no-nursery
cnct: commit sweep without nursery
2019-11-15 10:38:57 +01:00
Johan T. Halseth f0048bb662 chainntnfs/txnotifier_test: add TestTxNotifierSpendDuringHistoricalRescan 2019-11-14 15:05:50 +01:00
Johan T. Halseth a8837478f4 mod: update neutrino dep 2019-11-11 10:45:09 +01:00
Johan T. Halseth 3b22540fc1 Merge pull request #2533 from yancyribbens/persistent-lnd-volume-docker-compose
add named volume to lnd service for persisting data accross container…
2019-11-11 09:47:30 +01:00
Johan T. Halseth d50b3a9c81 Merge pull request #3684 from alexbosworth/patch-12
trivial: fix typo
2019-11-07 12:00:35 +01:00
Johan T. Halseth 2947036633 Merge pull request #3664 from joostjager/outgoing-contest-resolver-test
cnct/test: add outgoing contest resolver test
2019-11-07 10:54:45 +01:00
Johan T. Halseth e0744a3983 Merge pull request #3650 from guggero/update-grpc-gateway
proto+lnrpc: update gRPC-REST gateway to v1.8.6
2019-11-01 09:03:48 +01:00
Johan T. Halseth 5a8ecfcc49 autopilot/agent_test: add TestAgentHeuristicUpdateSignal
TestAgentHeuristicUpdateSignal tests that upon notification about a
heuristic update, the agent reconsults the heuristic.
2019-10-31 10:19:50 +01:00
Johan T. Halseth 7524265ab1 autopilot: trigger agent channel open on new scores
This commit adds a new signal to the autopilot agent, meant to signal
when any of the available heuristics has gotten an update.

We currently use this to trigger a new channel opening after the
external scores have been updated.
2019-10-31 10:17:31 +01:00
Johan T. Halseth f0ba4be758 autopilot/manager: fix slice modifications
When appending to a slice, there is no guarantee the slice won't be
modified. So instead of appending to the global slice
availableHeuristics, we create a temporary local one.
2019-10-31 10:17:31 +01:00
Johan T. Halseth df5baa4275 autopilot/agent: trace log reason nodes being skipped 2019-10-31 10:17:31 +01:00
Johan T. Halseth 64e5d06cd1 Merge pull request #2598 from skwp/docker-caching
Add source after installing apk packages to avoid breaking docker cache
2019-10-30 15:47:57 +01:00
Johan T. Halseth 1a0ab538d5 Merge pull request #3332 from carlaKC/chanfitness-trackchanneluptime
Chanfitness: Track peer uptime
2019-10-25 14:29:59 +02:00
Johan T. Halseth 12a1d05127 fundingmanager: make SendToPeer sync
Since the funding flow requires messages to go through, make use of
sync version of SendToPeer. Using the async version we would risk that
the message was dropped and the process would stall (it would properly
continue after a restart though).
2019-10-24 13:08:08 +02:00
Johan T. Halseth 018737a80a Merge pull request #3627 from guggero/witness-timelock-type
input+sweep: log input witness types instead of CSV/CLTV count
2019-10-24 11:08:33 +02:00
Johan T. Halseth fd906475dd Merge pull request #3569 from guggero/chainntfs-addr-reuse
chainntnfs: fix nil pointer on address reuse
2019-10-23 12:45:57 +02:00
Johan T. Halseth 753f30a6ff chainntnfs/neutrino: don't ignore failed filter fetches
Earlier GetCFilter could return a nil-error along with a nil-filter in
cases where we failed to fetch the filter. We would just ignore the
block causing us to miss potential crucial information.

Now that GetCFilter will return an error in cases where the fetch
failed, the filter will never be nil (even for blocks with only coinbase
transactions), and we'll instead return an error.

We also increase the number of retries for the filter from the default 2
to 5.
2019-10-15 11:25:31 +02:00
Johan T. Halseth 610a93e2ff routing/chainview: check GetCFilter error
Since the filter will never be nil in non-error cases now, remove the
nil-check.
2019-10-15 10:31:25 +02:00
Johan T. Halseth 5cbef663e4 go mod: update btcd+neutrino+btcwallet 2019-10-15 10:31:23 +02:00
Johan T. Halseth d15209abf2 make: default backend variable to btcd
This fixes the logging of used backend in the default (btcd) case.
2019-10-08 15:14:11 +02:00
Johan T. Halseth 1a5e39db88 Merge pull request #3541 from halseth/itest-connection-refused-ignore
lnd_test: give peers more time to successfully attempt connection
2019-10-07 10:23:52 +02:00
Johan T. Halseth a3a04992b4 lnd_test: give peers more time to successfully attempt connection
We might hit a connection refused error in cases where the peer connects
to us exactly as we try to connect to it. We retry the connection within
a wait predicat, as it should be the case that the other peer
establishes the connection, and the two peers actually connects.
2019-10-07 09:46:23 +02:00
Johan T. Halseth 6765b8668a Merge pull request #3574 from wpaulino/max-fee-allocation-fee-floor
htlcswitch: enforce fee floor on max fee allocation
2019-10-04 14:12:02 +02:00
Johan T. Halseth e88c635b7e Merge pull request #3573 from wpaulino/log-conf-ntfn-once
chainntnfs: only log confirmation notification registration once
2019-10-04 13:06:42 +02:00
Johan T. Halseth 989de44a69 Merge pull request #3563 from joostjager/link-test-context
htlcswitch/test: create link test context
2019-10-03 09:45:36 +02:00
Johan T. Halseth 43b02d3035 Merge pull request #3481 from legacycode/fix-dockerfile
Fixed dockerfile by adding version numbers to base containers
2019-10-01 15:02:07 +02:00
Johan T. Halseth f8621fe6d7 Merge pull request #3554 from alrs/stdlib-context
Use stdlib "context" Package
2019-09-30 10:15:34 +02:00
Johan T. Halseth 7fcac54dff Merge pull request #3531 from LightningPeach/fix-tx-subscr
Add BlockHeight param to SubscribeTransactions when tx is confirmed
2019-09-26 09:26:25 +02:00
Johan T. Halseth e5f0b8e793 Merge pull request #3393 from wroscoe/patch-1
fixed 1-line errant docker-compose command in instructions
2019-09-25 15:28:48 +02:00
Johan T. Halseth 97093b4223 lntest/itest: wait for on-chain balance restore
We add a wait predicate to make sure the node's on-chain balance is
restored before continuing the restore test case.

This is needed since the DLP test scenario includes several restarts of
the node, and if the node isn't done scanning for on-chain balance
before the restart happens, it would be unlocked without a recovery
window, causing funds to be left undiscovered.
2019-09-25 14:04:44 +02:00
Johan T. Halseth 2d194c9672 htlcswitch/link: remove chan sync delay
Earlier this delay was needed to increase the likelihood that the DLP
scanario was successfully completed. Since we would risk the connection
being torn down, and the link exit, we could end up with the remote
marking the channel borked, but not finishing the force close.

With the previous set of commits, we should now trigger the force close
before we merk the channel borked, which should ensure we'll resume the
orocess on next restart/connect.
2019-09-25 14:04:44 +02:00
Johan T. Halseth 2a6ad6e634 channeldb+lnwallet: don't pass isRestoredChan to ChanSyncMsg
Since we have access to the internal state of the channel, we can
instead get it directly instead of passing it in as a parameter.
2019-09-25 14:04:44 +02:00
Johan T. Halseth c90b1dd17d chancloser: mark commitment broadcast before publish
We call MarkCommitmentBroadcasted before publishing the closing tx to
ensure we can attempt to republish at startup if something goes wrong.
2019-09-25 14:04:44 +02:00
Johan T. Halseth 2cb80c4449 contractcourt/chain_arbitrator: mark commitment broadcasted before publish
Before publishing the close tx to the network and commit to the
StateCommitmentBroadcasted state, we mark the commitment as broadcasted
and store it to the db. This ensures it will get re-published on startup
if we go down.
2019-09-25 14:04:44 +02:00
Johan T. Halseth 9423fadf56 htlcswitch/link: don't mark channel borked on force close scanarios
Instead of marking the channel Borked in cases where we want to force
close it, we immediately let the peer fail the link. The channel state
will instead be updated by the channel arbitrator, which will transition
to StateBroadcastCommit, marking the channel borked, then marking the
commitment tx broadcasted right before publishing the force close tx. We
do this to avoid the case where we would mark it Borked, but go down
before being able to publish the closing tx.

Storing the force close tx ensures it will be re-published on startup.
2019-09-25 14:04:44 +02:00
Johan T. Halseth 6e361d04cf lnwallet+link: move marking channel states to link
Instead of marking the database state when processing the channel
reestablishment message, we wait for the result of this processing to
arrive in the link, and mark it accordingly in the database here.

We do this move the logic determining whether we should force close the
channel or not, and what state to mark it in the DB, to the same place,
as these need to be consistent.
2019-09-25 14:04:43 +02:00
Johan T. Halseth f40f4620f7 lnwallet/channel: make ErrCommitSyncLocalDataLoss type
This commit converts the ErrCommitSyncLocalDataLoss error into a struct,
that also holds the received last unrevoked commit point from the remote
party.
2019-09-25 14:04:43 +02:00
Johan T. Halseth d75feeb953 contractcourt/chain_arbitrator_test: add TestChainArbitratorRepublishCommitment
TestChainArbitratorRepulishCommitment testst that the chain arbitrator
will republish closing transactions for channels marked
CommitementBroadcast in the database at startup.
2019-09-25 14:04:43 +02:00
Johan T. Halseth 07a42971bf lnwallet/test_utils: make CreateTestChannel return random funding op
Previously it would always be the same, resulting in multiple calls to
the method not being usabel to create more than one set of channels.
2019-09-25 14:04:43 +02:00
Johan T. Halseth 425afd28ea contractcourt/chain_arbitrator: republish closeTx for open channels 2019-09-25 14:04:43 +02:00
Johan T. Halseth ac0e9b6016 channeldb/channel: add BroadcastedCommitment 2019-09-25 14:04:43 +02:00
Johan T. Halseth 02b2787e44 multi: make MarkCommitmentBroadcasted take closeTx 2019-09-25 14:04:43 +02:00
Johan T. Halseth a810092e53 channeldb/channel: make putChanStatus take optional extra closures 2019-09-25 14:04:43 +02:00
Johan T. Halseth 1974bfa4cf peer: send channel reestablish message for borked channels
When loading active channels for a connected peer, we gather channel
sync messages for all borked channels, and send them to the peer. This
should help a peer realize that the state is irreconcible, as we have
already realized.
2019-09-25 14:04:42 +02:00
Johan T. Halseth eb1b84c0b4 channeldb+lnwallet: make ChanSyncMsg method on OpenChannel 2019-09-25 14:04:42 +02:00
Johan T. Halseth 0122dda88a channeldb/channel: remove unused FullSync method
The exported FullSync method is only used by test code, so we remove it
and instead use SyncPending.
2019-09-25 14:04:42 +02:00
Johan T. Halseth b7e1bb0bf0 Merge pull request #3510 from halseth/lnwallet-rbf
Handle RBF signaling publication failures in wallet
2019-09-25 14:04:03 +02:00
Johan T. Halseth bc8308f42f Merge pull request #3538 from fridokus/master
trivial: fix typo in config.go
2019-09-25 08:17:21 +02:00
Johan T. Halseth 2e9452916e lnwallet/interface_test: add RBF test cases to testPublishTransaction
Checks that we get ErrDoubleSpend as expected when publishing a
conflicting mempool transaction with the same fee as the existing one,
and that we can publish a replacement with a higher fee successfully.
2019-09-25 08:04:04 +02:00
Johan T. Halseth 61e1b48f57 lnwallet/btcwallet: check publication error types, handle replacement
error

Since btcwallet will return typed errors now, we can simplify the
matching logic in order to return ErrDoubleSpend.

In case a transaction cannot be published since it did not satisfy the
requirements for a valid replacement, return ErrDoubleSpend to indicate
it was not propagated.
2019-09-25 08:04:04 +02:00
Johan T. Halseth 96ebce6842 go mod: update btcwallet dependency
We update to a new version of btcwallet where specific errors
(ErrDoubleSpend and ErrReplacement) will be returned from
PublishTransaction.
2019-09-25 08:03:21 +02:00
Johan T. Halseth 7897b96e6a lnwallet/interface_test: extract local utility functions
In preparation for extending the testPublishTransaction test, shorten it
by moving utility methods out of the local scope.
2019-09-25 08:01:42 +02:00
Johan T. Halseth 9f3fbda71f fundingmanager: remove unnecessary Peer param to sendFundingLocked 2019-09-24 21:24:40 +02:00
Johan T. Halseth 5b8e97da29 funding: update comment aboute offline peers
Since fundingLocked now are being sent reliably, the only message left
to be sent reliably is the node announcement for private channels.
2019-09-24 21:24:40 +02:00
Johan T. Halseth 9ff6de5be1 funding: add TODO for consistency check 2019-09-24 21:24:39 +02:00
Johan T. Halseth bda0e40dad fundingmanager: save markedOpen before marking the channel open
This commit fixes a potential issue within the fundingmanager, where
failing to write the channel opening state could cause the channel being
marked open in the DB, but the opening state not being set. On startup
this would cause the channel state machine to not be able to resume.

We fix this by saving the channel opening state _first_. This works
because saving the opening state is idempotent, and in case a channel is
found pending at startup, it will re-register for confirmation
notifications and re-do the process.
2019-09-24 21:24:39 +02:00
Johan T. Halseth 88f5e06427 fundingmanager: unify handling of pending and non-pending channels at startup
Since the advanceFundingState now can handle pending channels, we'll
call it for both pending and non-pending channels, just making sure that
we re-initialize the channel barriers and re-publish the funding tx fro
pending channels.
2019-09-24 21:24:39 +02:00
Johan T. Halseth 8a61af6a55 fundingmanager: make advanceFundingState handle pending channels
This commit makes advanceFundingState check whether a channel is still
pending before checking the channel opening state. This lets us call it
directly, without checking whether a channel has confirmed first.
2019-09-24 21:24:39 +02:00
Johan T. Halseth 30614d3840 funding tests: increase epoch channel buffer
Since the initiator no longer registers for block epochs, we increase
the buffer on the mocked channel to not block during tests.
2019-09-24 21:24:39 +02:00
Johan T. Halseth 893c6cbc59 fundingmanager: make waitForFundingTimeout sync
This commit makes the waitForFundingTimeout method synchronous, and
return ErrConfirmationTimeout in case the timeout is reached.

We also simplify the internals by using waitForTimout defined earlier.
2019-09-24 21:24:35 +02:00
Johan T. Halseth 47fae26dc4 fundingmanager: define method waitForTimeout
This commit defines a new method waitForTimeout, that will be used to
listen for channels timing out. It handles a subset of what is already
handled by waitForFundingWithTimeout, but we want to break that one up
in smaller parts, and waitForTimeout is the first of these.
2019-09-24 21:24:34 +02:00
Johan T. Halseth ea196f6e8f fundingmanager make waitForFundingConfirmation decrement waitgroup
Since waitForFundingConfirmation is always called in a goroutine, we
make this explicit by requireing the caller to always increment the
waitgroup before calling it.
2019-09-24 21:24:34 +02:00
Johan T. Halseth 76857dbcdc fundingmanager: move handleFundingConfirmation out of waitForFundingWithTimeout
Similarly to what we did in the previous commit, we move the
responsibility of marking the channel open by calling
handleFundingConfirmation out from waitForFundingWithTimeout to the
caller.
2019-09-24 21:24:34 +02:00
Johan T. Halseth 25f6094802 fungingmanager: move handleFundingConfirmation out of waitForfundingConfirmation
This commit moves the handling of a funding confirmation out of
waitForFundingConfirmation, and instead let the caller handle marking
the channel opened.
2019-09-24 21:24:34 +02:00
Johan T. Halseth b51b76b469 fundingmanager: extract opening logic into new method handleFundingConfirmation
This commit moves the opening logic found within
waitForFundingConfirmation into a new method handleFundingConfirmation.
This will make it easier to later break up waitForFundingConfirmation,
and avoid code duplication.
2019-09-24 21:24:34 +02:00
Johan T. Halseth b2a7e42f44 fundingmanager: commit to new states in stateStep
This commit moves the saving of the new channelOpeningState to the
stateStep method.
2019-09-24 21:24:33 +02:00
Johan T. Halseth 49bbf0eb61 fundingmanager: call advanceFundingState in place of handleFundingConfirmation
This commit removes the handleFundingConfirmation method, and instead
hands the newly confirmed channel of to advanceFundingState, which will
take the channel through the rest of the channel opening flow.
2019-09-24 21:24:33 +02:00
Johan T. Halseth e274c2fb7c fundingmanager: call advanceFundingState from handleFundingSigned
Since the advanceFundingSigned now can resume a channel from any state,
we resue the logic in handleFundingSigned instead of manually executing
each step of the funding flow.
2019-09-24 21:24:33 +02:00
Johan T. Halseth cbf1fe6bb1 fundingmanager: define stateStep, make advanceFundingState sync
This commit make the advanceFundingStateMethod synchronous. It will now
query the database for a channel's opening state, and call the method
stateStep until the channel has finished the opening procedure.
2019-09-24 21:24:33 +02:00
Johan T. Halseth 08cb313934 fundingmanager: move startup state check into advanceFundingState method
This commit extracts the funding state check we do at startup into a new
method advanceFundingState. In later commits we will modify this method
to work for all funding state machine flows, not only on restart.
2019-09-24 21:24:33 +02:00
Johan T. Halseth e189f78567 fundingmanager: remove dead code
Pending channels will never have a channel opening state, and hence will
never be pending.
2019-09-24 21:24:32 +02:00
Johan T. Halseth 5d1a7b0e7d funding test: correctly send remote peer on connected chan 2019-09-24 21:24:32 +02:00
Johan T. Halseth 0db9045e11 funding test: mark assert methods t.Helper 2019-09-24 21:24:32 +02:00
Johan T. Halseth e4301d3a8f lnwire: rename ErrorCode -> FundingError
To make it clear that these errors are not part of the spec, rename them
to FundingError.
2019-09-20 10:55:21 +02:00
Johan T. Halseth 33fe09482b lnwire+multi: define Error() for lnwire.Error
To make lnwire.Error actually satisfy the error interface, define the
Error method directly.
2019-09-20 10:55:21 +02:00
Johan T. Halseth 949f6c6cec lnwire: remove ErrorCode encoding/decoding
Never sent on the wire.
2019-09-20 10:55:20 +02:00
Johan T. Halseth ff37b711c6 funding: dont's send ErrorCode on wire
Since the ErrorCodes are not part of the spec, they cannot be read by
other implementations.

Instead of only sending the error code we therefore send the complete
error message. This will have the same effect at the client, as it will
just get the full error instead of the code indicating which error it
is. It will also be compatible with other impls.

Note that the GRPC error codes will change, since we don't set them
anymore.
2019-09-20 10:55:20 +02:00
Johan T. Halseth e4751f1361 Merge pull request #3517 from halseth/channel-point-log
lnwallet/channel: add missing chanpoint to log
2019-09-19 15:14:38 +02:00
Johan T. Halseth c308042ae0 lnwallet/channel: add missing chanpoint to log 2019-09-19 10:40:32 +02:00
Johan T. Halseth ce9f7faff2 contractcourt/channel_arbitrator: handle breach channel at startup
Earlier the channel arbitrator would fail to recognize channels pending
close that were in the breached state. This lead to the state machine
not progressing correctly, and in some cases crashing since we would
attempt to force close an already closed channel.

A test TestChannelArbitratorForceCloseBreachedChannel is added to
exercise one of these scenarios.
2019-09-18 13:05:35 +02:00
Johan T. Halseth 26b7ec1b94 contractcourt/channel_arbitrator: define and react to breachClose
Earlier we would not react to breaches, as these are handled by other
subsystems. Now we advances our state machine in case of breach, such
that we'll gracefully exit, and won't have leftover state in case of a
restart.

A simple test TestChannelArbitratorBreachClose to exercise this behavior
is added.
2019-09-18 13:05:35 +02:00
Johan T. Halseth 504a910def make: run linter on verbose 2019-09-18 09:07:53 +02:00
Johan T. Halseth 00d1890dd0 lint: skip files generated for mobile 2019-09-18 09:07:21 +02:00
Johan T. Halseth 1a4ba97562 Merge pull request #3274 from esneider/fix-typo-in-doc
Fix typo in doc
2019-09-18 08:37:06 +02:00
Johan T. Halseth d9a55334dc config: allow mainnet neutrino 2019-09-17 13:27:19 +02:00
Johan T. Halseth 92123c603d gossiper: retransmit self NodeAnnouncement 2019-09-16 10:54:42 +02:00
Johan T. Halseth 24004fcb37 gossiper+server: define SelfNodeAnnouncement 2019-09-16 10:54:42 +02:00