Commit Graph
100 Commits
Author SHA1 Message Date
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
Johan T. Halseth e36d15582c discovery/gossiper test: add TestRetransmit
This commit adds a test that ensures outdated announcements are
retransmitted when the RetransmitTicker ticks.
2019-09-16 10:54:38 +02:00
Johan T. Halseth 70d63abe9f discovery/test: set global test timestamp 2019-09-16 10:23:01 +02:00
Johan T. Halseth 8b9fd039ec discovery/gossiper test: remove mockGraphSource.SelfEdges 2019-09-16 10:23:01 +02:00
Johan T. Halseth e201fbe396 discovery+server: RetransmitDelay->RetransmitTicker
Also let retransmitStaleChannels take a timestamp, to make it easier to
test.
2019-09-16 10:23:01 +02:00
Johan T. Halseth 74c9551564 discovery+server: make RebroadcastInterval part of config 2019-09-16 10:23:00 +02:00
Johan T. Halseth 3d8f194670 discovery/gossiper: extract adding nodeAnnouncement into method 2019-09-16 10:23:00 +02:00
Johan T. Halseth d195acc632 chainntnfs/neutrino: start concurrent queues prior to connection
Similar to what was done for btcd, just to make sure we won't be blocked
on any incoming notifications, start the queues first thing during
startup.
2019-09-16 08:54:06 +02:00
Johan T. Halseth 6b6beb4d7d chainntnfs/btcd: start concurrent queues prior to connection
We would establish the connection to the chain backend and start getting
block notifications before we had started the concurrent queues, which
would lead to the OnBlockConnected call being blocked, and a deadlock
(since GetBestBlock would never return).

Instead we make sure to start the queues before establishing the
connection, consuming the notifications right away.
2019-09-16 08:54:06 +02:00
Johan T. Halseth 1dbb653b3a Merge pull request #3501 from alrs/fix-test-errors
Cross-Project Sweep to Fix Dropped Test Errors
2019-09-13 14:15:34 +02:00
Johan T. Halseth b82286e83b Merge pull request #3498 from alrs/fix-channeldb-errors
channeldb Error Handling Fixes
2019-09-12 21:20:10 +02:00
Johan T. Halseth 8f74ec2f1a Merge pull request #3491 from fiatjaf/patch-1
Fix error message for wrong size description_hash.
2019-09-12 21:08:02 +02:00
Johan T. Halseth 01f696afce Merge pull request #3487 from matheusd/lnd-fix-extra-dave
itest: Shutdown final Dave node in testChanRestore
2019-09-12 14:55:53 +02:00
Johan T. Halseth e61ec3a46d Merge pull request #3467 from hsjoberg/norest-config
config: Add norest config for disabling REST API
2019-09-12 08:20:37 +02:00
Johan T. Halseth 2dd23819bb Merge pull request #3486 from joostjager/remove-unused
multi: remove dead code
2019-09-11 08:52:50 +02:00
Johan T. Halseth 78e87d148f Merge pull request #3475 from chokoboko/fix-pilot-log-message
trivial: fix log message in initAutoPilot
2019-09-09 10:25:46 +02:00
Johan T. Halseth a8cb1c80eb mobile: add README 2019-09-05 09:22:54 +02:00
Johan T. Halseth fef2074c1d mobile: add sample_lnd.conf 2019-09-05 09:22:54 +02:00
Johan T. Halseth 3aa9f18395 make: define make android, make mobile (ios+android) 2019-09-05 09:22:54 +02:00
Johan T. Halseth 4dcaea1f5d make: define make ios, make vendor 2019-09-05 09:22:54 +02:00
Johan T. Halseth 8a92ccbbf4 mobile/bindings: add mobile bindings 2019-09-05 09:22:54 +02:00
Johan T. Halseth a5c63786c6 make+mobile: define gen_bindings.sh
gen_bindings uses falafel to generate Go bindings from the lnrpc
protos.
2019-09-05 09:22:54 +02:00
Johan T. Halseth fa21601d07 lnd+cmd/lnd/main: add ListenerCfg to Main
ListenerCfg allows passing custom listeners to the main method, to be
used for the wallet unlocker and rpc server. If these are set these will
be used instead of the regular RPC listeners.
2019-09-05 09:22:54 +02:00
Johan T. Halseth 2562fdbdda lnd+rpcserver: extract listener setup into closure 2019-09-05 09:22:54 +02:00
Johan T. Halseth 187bd29d2d gitignore: add mobile/build 2019-09-05 09:22:53 +02:00
Johan T. Halseth d7f0372fa2 lntest/itest: use timeout constants in rejectHTLC test
The local timeout could be too short for certain backends.
2019-09-02 12:05:51 +02:00
Johan T. Halseth 2f1aad257c autopilot/agent: trace log skipped nodes during scoring 2019-09-02 10:41:00 +02:00
Johan T. Halseth d5ab95546e autopilot/combinedattach: trace log scoring process from sub heuristics 2019-09-02 10:40:59 +02:00
Johan T. Halseth b2560b4ad2 autopilot/externalscoreattach: trace log scoring process 2019-09-02 10:40:59 +02:00
Johan T. Halseth bad9f4b685 autopilot/prefattach: trace log score process 2019-09-02 10:40:58 +02:00
Johan T. Halseth 2dbc4fe973 autopilot/agent: move expensive graph lookup after channel size check 2019-09-02 10:35:14 +02:00
Johan T. HalsethandWilmer Paulino c3480c6066 lntest/bitcoind: set debug loglevel
Co-authored-by: Wilmer Paulino <wilmer.paulino@gmail.com>
2019-09-02 09:37:41 +02:00
Johan T. Halseth 168fc4e1ab lntest/itest: cleanup force closed channel in testSendUpdateDisableChannel
Otherwise following tests would be flaky because of unexpected sweep transaction in the mempool.
2019-09-02 09:37:37 +02:00
Johan T. Halseth 857a2c3e65 make+travis: enable bitcoind itests on travis 2019-09-02 09:37:37 +02:00