Commit Graph
100 Commits
Author SHA1 Message Date
Wilmer Paulino 83a0d03c0b discovery: use token bucket based rate limiting to throttle gossip
The recently added gossip throttling was shown to be too aggressive,
especially with our auto channel enable/disable signaling. We switch to
a token bucket based system instead as it's based on time, rather than a
block height which isn't constantly updated at a given rate.
2021-02-10 16:21:13 -08:00
Wilmer Paulino 1f1f7be770 Revert "lncfg: add new legacy protocol option to turn off gossip throttling"
This reverts commit b1fbbcf562.
2021-02-10 15:45:49 -08:00
Wilmer Paulino bfc8523873 Revert "discovery: add new option to toggle gossip rate limiting"
This reverts commit 13a2598ded.
2021-02-10 15:45:48 -08:00
Wilmer Paulino d4fa430ca6 Revert "lntest: always turn off gossip throttling for nodes created in itests"
This reverts commit 447c9f2c0b.
2021-02-10 15:45:47 -08:00
Wilmer Paulino 904003fbcb discovery: use source of ann upon confirmed channel ann batch
We do this instead of using the source of the AnnounceSignatures
message, as we filter out the source when broadcasting any
announcements, leading to the remote node not receiving our channel
update. Note that this is done more for the sake of correctness and to
address a flake within the integration tests, as channel updates are
sent directly and reliably to channel counterparts.
2021-02-10 13:22:28 -08:00
Wilmer Paulino 023f327cdd lntest: add rebroadcast stale announcements err to whitelist 2021-01-06 14:33:41 -08:00
Wilmer Paulino 7ef1f3f636 discovery: use source of ann upon confirmed channel ann batch
We do this instead of using the source of the AnnounceSignatures
message, as we filter out the source when broadcasting any
announcements, leading to the remote node not receiving our channel
update. Note that this is done more for the sake of correctness and to
address a flake within the integration tests, as channel updates are
sent directly and reliably to channel counterparts.
2021-01-06 13:16:44 -08:00
Wilmer Paulino 00d4e92362 discovery: prevent rebroadcast of premature channel updates
As similarly done with premature channel announcements, we'll no longer
allow premature channel updates to be rebroadcast once mature. This is
no longer necessary as channel announcements that we're not aware of are
usually broadcast to us with their accompanying channel updates.
2021-01-06 12:52:41 -08:00
Wilmer Paulino 871a6f1690 discovery: prevent rebroadcast of previously premature announcements 2020-12-08 15:18:08 -08:00
Wilmer Paulino a4f33ae63c discovery: adhere to proper channel chunk splitting for ReplyChannelRange 2020-12-08 15:18:07 -08:00
Wilmer Paulino c5fc7334a4 discovery: limit NumBlocks to best known height for outgoing QueryChannelRange
This is done to ensure we don't receive replies for channels in blocks
not currently known to us, which we wouldn't be able to process.
2020-12-08 15:18:06 -08:00
Wilmer Paulino 791ba3eb50 discovery: rate limit incoming channel updates
This change was largely motivated by an increase in high disk usage as a
result of channel update spam. With an in memory graph, this would've
gone mostly undetected except for the increased bandwidth usage, which
this doesn't aim to solve yet. To minimize the effects to disks, we
begin to rate limit channel updates in two ways. Keep alive updates,
those which only increase their timestamps to signal liveliness, are now
limited to one per lnd's rebroadcast interval (current default of 24H).
Non keep alive updates are now limited to one per block per direction.
2020-11-25 15:38:08 -08:00
Wilmer Paulino d3157bcaf8 watchtower: prevent removal of last tower addr
This addresses a potential panic when a tower has one of its candidate
sessions chosen, but its only reachable address was removed by a
user-initiated RPC before the fact.
2020-11-04 15:43:18 -08:00
Wilmer Paulino 1ad0dbade9 btcwallet: return chain best timestamp while backend is syncing
A while back, changes were made to the wallet such that it waits for the
backend to be synced before beginning to store the latest 10,000 blocks
of the chain. This inherently broke sync progress implementations based
on the best_header_timestamp result from the GetInfo RPC for
neutrino-based nodes as the wallet is no longer tracking all blocks in
the chain. To work around this, we now make sure to return the backend's
best header timestamp instead of the wallet's, allowing said sync
progress implementations to work again.
2020-10-19 13:57:30 -07:00
Wilmer Paulino a5c5304c09 Merge pull request #4452 from yyforyongyu/add-connection-timeout
lnrpc+tor: add network connection timeout
2020-09-16 12:28:29 -07:00
Wilmer Paulino a85c4feb17 btcwallet: skip unsupported addresses in ListTransasctionDetails
A transaction with an unsupported address would prevent the method from
returning any other transactions and would instead return an error.
2020-08-25 11:21:29 -07:00
Wilmer Paulino 90af440380 Merge pull request #4451 from yyforyongyu/fix-go-fmt
lnd: fix go fmt
2020-07-08 10:14:47 -07:00
Wilmer Paulino 9e8c39d4a2 Merge pull request #971 from vctt94/addMaxValueFlag
Add max value in flight flag
2020-07-07 10:29:51 -07:00
Wilmer Paulino 6075997ebc multi: add relative thaw height interpretation
This is useful when we wish to have a channel frozen for a specific
amount of blocks after its confirmation. This could also be done with an
absolute thaw height, but it does not suit cases where a strict block
delta needs to be enforced, as it's not possible to know for certain
when a channel will be included in the chain. To work around this, we
add a relative interpretation of the field, where if its value is below
500,000, then it's interpreted as a relative height. This approach
allows us to prevent further database modifications to account for a
relative thaw height.
2020-07-02 12:05:49 -07:00
Wilmer Paulino a998d5d647 Merge pull request #4106 from yyforyongyu/display-recovery-progress
multi: add a rpc endpoint to track the recovery process
2020-06-26 11:06:46 -07:00
Wilmer Paulino 8c79359247 Merge pull request #4395 from bmancini55/reply-channel-range-query
discovery: prevent endBlock overflow in replyChanRangeQuery
2020-06-18 15:19:52 -07:00
Wilmer Paulino d808ec0d17 itest: add sync error to whitelist 2020-06-18 14:51:45 -07:00
Wilmer Paulino d23be59f53 channeldb: remove graph insertion of restored channels
This was initially done as there were a few assertions throughout the
codebase requiring a channel's policy to be known. Now that these have
been addressed, we no longer need to store restored channels in the
graph, as their policies where incomplete anyway.
2020-06-18 14:51:44 -07:00
Wilmer Paulino 2a5b66ec00 lnwallet: note requirement of global coin selection lock 2020-06-12 11:22:30 -07:00
Wilmer Paulino c2f1fe26c1 rpc: acquire global coin select lock in related RPCs
This ensures proper coin selection synchronization between lnd and users
of the RPC to avoid potential double spend errors.
2020-06-12 11:22:29 -07:00
Wilmer Paulino 9d9e54f83e btcwallet: ensure output isn't locked by in-memory impl in LeaseOutput
The current implementation of LeaseOutput already checked whether the
output had already been leased by the persisted implementation, but not
the in-memory one used by lnd internally. Without this check, we could
potentially end up with a double spend error if lnd acquired the UTXO
internally before the LeaseOutput call.
2020-06-12 11:22:28 -07:00
Wilmer Paulino 6e8021f858 scripts: bump bitcoind version to 0.20 2020-06-12 10:46:20 -07:00
Wilmer Paulino d49c6fba87 build: update btcwallet dependency for bitcoind v0.20 compat 2020-06-12 10:46:16 -07:00
Wilmer Paulino 69b8a356b2 chainntnfs: remove queued confirmation notification in CancelConf
This addresses a panic when a notification is canceled after its been
detected as included in a block and before its confirmation notification
is dispatched.
2020-06-10 13:45:45 -07:00
Wilmer Paulino 98da6c61c1 signrpc: parse both KeyDescriptor fields for SignOutputRaw requests
This is meant to handle a quirk in which key descriptors obtained
through walletrpc.DeriveKey don't result in the derived key being
persisted to the wallet's database, unlike with DeriveNextKey. Due to
this and some fallback logic in the wallet with regards to empty key
locators, if a request only specified the compressed public key, the
signature returned would be over a different key, namely the one derived
from (family=0, index=0).
2020-06-04 17:44:25 -07:00
Wilmer Paulino 146611d1c1 lnrpc: mark existing ListUnspent RPC as deprecated in favor of walletrpc 2020-06-03 19:03:05 -07:00
Wilmer Paulino acfd432602 walletrpc: add ListUnspent RPC 2020-06-03 19:03:04 -07:00
Wilmer Paulino 7616a3dc7f rpc: refactor request validation and response marshal into functions 2020-06-03 18:50:11 -07:00
Wilmer Paulino 9dcaf4fbc6 walletrpc: add output leases RPCs 2020-06-03 18:50:09 -07:00
Wilmer Paulino ae7335ce3b lnwallet: expose output leases on WalletController interface 2020-06-03 18:49:39 -07:00
Wilmer Paulino 94629b6c73 build: update btcwallet version to expose output leases 2020-06-03 18:31:53 -07:00
Wilmer Paulino c7dad7a8dd Merge pull request #4341 from wpaulino/log-raw-funding-tx
fundingmanager: log raw transaction on broadcast
2020-06-03 15:45:22 -07:00
Wilmer Paulino 96dc30ae70 fundingmanager: log raw transaction on braodcast 2020-06-03 14:57:13 -07:00
Wilmer Paulino d0fe8b737b netann: decode features when creating chan ann from stored chan info
This was the only field not properly set when creating a
lnwire.ChannelAnnouncement from a channeldb.ChannelEdgeInfo.
2020-06-01 17:30:23 -07:00
Wilmer Paulino 77a4bc97a7 Merge pull request #4304 from guggero/peer-alignment
peer: fix struct alignment
2020-05-21 19:05:21 +00:00
Wilmer Paulino f287ac3cea btcwallet: add transaction outputs bounds check to FetchInputInfo
This prevents a panic when providing an incompatible output index for
the transaction.
2020-05-20 11:42:12 -07:00
Wilmer Paulino db2589ee8d itest: add disconnection error to whitelist 2020-05-18 16:14:31 -07:00
Wilmer Paulino 0e3fc4c7a6 build: update to latest btcd and btcwallet versions
This update introduces backwards compatibility for btcd nodes running
versions prior to v0.20.1-beta.
2020-05-15 17:00:16 -07:00
Wilmer Paulino c760700545 wtmock: prevent race conditions by not using ClientSession pointers
These race conditions originate from the mock database storing and
returning pointers, rather than returning a copy.

