Commit Graph
49 Commits
Author SHA1 Message Date
nsa 363bdc42b0 fuzz/lnwire: adding fuzz harnesses for all lnwire messages + zlib 2020-03-03 13:58:25 -05:00
nsa 5a03fe572f lnwire: move zero-length queryBody check to zlib case 2020-03-03 13:58:25 -05:00
nsa 7b9e0c889e docs: add fuzz.md 2020-03-03 13:58:07 -05:00
nsa 5a5e095684 lnwallet: adding TestMaxAsynchronousHtlcs unit test
Adds a new test which asserts that the new ReceiveHTLC logic can
handle proper commitment overflow calculation in the face of
asynchronous updates.
2020-02-15 09:59:50 -05:00
nsa 4af00c6b25 lnwallet: fixing unit tests to properly handle new receive validation
This commit fixes the TestMaxAcceptedHTLCs, TestMaxPendingAmount,
TestMinHTLC, & TestChanReserve unit tests to pass with the new
ReceiveHTLC logic. Instead of asserting specific failures upon
receiving a new commitment signature, the various assertions were
moved to assert on the error returned from ReceiveHTLC.
2020-02-15 09:59:50 -05:00
nsa 56c07a52d8 lnwallet: call valdiateCommitmentSanity in ReceiveHTLC
This commit checks the commitment sanity when receiving an HTLC so
that if a commitment transaction will overflow from an ADD, it is
caught earlier rather than in ReceiveNewCommitment.
2020-02-15 09:59:49 -05:00
nsa 0d42da0cb3 fuzz/brontide: random+static round-trip encrypt+decrypt harnesses 2020-01-30 16:46:02 -05:00
nsa 0be5660a2a fuzz/brontide: random+static encrypt harnesses 2020-01-30 16:46:02 -05:00
nsa 468e5c03e9 fuzz/brontide: random+static decrypt harnesses 2020-01-30 16:46:01 -05:00
nsa 116c5469bc fuzz/brontide: random+static harnesses for acts 1-3 2020-01-30 16:46:01 -05:00
nsa 511fdb2520 fuzz/brontide: add fuzzing helper utilities 2020-01-30 16:46:01 -05:00
nsa 7c316b9194 brontide: add SetCurveToNil function 2020-01-30 16:45:59 -05:00
nsa 929167b9af routing: fix race condition when resuming payments 2019-11-15 14:44:05 -05:00
nsa 1018df991f macaroons: add encKeyMtx to prevent race condition 2019-11-09 21:12:11 -05:00
nsa b392dd1b95 routing: move statTicker to prevent race condition 2019-11-02 13:55:41 -04:00
nsa 423887d3d8 chanacceptor: adding tests for the RPCAcceptor
This commit adds the TestRPCMultipleAcceptClients test which asserts
that the RPCAcceptor correctly handles multiple Accept callers.
2019-09-25 12:07:31 -04:00
nsa 4d02100e12 fundingmanager+server: adding ChannelAcceptor to the fundingmanager 2019-09-25 12:07:30 -04:00
nsa c2a6c86e6b rpcserver: adding ChannelAcceptor bidirectional streaming 2019-09-25 12:07:30 -04:00
nsa 2bd2e2e5ce chanacceptor: Adding Chained and RPC acceptors
This commit introduces the chanacceptor package which is used
to determine, by a set of heuristics, which open channel messages
to accept and reject. Currently, two acceptors are implemented
via the ChannelAcceptor interface: ChainedAcceptor and RPCAcceptor.
The RPCAcceptor allows the RPC client to respond to the open channel
request, and the ChainedAcceptor allows a conjunction of acceptors
to be used.
2019-09-25 12:07:30 -04:00
nsa 7c6cee7c4f lnrpc: updating protos to include ChannelAcceptor 2019-09-25 12:07:28 -04:00
nsa 0f6e11c35f zpay32: check invoice length while decoding
This commit checks that the size of the bech32 encoded invoice is not
greater than 7092 bytes, which is the maximum number of bytes that can
fit into a QR code. This mitigates a potential DoS vector where an attacker
could craft a very large bech32 invoice string containing an absurd amount
of route and/or hop hints. If sent to an application that processes
payment requests, this would allocate a burdensome amount of memory
due to the public key parsing for each route/hop hint.

