Commit Graph

73 Commits

Author SHA1 Message Date
Alex
50d88e7769 chainntfns/neutrinonotify: update driver to comply with BIP 2017-11-02 20:04:07 -07:00
Jim Posen
e9c16845dc chainntnfs: Remove some unnecessary channels in interface_test. 2017-10-19 20:00:16 -07:00
Jim Posen
be7cb08f41 chainntnfs: Rename file with typo in filename. 2017-10-19 20:00:16 -07:00
Olaoluwa Osuntokun
e5f3ee0fb6
chainntnfs+routing/chainview: reduce neutrino.WaitForMoreCFHeaders value
This commit reduces the neutrino.WaitForMoreCFHeaders parameter when
instantiating a neutrino instance as a lower value will allow the tests
to complete more quickly.
2017-09-13 16:46:11 +02:00
Olaoluwa Osuntokun
5044cd6468
chainntnfs/btcdnotify: recognize JSON-RPC error in RegisterSpendNtfn
This commit fixes a prior bug in the logic for registering a new spend
notification. Previously, if the transaction wasn’t found in the
mempool or already confirmed within the chain, then
GetRawTransactionVerbose would return an error which would cause the
function itself to exit with an error.

This issue would then cause the server to be unable to start up as the
breach arbiter would be unable to register for spend notifications for
all the channels that it needed to be watching.

We fix this error simply by recognizing the particular JSON-RPC error
that will be returned in this scenario and treating it as a benign
error.
2017-09-12 17:11:47 +02:00
Olaoluwa Osuntokun
ed7eae819a
chainntnfs/btcdnotify: don't error if tx not found for historical conf dispatch
This commit fixes a prior mishandled error when attempting historical
confirmation dispatches. In the prior version of this code fragment, if
the transaction under the spotlight wasn’t found within the mempool, or
already in the chain, then an error would be returned by
b.chainConn.GetRawTransactionVerbose, which would case the function to
exit with an error. This behavior was incorrect, as during transaction
re-broadcasts, it was possible for transaction not yet to be a member
of either set.

