Commit Graph

2868 Commits

Author SHA1 Message Date
Conner Fromknecht 20738885ef
mock: adds mockSpendNotifier and updates mockSigner 2018-01-05 13:47:17 -08:00
Conner Fromknecht 95b788e9a6
channeldb/db: exposes Path method, useful for testing 2018-01-05 13:47:17 -08:00
Conner Fromknecht 1d69526874
channeldb/channel: adds IsBorked to OpenChannel 2018-01-05 13:47:17 -08:00
Conner Fromknecht 20f4c61c8b
lnwallet/channel_test: adds TestBreachClose 2018-01-05 13:47:17 -08:00
Conner Fromknecht 9703ab9161
lnwallet/channel: exposes channelState via State for testing 2018-01-05 13:47:17 -08:00
Conner Fromknecht bb8c5f82da
lnwallet/channel: delete state after ack from breach arb 2018-01-05 13:47:16 -08:00
Conner Fromknecht ff3a1389e5
breacharbiter_test: remove channel close summary fields 2018-01-05 13:47:16 -08:00
Conner Fromknecht fb228a0f7d
breacharbiter: reliable handoff from wallet 2018-01-05 13:46:36 -08:00
Olaoluwa Osuntokun e2fe4c2955
htlcswitch: reject duplicate payments to same invoice
In this commit, we modify the way the link handles HTLC’s that it
detects is destined for itself. Before this commit if a payment hash
came across for an invoice we’d already settled, then we’d gladly
accept the payment _again_. As we’d like to enforce the norm that an
invoice is NEVER to be used twice, this commit modifies that behavior
to instead reject an incoming payment that attempts to re-use an
invoice.

Fixes #560.
2018-01-04 14:23:37 -06:00
Olaoluwa Osuntokun 7421584341
lnrpc: making PendingChannels req/resp naming scheme consistent
In this commit we rename the lnrpc.PendingChannelRequest and
lnrpc.PendingChannelResponse to
lnrpc.PendingChannelsRequest/lnrpc.PendingChannelsResponse. We do this
as we strive to ensure that the naming scheme across the RPC interface
is consistent.
2018-01-04 14:20:31 -06:00
Wilmer Paulino 445e11db5c bolt11: handle r field fee spec change
Updates the way fees are handled for routing payments.
See lightningnetwork/lightning-rfc#317.
2018-01-04 13:23:56 +01:00
Thijs Triemstra 607b394f38 fix typos in rpcserver 2018-01-03 19:23:26 +01:00
Justus Kandzi 976655d172 docs: fix python example code issues 2018-01-03 18:09:00 +01:00
Matt Drollette 12677f08b2 correct wording on error log 2018-01-03 17:40:42 +01:00
Walt Seymour 0a36bfae9c fix issue with closechannel 2018-01-03 15:19:10 +01:00
Nabil Boag 63517a1eef Update Docker README examles, spelling and grammar 2018-01-03 12:25:09 +01:00
hackerrdave ad40207126 provide formatting for lnd references 2018-01-03 11:39:35 +01:00
Johan T. Halseth 2ddd139084 discovery: check proof for nilness before creating chanAnn
This commit makes sure we are not attempting to create a
channel announcement with a nil ChannelAuthProof, as that
could cause a crash at startup whe the gossiper would
attempt to reprocess an edge coming from the fundingmanager.

It also makes sure we check the correct error returned from
processRejectedEdge.
2018-01-02 19:51:38 +01:00
Olaoluwa Osuntokun 6b0f984e31
discovery: update tests to reflect new broadcast related changes 2017-12-26 16:29:37 +01:00
Olaoluwa Osuntokun 38715ca768
discovery: refactor re-processing rejected announcements into new method 2017-12-26 16:28:23 +01:00
Olaoluwa Osuntokun 68dabe3594
discovery: update usage of d.cfg.Broadcast to reflect recent API change
When broadcasting a set of messages, we must now call broadcast for
each (msg, …senders) tuple, rather than just calling it once for the
entire batch.
2017-12-26 16:26:34 +01:00
Olaoluwa Osuntokun 702bf7be29
server: Broadcast now takes a set of peers to skip
In this commit, we modify the Broadcast to take a *set* of peers to
skip, rather than just a single peer. We make this modification as when
a new channel is discovered, it’s likely the case that we get the
announcement from several peers rather than a single peer. With this
change, we’ll ensure that the caller (who is aware of the set of
senders) is able to properly avoid wasting bandwidth by re-sending the
message to all peers that sent it to us originally.
2017-12-26 16:25:40 +01:00
Olaoluwa Osuntokun f45502f890
discovery: update message processing to emit networkMsg rather than lnwire.Message
In this commit, we make an incremental step towards page of the new
feature of deDupedAnnoucnements to return the set of senders for each
message. All methods the process new channel announcements, will now
return an instance of networkMsg rather than lnwire.Message. This will
allow passing the returned announcement directly into
deDupedAnnoucnements.AddMsg().
2017-12-26 16:23:12 +01:00
Olaoluwa Osuntokun f1b40e0b4d
discovery: modify deDupedAnnouncements to keep track of senders for each msg
In this commit, we modify the deDupedAnnouncements struct slightly. The
element of this struct will now keep track of the set of senders that
sent a particular message. Each time a message is added, we’ll replace
the new message with the old (as normal), but we’ll also add the new
sender to the set of known senders.