Observed on Travis:

WARNING: DATA RACE
Read at 0x00c0003222b8 by goroutine 149:
  github.com/lightningnetwork/lnd/watchtower/wtclient.(*sessionQueue).drainBackups()
      /home/runner/work/lnd/lnd/watchtower/wtclient/session_queue.go:288 +0xed
  github.com/lightningnetwork/lnd/watchtower/wtclient.(*sessionQueue).sessionManager()
      /home/runner/work/lnd/lnd/watchtower/wtclient/session_queue.go:281 +0x450

Previous write at 0x00c0003222b8 by goroutine 93:
  github.com/lightningnetwork/lnd/watchtower/wtclient.getClientSessions()
      /home/runner/work/lnd/lnd/watchtower/wtclient/client.go:365 +0x24f
  github.com/lightningnetwork/lnd/watchtower/wtclient.(*TowerClient).handleNewTower()
      /home/runner/work/lnd/lnd/watchtower/wtclient/client.go:1063 +0x23e
  github.com/lightningnetwork/lnd/watchtower/wtclient.(*TowerClient).backupDispatcher()
      /home/runner/work/lnd/lnd/watchtower/wtclient/client.go:784 +0x10b9
2020-05-14 15:39:03 -07:00
Wilmer Paulino f6f0d3819f wtclient: test case re-add removed tower 2020-05-14 13:48:08 -07:00
Wilmer Paulino b195d39ad7 rpc: use existing rpc logger for wtclientrpc
The logger string used to identify the wtclient and wtclientrpc loggers
was the same, leading to being unable to modify the log level of the
wtclient logger as it would be overwritten with the wtclientrpc's one.
To simplify things, we decide to use the existing RPC logger for
wtclientrpc.
2020-05-14 13:35:03 -07:00
Wilmer Paulino ec5c941512 wtclient: filter out inactive sessions upon adding existing/new tower 2020-05-14 13:35:02 -07:00
Wilmer Paulino 75c2ebd794 wtclient: load missing info into client sessions upon new tower
This addresses a potential panic in where we relied on this missing info
being populated.
2020-05-14 13:35:00 -07:00
Wilmer Paulino 01ab551b22 wtclient: refactor existing candidate session filtering into method 2020-05-14 13:34:59 -07:00
Wilmer Paulino 4e93d3036d Merge pull request #4282 from carlaKC/walletrpc-comments
lnrpc: remove double asterix comments
2020-05-13 10:15:23 -07:00
Wilmer Paulino c039aee059 chainregistry: increase zmq connection timeout with bitcoind backend
There seems to be a misinterpretation of a variable between the
btcwallet and gozmq libraries. When establish a ZMQ connection, it
expects a timeout, which is used to set read deadlines and determine how
long we should wait before attempting a reconnection. Within btcwallet
and lnd however, this is is interpreted as a polling duration,
explaining the current value of 100ms. Under load, especially on
less-capable hardware, this leads to high resource usage as we get into
a constant reconnection loop. To remedy this, we use a timeout of 5s
instead, which is a much more reasonable value for read timeouts, and is
also what's used for LN peers.
2020-04-28 11:15:44 -07:00
Wilmer Paulino c503b82e91 server: ignore reconnection for unadvertised inbound peers over Tor
A peer's remote address isn't known to us if we accepted the connection
over Tor, instead we know the address the onion service used to dial to
lnd. If said peer also doesn't have any advertised addresses, then we
don't have enough information to attempt a reconnect, so we avoid doing
so. Allowing the reconnection to happen isn't necessarily an issue, but
not allowing it prevents the configured SOCKS proxy from dialing to
private addresses.
2020-04-14 16:16:26 -07:00
Wilmer Paulino f48c4cae37 fundingmanager: check remote peer upfront shutdown support before reservation
This addresses a bug in which a funding reservation wasn't cleaned up
properly if the remote peer didn't support upfront shutdown.
Alternatively, we could just cancel the reservation on error, but
instead we move the check above so that we don't attempt coin selection
in the first place.
2020-04-13 11:45:02 -07:00
Wilmer Paulino 893c0cf843 rpcserver: omit uptime in ListChannels response if server not started
If the server hasn't fully started yet, it's possible that the channel
event store hasn't either, so it won't be able to consume any requests
until then. To prevent blocking, we'll just omit the uptime related
fields for now.
2020-04-10 18:31:46 -07:00
Wilmer Paulino 17ca1d78f0 rpcserver: include upfront shutdown script in ListChannels response
This field could be omitted from the response if we were unable to
calculate the channel's uptime.
2020-04-10 18:26:31 -07:00
Wilmer Paulino f6ff3131d8 lntest/itest: add change address recovery case to onchain recovery test
This is mainly motivated by a now fixed bug in the wallet in which
change addresses could at times be created outside of the default key
scopes. Recovery only used to be performed on the default key scopes, so
ideally this test case would've caught the bug earlier.
2020-04-03 15:26:19 -07:00
Wilmer Paulino 1a1e8b6dad build: update btcwallet dependency to scan/recover all key scopes 2020-04-03 15:26:18 -07:00
Wilmer Paulino d04bc200e7 Merge pull request #4144 from cfromknecht/frozen-chan-fixups
multi: frozen chan fixups
2020-04-03 11:21:22 -07:00
Wilmer Paulino 40f97e6c47 peer: send local node announcement upon establishing peer connections
We'll only do so when we have at least one confirmed advertised channel
with the remote peer. This ensures that our node announcement can
propagate throughout the network even for nodes that were offline when
we initially broadcast it.
2020-04-02 10:04:45 -07:00
Wilmer Paulino f996203883 Merge pull request #4079 from guggero/psbt-chanfunding
wallet: PSBT channel funding
2020-03-31 10:03:46 -07:00
Wilmer Paulino a8ba417dfc Merge pull request #4122 from yyforyongyu/typo_fix
trivial:typo fix and add coverage.txt to gitignore
2020-03-27 10:20:39 -07:00
Wilmer Paulino 32cfb9fdd2 Merge pull request #4117 from cilphex/docker-readme-update
Fix text in docker readme
2020-03-26 10:59:27 -07:00
Wilmer Paulino 4b8d0d913a build: bump travis bitcoind version to v0.19.1 2020-03-13 11:03:00 -07:00
Wilmer Paulino e17ad8bc84 Merge pull request #4048 from wpaulino/tor-hashed-password
server+tor: add support for Tor HASHEDPASSWORD authentication method
2020-03-10 11:12:41 -07:00
Wilmer Paulino 2dfd6a7a3e tor+server: add OnionStore to AddOnionConfig with file-based impl
In this commit, we modify the AddOnionConfig struct to include an
abstract OnionStore, which will be responsible for storing all relevant
information of an onion service. We also add a file-based implementation
of the interface to maintain the same behavior of storing an onion
service's private key in a file.
2020-03-06 17:44:29 -08:00
Wilmer Paulino 46f4da0b6b tor: move AddOnion to its own file 2020-03-06 16:01:47 -08:00
Wilmer Paulino bed485f0a9 Merge pull request #3194 from halseth/listpayments-test-on-chain-settle
[integration tests]: restart Alice after on-chain settle
2020-01-28 17:29:23 -08:00
Wilmer Paulino 57b69e3b1a discovery: check ChainHash in QueryChannelRange messages
If the provided ChainHash in a QueryChannelRange message does not match
that of our current chain, then we should send a blank response, rather
than reply with channels for the wrong chain.
2020-01-17 11:51:09 -08:00
Wilmer Paulino 9a7f66f2f7 peer: modify ReplyChannelRange log message
The message now shows the block range the reply spans, which is a lot
more useful.
2020-01-06 14:03:19 -08:00
Wilmer Paulino 1bacdfb41e discovery: interpret block range from ReplyChannelRange messages
We move from our legacy way of interpreting ReplyChannelRange messages
which was incorrect. Previously, we'd rely on the Complete field of the
ReplyChannelRange message to determine when our peer had sent all of
their replies. Now, we properly adhere to the specification by
interpreting the block ranges of these messages as intended.