For a 1.7MB payment request, this yielded about 38MB in allocations
from just parsing public keys:

```
   45.51MB  7.31% 92.07%    45.51MB  7.31%  math/big.nat.make
   25.50MB  4.09% 96.16%    25.50MB  4.09%  github.com/lightningnetwork/lnd/zpay32.bech32VerifyChecksum
       1MB  0.16% 96.32%    39.50MB  6.34%  github.com/lightningnetwork/lnd/zpay32.parseRouteHint
       1MB  0.16% 96.48%    33.50MB  5.38%  github.com/btcsuite/btcd/btcec.decompressPoint
    0.50MB  0.08% 96.56%     7.50MB  1.20%  crypto/elliptic.(*CurveParams).doubleJacobian
    0.50MB  0.08% 96.64%       38MB  6.10%  github.com/btcsuite/btcd/btcec.ParsePubKey
         0     0% 96.64%       12MB  1.93%  crypto/ecdsa.Verify
         0     0% 96.64%        8MB  1.28%  crypto/elliptic.(*CurveParams).ScalarBaseMult
         0     0% 96.64%       12MB  1.93%  crypto/elliptic.(*CurveParams).ScalarMult
```

With this change, memory usage will be far lower as decoding will exit
early with an error if the invoice is too large.
2019-09-24 06:21:27 -04:00
nsa dfd1b38648 tlv: fix panic with large length
This commit fixes a panic where a large length in a record could
cause the DVarBytes function to fail to allocate a byte slice.
2019-08-21 16:48:23 -07:00
nsa 7762d55e80 itest+routing: updating tests to account for BlockPadding 2019-07-23 21:03:30 -04:00
nsa 3dde7bc4e2 routing: adding the BlockPadding value to sendpayment
This commit adds the BlockPadding value (currently 3) to sendpayment
calls so that if some blocks are mined while the htlc is in-flight, the
exit hop won't reject it.
2019-07-23 21:03:11 -04:00
nsa 00814dc7c1 htlcswitch: pipeline settles to switch
This commit makes the outgoing link pipeline the settle to the
switch as soon as it receives it. Previously, it would wait for a
revocation before sending it, which caused increased latency on
payments as well as possibly never settling on the incoming link.
A duplicate settle is still sent to the switch, but it is handled
gracefully. A new AckEventTicker was added to the switch which
acknowledges any pending settle / fail entries in an outgoing
link's fwd pkgs in batch. This was needed in order to reduce the
number of db txn's which would have been incurred by acking whenever
we receive a duplicate settle without batching.
2019-07-18 17:20:40 -04:00
nsa 7e6a34532e routing: add index map to distanceHeap
This commit adds the pubkeyIndices map to the distanceHeap to avoid
duplicate entries on the heap. This happened in the earlier iteration
of the findPath algorithm and would cause the driving loop to
evaluate already evaluated entries when there was no need.
2019-07-12 06:08:01 -04:00
nsa 61a1ab08fb routing+channeldb: findPath uses Vertex instead of LightningNode
This commit modifies the nodeWithDist struct to use a route.Vertex
instead of a *channeldb.LightningNode. This change, coupled with
the new ForEachNodeChannel function, allows the findPath Djikstra's
algorithm to cut down on database lookups since we no longer need
to call the FetchOtherNode function.
2019-07-12 06:08:01 -04:00
nsa 66d15c8e76 channeldb + wtdb: specify freelist bbolt options by default
This commit specifies two bbolt options when opening the underlying
channel and watchtower databases so that there is reduced heap
pressure in case the bbolt database has a lot of free pages in the
B+ tree.
2019-07-08 18:41:25 -04:00
nsa 4fd78926d4 build: update bbolt to v1.3.3 with panic rollback fix
This commit updates the bbolt dependency to v1.3.3 so that we
can use the NoFreelistSync option without triggering a panic
in case a rollback occurs.
2019-07-08 18:35:43 -04:00
nsa 678fb674eb routing: move call to PruneGraph outside of the collating loop
This commit moves the call to PruneGraph outside of the loop
that collates all of the spentOutputs. With this change, if
a node has been offline for a long period of time, resyncing
with the chain no longer takes up as much memory (1MB vs 200MB
in some cases) or time. Previously, PruneGraph was called
for every block and allocated a very large map further down
in the pruneGraphNodes function. Now, pruneGraphNodes is only
called once.
2019-07-02 21:21:28 -04:00
nsa 9804caca6d chanrestore: return error instead of nil if failed derivation
This commit fixes a bug in the openChannelShell function where,
instead of properly returning an error when failing to derive
the shachain root's private key, nil was returned instead. This
would lead to a panic as the channel shell was then referenced
further down in the callstack. An error is now properly returned.
2019-06-30 12:42:36 -04:00
nsa d09d514858 lnwire: include init prefix in MaxPayloadLength calculation 2019-02-07 13:19:54 -05:00
nsa a460fa92b8 lnwire: change error's MaxPayloadLength to 65535 2019-02-06 20:46:38 -05:00
nsa 7a65be7f14 lnwire: features "maxAllowedSize" fix 2019-02-06 07:02:10 -05:00
nsa d924fcfdf4 funding test: add default constraints to wallet config 2018-02-08 18:35:23 -05:00
nsa 7e84892c21 htlcswitch: account for channel reserve in Bandwidth 2018-02-08 18:35:23 -05:00
nsa 7e7516137d lnwallet: validate commited channel constraints 2018-02-08 18:35:23 -05:00
nsa 698df2ac16 torsvc: added new type that multiplexes torsvc and net packages
This commit adds the `lnnet` package which contains an
implementation of the newly created LightningNet interface which
multiplexes the Dial and DNS-related functions to use net
by default and torsvc if a flag is specified. This modularization
makes for cleaner code.
2018-02-05 17:37:46 -08:00
nsa 8c482f2be7 multi: Added a NetInterface to clean up config.go
This commit adds a new interface named NetInterface and two
implementations of it: RegularNet & TorProxyNet. These two structs
are used in config.go in an attempt to clean up the code and
abstract away the dialer and DNS functions.
2018-02-05 17:37:46 -08:00
nsa e132ad8433 torsvc: Added new module to house Tor functions
This commit adds a new module named 'torsvc' which houses all Tor
functionality in an attempt to isolate it and make it reusable in
other projecs. Some additional tweaks were made to config.go and
to the bootstrapper.
2018-02-05 17:37:46 -08:00
nsaandMeshCollider e2142c778f multi: Added Tor support
This commit adds Tor support. Users can set the --TorSocks flag
to specify which port Tor's SOCKS5 proxy is listening on so that
lnd can connect to it. When this flag is set, ALL traffic gets
routed over Tor including DNS traffic. Special functions for
DNS lookups were added, and since Tor doesn't natively support
SRV requests, the proxySRV function routes connects us to
a DNS server via Tor and SRV requests can be issued directly
to the DNS server.