With this new feature, we’ll be able to avoid re-sending a message to
the peer that sent it to us in the first place.
2017-12-26 16:19:03 +01:00
Olaoluwa Osuntokun 7e54b4ae46
lnwire: if unable to parse encapsulated error, log length and raw bytes
In this commit, we add additional detail in the error return hen were’e
unable to properly decode an encapsulated error. This additional
logging was added with the goal of being able to track down a lingering
bug, where at times lnd cannot decode a TemporaryChannelFailure
message.
2017-12-26 16:17:22 +01:00
Matt Drollette d6172ca8b4 discovery: correctly format ipv6 addresses from dns seed 2017-12-22 20:12:35 +01:00
Olaoluwa Osuntokun b74b9fc16e
test: extend time outs in flaky tests due to Travis CI instance speed variance 2017-12-22 19:43:50 +01:00
Olaoluwa Osuntokun 9777176d7d
lnwallet: don't use persistent pointer to funding tx within channel state machine
This commit fixes a lingering bug that could at times cause
incompatibilities with other implementations when attempting a
cooperative channel close. Before this commit, we would use a pointer
to the funding txin everywhere. As a result, each time we made a new
state, or verified one, we would modify the sequence field of the main
txin of the commitment transaction. Due to this if we updated the
channel, then went to do a cooperative channel closure, the sequence of
the txin would still be set to the value we used as the state hint.

To remedy this, we now copy the txin each time when making the
commitment transaction, and also the cooperative closure transaction.
This avoids accidentally mutating the txin itself.

Fixes #502.
2017-12-22 19:26:35 +01:00
Olaoluwa Osuntokun 3f2a5241c1
Merge pull request #509 from halseth/fix-sendtopeer-deadlock
[trivial] server: fix deadlock in sendToPeer at peer shutdown
2017-12-22 17:48:26 +01:00
Olaoluwa Osuntokun 151a4325b1
htlcswitch: fix alignment of the packetQueue's fields for 32-bit systems (#507)
In this commit, we fix an existing issue that would cause lnd to panic
on 32-bit systems. Within the packetQueue we utilize atomics heavily.
However, it's the caller's job to ensure 64-bit alignment of 64-bit words
accessed atomically. This is documented within the sync/atomic package
as a set of known bugs.

The old alignment of this struct was:

⛰  structlayout github.com/lightningnetwork/lnd/htlcswitch packetQueue
packetQueue.queueLen int32: 0-4 (size 4, align 4)
padding: 4-8 (size 4, align 0)
packetQueue.totalHtlcAmt int64: 8-16 (size 8, align 8)
packetQueue.queueCond *sync.Cond: 16-24 (size 8, align 8)
packetQueue.queueMtx.state int32: 24-28 (size 4, align 4)
packetQueue.queueMtx.sema uint32: 28-32 (size 4, align 4)
packetQueue.queue []*github.com/lightningnetwork/lnd/htlcswitch.htlcPacket: 32-56 (size 24, align 8)
packetQueue.outgoingPkts chan *github.com/lightningnetwork/lnd/htlcswitch.htlcPacket: 56-64 (size 8, align 8)
packetQueue.freeSlots chan struct{}: 64-72 (size 8, align 8)
packetQueue.wg.noCopy sync.noCopy: 72-72 (size 0, align 1)
packetQueue.wg.state1 [12]byte: 72-84 (size 12, align 1)
packetQueue.wg.sema uint32: 84-88 (size 4, align 4)
packetQueue.quit chan struct{}: 88-96 (size 8, align 8)

After this commit, the new alignment of this sturct is:

⛰  structlayout  -json github.com/lightningnetwork/lnd/htlcswitch packetQueue | structlayout-optimize
packetQueue.queue []*github.com/lightningnetwork/lnd/htlcswitch.htlcPacket: 0-24 (size 24, align 8)
packetQueue.wg struct: 24-40 (size 16, align 8)
packetQueue.freeSlots chan struct{}: 40-48 (size 8, align 8)
packetQueue.queueCond *sync.Cond: 48-56 (size 8, align 8)
packetQueue.queueMtx struct: 56-64 (size 8, align 8)
packetQueue.outgoingPkts chan *github.com/lightningnetwork/lnd/htlcswitch.htlcPacket: 64-72 (size 8, align 8)
packetQueue.totalHtlcAmt int64: 72-80 (size 8, align 8)
packetQueue.quit chan struct{}: 80-88 (size 8, align 8)
packetQueue.queueLen int32: 88-92 (size 4, align 8)
padding: 92-96 (size 4, align 0)