Due to the large number of nodes deployed with the previous method, we
still maintain and detect when we are communicating with them, such that
we are still able to sync with them for backwards compatibility.
2020-01-06 14:03:13 -08:00
Wilmer Paulino d688e13d35 discovery: remove unnecessary test check
It's not possible to send another reply once all replies have been sent
without another request. The purpose of the check is also done within
another test, TestGossipSyncerReplyChanRangeQueryNoNewChans, so it can
be removed from here.
2020-01-06 14:02:31 -08:00
Wilmer Paulino c4723ce3db lnwire: add LastBlockHeight method to QueryChannelRange 2020-01-06 14:00:16 -08:00
Wilmer Paulino c7c0853531 discovery: cover requested range in ReplyChannelRange messages
In order to properly adhere to the spec, when handling a
QueryChannelRange message, we must reply with a series of
ReplyChannelRange messages, that when consumed together cover the
entirety of the block range requested.
2020-01-06 14:00:15 -08:00
Wilmer Paulino 1f781ea431 discovery: use inclusive range in FilterChannelRange
FilterChannelRange takes an inclusive range, so it was possible for us
to return channels for an additional block that was not requested.
2020-01-06 14:00:14 -08:00
Wilmer Paulino 9216ef2cd7 Merge pull request #3855 from cfromknecht/sorted-policies
routing/pathfind_test: construct sorted edge policies
2019-12-20 10:27:28 -08:00
Wilmer Paulino 7f3771e74f Merge pull request #3796 from carlaKC/3786-setupfrontshutdown
Add Upfront Shutdown Address to OpenChannelRequest
2019-12-18 11:28:29 -08:00
Wilmer Paulino 1fb28b6cd9 Merge pull request #3745 from akovalenko/master
lncli addholdinvoice: allow specifying msat with --amt_msat
2019-12-13 10:45:16 -08:00
Wilmer Paulino 3c6be62b18 Merge pull request #3702 from carlaKC/lnrpc-addcloseaddress
Add optional close address
2019-12-10 13:01:45 -08:00
Wilmer Paulino d01feb516f Merge pull request #3813 from ellemouton/add-space-in-log-message
bitcoindnotify: add missing space in log message in bitcoind.go
2019-12-10 12:29:05 -08:00
Wilmer Paulino 9484287f1f Merge pull request #3815 from alexbosworth/patch-13
trivial: typo fix
2019-12-10 11:14:29 -08:00
Wilmer Paulino 75dbfba4ec lntest: lower cpfp fee due to new bitcoind max fee restriction 2019-11-25 12:40:01 -08:00
Wilmer Paulino 44fa28b27b build: bump travis bitcoind version to 0.19.0.1 2019-11-25 10:59:00 -08:00
Wilmer Paulino 0c83a066e9 Merge pull request #3754 from dennisreimann/patch-1
Document setting multiple tlsextra entries
2019-11-22 10:41:22 -08:00
Wilmer Paulino 29f12411cd Merge pull request #3732 from Crypt-iQ/router_race_1115
routing: fix race condition when resuming payments
2019-11-18 11:06:18 -08:00
Wilmer Paulino 11a031c34b Merge pull request #3726 from halseth/chainntfs-test-spend-during-rescan
[test only] add TestTxNotifierSpendDuringHistoricalRescan
2019-11-14 09:38:28 -08:00
Wilmer Paulino 9587a2259f lnwallet: fix test inconsistencies to support bitcoind 0.19.0
bitcoind's sendrawtransaction API in v0.19.0 now enforces a maximum fee
rate of 0.1 BTC/kb and valid output scripts.
2019-11-12 20:34:37 -08:00
Wilmer Paulino b33a229457 build: bump btcsuite and neutrino dependencies to latest tagged versions
The btcwallet update includes some edge-case wallet bug fixes and an
optimization on ZMQ connections for bitcoind backends.