We fix this issue by ensuring that we treat the JSON error code as a
benign error and continue with the notification registration.
2017-09-12 17:06:58 +02:00
Philip Hayes
f0aa186a56 channeldb+utxonursery+lnwire: use lnwire's OutPoint,TxOut serialization 2017-08-25 17:56:50 -07:00
Olaoluwa Osuntokun
9f0efddc20
multi: switch from btcrpcclient to rpcclient 2017-08-24 18:54:24 -07:00
Olaoluwa Osuntokun
671f15383b
chainntnfs: fix a typo 2017-08-10 21:15:38 -07:00
Conner Fromknecht
d1e797451d chainntnfs/btcd+neutrino: close spendChan after send 2017-08-03 17:32:44 -07:00
Olaoluwa Osuntokun
399d9c974f
chainntnfs: ensure ntfn cancellation loop will exit
This commit fixes a slight bug introduced. We now ensure that the
cancel loop always exists if the ChainNotifier has been signaled for a
quit.
2017-08-01 17:14:11 -07:00
Conner Fromknecht
9f85eadde1 chainntnfs/btcd+neutrino: sync epoch cancel 2017-07-31 21:44:23 -07:00
Conner Fromknecht
a9b1af4c73 chainntnfs/btcd+neurtino: unify + sync ntfn cancels 2017-07-31 21:44:23 -07:00
Olaoluwa Osuntokun
c47047c0b8
chainntnfs: extend interface test to ensure initial conf height is correct 2017-07-11 17:38:43 -07:00
Olaoluwa Osuntokun
c5f4049394
chainntnfs: convert ChainNotifier interface tests to use sub-tests 2017-07-04 15:54:45 -07:00
Andrey Samokhvalov
8fa2b95c12 lnd: remove seelog logger
The btclog package has been changed to defining its own logging
interface (rather than seelog's) and provides a default implementation
for callers to use.

There are two primary advantages to the new logger implementation.

First, all log messages are created before the call returns.  Compared
to seelog, this prevents data races when mutable variables are logged.

Second, the new logger does not implement any kind of artifical rate
limiting (what seelog refers to as "adaptive logging").  Log messages
are outputted as soon as possible and the application will appear to
perform much better when watching standard output.

Because log rotation is not a feature of the btclog logging
implementation, it is handled by the main package by importing a file
rotation package that provides an io.Reader interface for creating
output to a rotating file output.  The rotator has been configured
with the same defaults that btcd previously used in the seelog config
(10MB file limits with maximum of 3 rolls) but now compresses newly
created roll files.  Due to the high compressibility of log text, the
compressed files typically reduce to around 15-30% of the original
10MB file.
2017-06-25 14:19:56 +01:00
Olaoluwa Osuntokun
54cb8a05cd
chainntnfs: fix vet error, don't pass lock by value 2017-06-07 17:07:33 -07:00
Olaoluwa Osuntokun
baf769eaf0
chainntnfs/neutrinonotify: fix deadlock when notifying blocks, wait for epoch coroutines to exit 2017-06-07 17:05:22 -07:00
Olaoluwa Osuntokun
625d57aea6
chainntnfs/btcdnotify: ensure block epoch coroutines exit before closing ntfn channel 2017-06-07 17:04:32 -07:00
Olaoluwa Osuntokun
ab2af76b44
chainntnfs: add proper logging for the two last interface-level tests 2017-06-07 17:03:01 -07:00
Olaoluwa Osuntokun
7d30634757
routing/chainview: fix race condition in neutrino implementation 2017-06-06 12:01:24 -07:00
Olaoluwa Osuntokun
9fd70958f4
multi: fix linter errors 2017-06-05 19:45:01 -07:00
Olaoluwa Osuntokun
cbf7cd48f5
multi: update to latest neutrino API changes 2017-06-05 19:41:07 -07:00
Olaoluwa Osuntokun
392a8180dd
chaintnfs/neutrinonotify: add additional logging 2017-06-05 19:08:30 -07:00
Olaoluwa Osuntokun
0050108391
chainntnfs/btcdnotify: fix off-by one error when setting spending height 2017-06-05 19:07:48 -07:00
Olaoluwa Osuntokun
065f646ef8
chainntnfs: add the neutrino implementation to the set of interface tests
This commit adds a new case and proper initialization for the
NeutrinoNotifier implementation, such that it can be tested in-line
with the other implementations for proper behavior conformity.

Due to a delay when btcd sends invs for new blocks, the timeouts for
several of the tests has been extended in order to give enough time for
propagation of the new block.
2017-06-05 19:07:04 -07:00
Olaoluwa Osuntokun
8f81133d6c
chainntnfs/neutrinonotify: add ChainNotifier implementation for neutrino
This commit adds an initial rough implementation father ChainNotifier
interface for neutrino, our new light client implementation. This
implementation largely borrows from the existing BtcdNotifier
implementation. As a result, a follow up commit will perform two
refactoring in order to further consolidate code.
2017-06-05 19:04:56 -07:00
Olaoluwa Osuntokun
49e27c77dd
chainntnfs/btcdnotify: modify logging level from error to warn 2017-05-16 18:46:55 -07:00
Olaoluwa Osuntokun
1b83c6ae16
chainntnfs: update confirm ntfn tests to verify TxIndex+BlockHeight
This commit updates two interface-level tests for confirmation
notifications to check the txIndex and blockHeight advertised to serve
as regression tests for the recent bug fix related to properly setting
these two fields.
2017-05-15 18:20:46 -07:00
Olaoluwa Osuntokun
dfd9f6d1ca
chainntnfs/btcdnotify: fix historical confirmation dispatch bugs
This commit fixes to distinct bugs in the way we previously dipatched
notifications for transactions which needed a historical dispatch.

Previously we would compare transactions when scanning the block using
the `tx.Hash` field. This was incorrect has the `Hash` field is
actually the wtxid, not the txid which should be the item being
compared. We fix this within the second bug fix by actually using the
txid to find the proper transaction.

The second fix has to due with a slight race condition which led to an
off-by-one error when dispatching the historical confirmation. If while
we were dispatching the confirmation, a new block was found, then we
could calculate the wrong block height (off by one) as we were using
the ‘currentHeight’ instead the height of the block which included the
transaction.
2017-05-15 17:47:07 -07:00
Olaoluwa Osuntokun
1b4862d815
lnwallet: use new ChainNotifier API, typo fixes 2017-05-11 15:21:05 -07:00
Olaoluwa Osuntokun
2f0639f1af
chainntnfs: add heightHint to RegisterSpendNtfn+ RegisterConfirmationsNtfn
This commit modifies two of the main methods in the ChainNotifier
interface to be more light client friendly. In order to do so, we now
tack on an extra parameter to the methods: heightHint. This value
represents the earliest known height that the chain should be scanned
when attempting to do a dispatch from historical data.

All tests have also been updated to use these new parameters properly
when excising the expected behavior of each interface implementation.
2017-05-11 15:20:38 -07:00
Olaoluwa Osuntokun
45bbeb8f84
chainntnfs/btcdnotify: properly include SpendingHeight in SpendDetails
This commit modifies the btcdnotify implementation of the ChainNotifier
interface to properly include the height in which the watched output
was spent in the SpendDetail sent as a notification.

The set of tests have also been updated to assert that the proper
spending height is included in received notification.
2017-05-11 15:20:36 -07:00
Olaoluwa Osuntokun
4b15310c08
chainntfns/btcdnotify: eliminate block epoch race condition, use diff cancel channel
This commit fixes a race condition that was uncovered by the race
condition detector surrounding cancelling active block epoch
notifications. Previously we would close the main notification channel
for each client, at tine this would cause a read/write race condition
if an active grouting was attempting to dispatch a notification. We now
fix this use by using a distinct channel for signaling cancellation to
the active grouting, and another to signal cancellation to any
notification observers.
2017-05-05 15:53:20 -07:00
Olaoluwa Osuntokun
a9b8da7c3f
chainntfns/btcdnotify: log error when unable to query for transaction 2017-05-04 17:38:52 -07:00
Olaoluwa Osuntokun
c575107607
chaintnfs/btcdnotify: make cancellation of block epoch synchronous
This commit is meant to fix an occasional flake in the interrogation
tests cause by the async nature of the cancellation of block epoch
notifications. This commit modifies the cancellation to now be fully
synchronous which should eliminate this flake.
2017-04-26 21:17:35 -07:00
Olaoluwa Osuntokun
419c2ac206
chainntnfs/btcdnotify: fix race condition for block epoch clients
This commit fixes a race condition that was introduced while fixing a
lingering bug in the logic to notify block epoch clients. The race
condition would happen as by removing the default case in the select
statement, it was now possible for the client’s block epoch client to
be closed while the routine was attempting a send on it.

We now eliminate this race condition possibility by adding a wait group
to all goroutines launched to dispatch a block epoch notification. With
this modification, the Stop() goroutine will now wait for all other
goroutine to exit before closing the block epoch channels of all
currently registered clients.
2017-04-04 14:20:16 +02:00
Olaoluwa Osuntokun
608b9d96d1
chainntnfs/btcdnotify: fix dropped block epoch notification bug
This commit a bug introduced in the chain notifier while we were
limiting the usage of mutexes within the package. In a prior commit a
default case was introduced in the select statement in order to avoid
the possibility of the main goroutine blocking when dispatching block
epoch notification.

In order to avoid this potentially disastrous bug, we now instead
launch a new goroutine for each client to ensure that all notifications
are reliably dispatched.
2017-04-01 20:13:58 +02:00
Olaoluwa Osuntokun
6b3a258e86
multi: fix formatting issues in packge README's 2017-03-27 16:25:25 -07:00
Andrey Samokhvalov
ee2379775c lnd: fix golint warning which requires to add additional comments 2017-03-13 16:30:23 -07:00
Andrey Samokhvalov
fd97a4bd19 lnd: partially fix golint warnings 2017-03-13 16:30:23 -07:00
Andrey Samokhvalov
143a6e01bb lnd: fix unconvert warnings 2017-03-13 16:30:23 -07:00
Andrey Samokhvalov
f2843dd4c9 lnd: fix gofmt warnings 2017-03-13 16:30:23 -07:00
Olaoluwa Osuntokun
6c81dfad61
chainntfns/btcdnotifier: fix race condition in notifyBlockEpochs
This commit fixes a race condition in the notifyBlockEpochs detected by
the race condition detector. Previously the notifyBlockEpochs function
could cause a race condition when a new caller was either cancelling an
existing notification intent or creating a new one.

We fix this issue by making the call to notifyBlockEpochs synchronous
rather than asynchronous. An alternative would be to add a mutex
guarding the map state. The channel itself is buffered with a good
margin, so there shouldn’t be a huge impact.
2017-02-22 14:51:48 -08:00
Olaoluwa Osuntokun
73cc28d5fb
chainntnfs/btcdnotify: implement spend+epoch ntfn cancellations
This commit minifies the BtcdNotifier concrete implementation of the
ChainNotifier interface to allow callers to optionally cancel an
outstanding block epoch or spend notificaiton intent.

To do this efficiently, we now give each notification intent a unique
ID based on if it’s an epoch intent or a spend intent. We then use this
ID to reference back to the original un-dispatched notification intent
when the caller wishes to cancel the intent.
2017-02-21 01:42:53 -08:00
Olaoluwa Osuntokun
a3319bb21a
chainntnfs: add the ability to cancel spend+epoch notifications
When iterating with the ChainNotifier, it currently isn’t possible to
cancel a non-dispatched yet active notificaiton intent. As a result,
this can be rather wasteful in many parts of lnd which my repeatedly
create a new spend notification depending on if/when a peer is
connected or not.

In order to fix this, we add a new `Cancel func()` field to both the
`BlockEpochEvent` and `SpendEvent` structs. This new closure attribute
allows the caller to cancel the yet-to-be-dispathed event, allowing the
ChainNotifier to free up resources.
2017-02-21 01:42:50 -08:00
Olaoluwa Osuntokun
384fe61e73
multi: fix go vet warnings throughout code base 2017-02-16 19:33:19 +08:00
Trevin Hofmann
40c7bac3aa multi: fix a variety of typos throughout the repo 2017-01-17 17:02:56 -08:00
Trevin Hofmann
a13ac90d46 multi: add link to LICENSE in README license badges (#100) 2017-01-12 16:31:08 -08:00
Christopher Jämthagen
cc4617ca23 chainntnfs: break out of loop once txIndex is found 2017-01-11 15:51:19 -08:00