Co-authored-by: MeshCollider <dobsonsa68@gmail.com>
2018-02-05 17:37:46 -08:00
nsa f06f6bc869 funding test: test private channels.
Tests in fundingmanager_test.go that
assert the privacy guarantees of non-broadcasting.
2017-12-17 18:35:34 -08:00
nsa c954ca1f21 funding: adding to graph, private chans, chanAnn after 6 confs
This commit introduces some new interdependent functionality. As
soon as the fundingLocked message is sent, the channel is
immediately added to the ChannelRouter's internal topology.

Finally, channels are now only broadcasted to the greater
network after six confirmations on the funding transaction
has been reached.
2017-12-17 18:35:34 -08:00
nsa dab7f31e44 gossiper: Only send channel updates for edges with AuthProof. 2017-12-17 18:35:34 -08:00
nsa 3beef359a2 rpcserver: forward private parameter to OpenChannel 2017-12-17 18:35:34 -08:00
nsa 5c4add8e0e pilot: pass private=false to OpenChannel 2017-12-17 18:35:34 -08:00
nsa 9fcb845bd2 server: use private parameter when opening channel 2017-12-17 18:35:34 -08:00
nsa 17c98473d9 lnrpc: add --private arg to OpenChanRequest 2017-12-17 18:35:34 -08:00
nsa aa6395874d wallet: channel test fee fix for added HTLC
This commit fixes the TestChannelBalanceDustLimit unit test in
channel_test.go. The unit test does not account for the fees
required by adding an HTLC. As a result, Alice's balance according
to her local and remote commitment chains drops below 0 at certain
points. By using the correct fee, this is avoided.
2017-10-19 20:04:04 -07:00