The btcd update allows for compatibility with bitcoind v0.19.0 backends.
2019-11-12 20:34:35 -08:00
Wilmer Paulino 9c454e9c6f Merge pull request #3704 from halseth/neutrino-dep-update
mod: update neutrino dep
2019-11-11 13:20:38 -08:00
Wilmer Paulino e1dd2a88e3 Merge pull request #3699 from Crypt-iQ/macaroon_store_race_1109
macaroons: add encKeyMtx to prevent race condition
2019-11-11 11:44:06 -08:00
Wilmer Paulino b0dc3b76fd Merge pull request #3661 from guggero/deprecate-rest-string
proto: deprecate duplicate string fields in requests
2019-11-07 10:52:45 -08:00
Wilmer Paulino 2bec35a3d2 Merge pull request #3687 from joostjager/wallet-binding-fix
lnwallet: fix loop binding bug
2019-11-07 10:49:18 -08:00
Wilmer Paulino 211eb4d472 Merge pull request #3518 from halseth/make-default-backend
[trivial] make: default backend variable to btcd
2019-11-05 15:42:46 -08:00
Wilmer Paulino 13b56d5849 Merge pull request #3632 from wpaulino/server-not-active-closechannel
rpcserver: ensure server has started before CloseChannel
2019-10-28 17:01:21 -04:00
Wilmer Paulino a469d5dc2c Merge pull request #2327 from ottosuess/invoice_macaroon_permissions
lnrpc: allow invoice.macaroon to read onchain transactions
2019-10-24 12:15:16 -04:00
Wilmer Paulino dd55d43520 rpcserver: ensure server has started before CloseChannel
We do this as a general sanity check to ensure channels cannot be closed
while either the backend is still syncing or the server is still
starting.
2019-10-23 17:40:38 -04:00
Wilmer Paulino 955d143c1b server+lntest: extract ErrServerNotActive error 2019-10-23 17:37:15 -04:00
Wilmer Paulino 254de64d4c Merge pull request #3533 from alrs/macaroons-test-fixes
macaroons: Test Improvements
2019-10-22 17:22:42 +02:00
Wilmer Paulino 239abded15 Merge pull request #3615 from Meshugah/patch-1
Fix Formatting of *Wrong*
2019-10-22 17:17:58 +02:00
Wilmer Paulino 0b2ef8bb4e Merge pull request #2813 from wereHamster/tor-target-ip-address
Tor option to override target IP address
2019-10-22 17:15:54 +02:00
Wilmer Paulino 73ceb9a06e Merge pull request #3603 from cryptagoras/patch-2
discovery/gossiper: fix minor typo
2019-10-15 14:21:21 +02:00