Modifies the test cases in `TestEdgeUpdateNotification` and
`TestNodeUpdateNotification` to check for the possibility of notifications
being delivered out of order. This addresses some sporadic failures that
were observed when running the test suite.
I looked through some of the open issues but didn't see any addressing this
issue in particular, but if someone could point me to any relevant issues
that would be much appreciated!
Issue
-----
Currently the test suite validates notifications received in the order they
are submitted. The check fails because the verification of each
notification is statically linked to the order in which they are delivered,
seen
[here](https://github.com/cfromknecht/lnd/blob/1be4d67ce41e65feee8ea05332dfc67a3437813d/routing/notifications_test.go#L403)
and
[here](https://github.com/cfromknecht/lnd/blob/1be4d67ce41e65feee8ea05332dfc67a3437813d/routing/notifications_test.go#L499)
in `routing/notifications_test.go`. The notifications are typically
delivered in this order, but causes the test to fail otherwise.
Proposed Changes
-------------------
Construct an index that maps a public key to its corresponding edges and/or
nodes. When a notification is received, use its identifying public key and
the index to look up the edge/node to use for validation. Entries are
removed from the index after they are verified to ensure that the same
entry is validated twice. The logic to dynamically handle the verification
of incoming notifications rests can be found here
[here](https://github.com/cfromknecht/lnd/blob/order-invariant-ntfns/routing/notifications_test.go#L420)
and
[here](https://github.com/cfromknecht/lnd/blob/order-invariant-ntfns/routing/notifications_test.go#L539).
Encountered Errors
--------------------
* `TestEdgeUpdateNotification`: notifications_test.go:379: min HTLC of
edge doesn't match: expected 16.7401473 BTC, got 19.4852751 BTC
* `TestNodeUpdateNotification`: notifications_test.go:485: node identity
keys don't match: expected
027b139b2153ac5f3c83c2022e58b3219297d0fb3170739ee6391cddf2e06fe3e7, got
03921deafb61ee13d18e9d96c3ecd9e572e59c8dbd0bb922b5b6ac609d10fe4ee4
Recreating Failing Behavior
---------------------------
The failures can be somewhat difficult to recreate, I was able to reproduce
them by running the unit tests repeatedly until they showed up. I used the
following commands to bring them out of hiding:
```
./gotest.sh -i
go test -test.v ./routing && while [ $? -eq 0 ]; do go test -test.v ./routing; done
```
I was unable to recreate these errors, or any others in this package, after
making the proposed changes and leaving the script running continuously for
~30 minutes. Previously, I could consistently generate an error after ~20
seconds had elapsed on the latest commit in master at the time of writing:
78f6caf5d2. Moar stability ftw!
Lightning Network Daemon
The Lightning Network Daemon (lnd) - is a complete implementation of a
Lightning Network node and currently
deployed on testnet4 - the Bitcoin Test Network. It utilizes an
upcoming upgrade to Bitcoin: Segregated Witness (segwit). The
project's codebase uses the btcsuite set
of Bitcoin libraries, and is currently dependant on btcd.
In the current state lnd is capable of:
- creating channels
- closing channels
- completely managing all channel states (including the exceptional ones!)
- maintaining a fully authenticated+validated channel graph
- performing path finding within the network, passively forwarding incoming payments
- sending outgoing onion-encrypted payments through the network
Lightning Network Specification Compliance
lnd doesn't yet fully conform to the Lightning Network specification
(BOLT's). BOLT stands
for: Basic of Lightning Technologies. The specifications are currently being drafted
by several groups of implementers based around the world including the
developers of lnd. The set of specification documents as well as our
implementation of the specification are still a work-in-progress. With that
said, lnd the current status of lnd's BOLT compliance is:
- BOLT 1: Base Protocol
lndcurrently utilizes a distinct wire format which was created before the emgergence of the current draft of BOLT specifications. We don't have aninitmessage, but we do have analogues to all the other defined message types.
- BOLT 2: Peer Protocol for Channel Management
lndimplements all the functionality defined within the document, however we currently use a different set of wire messages. Additionally,lnduses a distinct commitment update state-machine and doesn't yet support dynamically updating commitment fees.
- BOLT 3: Bitcoin Transaction and Script Formats
lndcurrently uses a commitment design from a prior iteration of the protocol. Revocation secret generation is handled byelkremand our scripts are slightly different.
- BOLT 4: Onion Routing Protocol
- BOLT 5: Recommendations for On-chain Transaction Handling
- BOLT 7: P2P Node and Channel Discovery
- BOLT 8: Encrypted and Authenticated Transport
Installation
In order to build from source, the following build dependencies are required:
-
Go: Installation instructions can be found here.
It is recommended to add
$GOPATH/binto yourPATHat this point. Note: If you are building withGo 1.5, then you'll need to enable the vendor experiment by setting theGO15VENDOREXPERIMENTenvironment variable to1. If you're usingGo 1.6or later, then it is safe to skip this step. -
Glide: This project uses
Glideto manage dependencies as well as to provide reproducible builds. To installGlide, execute the following command (assumes you already have Go properly installed):$ go get -u github.com/Masterminds/glide -
btcd: This project currently requires
btcdwith segwit support, which is not yet merged into the master branch. Instead, roasbeef maintains a fork with his segwit implementation applied. To install, please see the installation instructions.
With the preliminary steps completed, to install lnd, lncli, and all
related dependencies run the following commands:
$ git clone https://github.com/lightningnetwork/lnd $GOPATH/src/github.com/lightningnetwork/lnd
$ cd $GOPATH/src/github.com/lightningnetwork/lnd
$ glide install
$ go install . ./cmd/...
Updating
To update your version of lnd to the latest version run the following
commands:
$ cd $GOPATH/src/github.com/lightningnetwork/lnd
$ git pull && glide install
$ go install . ./cmd/...
Tests
To check that lnd was installed properly run the following command:
go install; go test -v -p 1 $(go list ./... | grep -v '/vendor/')
IRC
- irc.freenode.net
- channel #lnd
- webchat