Fixes #505, and #463.
2017-12-22 16:32:11 +01:00
Johan T. Halseth db8b4cad4a
server: fix deadlock in sendToPeer at peer shutdown
This commit fixes a deadlock that could occur when
a peer disconnected during a call to sentToPeer. In
This particular case, a message would successfully
be queued, the peer would shutdown, and we would
block waiting for an error to be returned on the
message's error channel, which would deadlock.
This fixes that by also checking for peer shutdown.
2017-12-21 23:32:39 +01:00
Olaoluwa Osuntokun 3b986b4c14
htlcswitch: extend timeouts within bandwidth consistency tests 2017-12-21 11:47:45 +01:00
Olaoluwa Osuntokun a93be76d16
test: extend timeouts within testRevokedCloseRetribution tests 2017-12-21 11:44:46 +01:00
Olaoluwa Osuntokun b56dcc988b
lntest: re-write loop in ConnectNodes to use WaitPredicate 2017-12-21 11:44:20 +01:00
Olaoluwa Osuntokun 6992822865
lntest: CloseChannel will wait for both nodes to show chan as active if not force
In this commit, we modify the CloseChannel to wait for both nodes to
detect that channel as being active before we attempt to close it. This
should serve to reduce many of the flakes that we’ve been seeing on
travis which were caused by node A detecting the channel as active, but
node B not, leading to a test flake under certain timing conditions.
The new function uses the recently added WaitPredicate method.
2017-12-21 11:43:17 +01:00
Olaoluwa Osuntokun c3f84b1a47
lntest: re-write AssertChannelExists to use WaitPredicate internally
Recent changes to the funding manger’s state machine have resulted in
some additional database calls during the funding process. This has
slowed down the tests by a few ms here and there. Recent integration
test runs have begun to fail due to AssertChannelExists returning an
error as the channel hasn’t fully propagated yet. In order to remedy
this, we’ll now use WaitPredicate to poll repeatedly to ensure. This
should serve to reduce flakes encountered within the integration tests.
2017-12-21 11:35:29 +01:00
Olaoluwa Osuntokun 72147fe1e5
lntest: add new WaitPredicate helper function 2017-12-21 11:33:34 +01:00
Olaoluwa Osuntokun 2154ec130f
lntest: add new LookUpNodeByPub method to lookup active nodes by pubkey
In this commit, we add a new helper function to the NetworkHarness
struct. This helper function serves to allow test authors to look up
pointer to an active node based on its current public key.

Each time a new node is started, its public key will be re-registered
within the global nodesByPub map.
2017-12-21 11:33:04 +01:00
Olaoluwa Osuntokun ef2838fdd3
lnwire: log type of failure upon decode failure 2017-12-21 11:31:15 +01:00
Johan T. Halseth 2f926f1a47 server: add NotifyWhenOnline method to gossiper 2017-12-19 13:01:59 -06:00
Johan T. Halseth c3aa23f061 discovery test: update gossiper test for new database structure 2017-12-19 13:01:59 -06:00
Johan T. Halseth e3ae204fcb discovery: make gossiper able to resend failed AnnounceSignatures
This commit makes the gossiper track the state of a local
AnnounceSignature message, such that it can retry sending
it to the remote peer if needed. It will also persist this
state in the WaitingProofStore, such that it can resume
from this state at startup.
2017-12-19 13:01:59 -06:00
Johan T. Halseth 8a79bbf383 server: return error from sendPeerMessages
This commit adds a return error to sendPeerMessages,
making it possible to observe if a message sent to
a peer fails or succeeds.
2017-12-19 13:01:59 -06:00
Johan T. Halseth 25b77a0aee peer: add error chan to queueMsg 2017-12-19 13:01:59 -06:00
Daniel Coonce c36b1c3992 lncli: Fix "invalid handle" error
Uses syscall.Stdin rather than 0 for terminal.ReadPassword() calls.
2017-12-19 14:56:42 +01:00
Olaoluwa Osuntokun e0c292d960
Merge pull request #486 from cfromknecht/invoice-itest-cancel
lnd_test: invoice subscription cancel lingering goroutine
2017-12-17 18:42:36 -08:00
Olaoluwa Osuntokun 3bf4b5a830
Merge pull request #489 from cfromknecht/force-close-complete-payreq
lnd_test: use completePaymentRequests in channel force close itest
2017-12-17 18:41:01 -08:00
Matt Drollette adf0d98194 multi: fix several typos in godoc comments 2017-12-17 18:40:05 -08:00
Johan T. Halseth b74a281b57 discovery test: test for remote ChannelUpdate for unknown channel
This commit adds a test that ensures that if we receive a
ChannelUpdate for a channel we don't know about, it will
be reprocessed after we receive a ChannelAnnouncement for
that channel.
2017-12-17 18:35:34 -08:00
Johan T. Halseth db829cd0c5 discovery: reprocess premature ChannelUpdates
This commit makes the gossiper store received ChannelUpdates
that is not for any known channel in a map, such that they
can be reprocessed when the ChannelAnnouncement arrives.

This is done to handle the case where we receive a ChannelUpdate
from our channel counterparty before we have been able to process
our own local ChannelAnnouncement.
2017-12-17 18:35:34 -08:00