Commit Graph

12036 Commits

Author SHA1 Message Date
Olaoluwa Osuntokun
d6524ea517
keychain+lnwallet: when fetching priv keys or signing try to use cache
In this commit, we start to optimistically use the new private key cache
that was added to btcwallet. As is, btcwallet will cache the decrypted
account keys for each scope in memory. However, the existing methods
to derive a child key from those account keys requires a write database
transaction, and will re-derive the private key using BIP-32 each time.

The newly added `DeriveFromKeyPathCache` lets us skip all this and
directly use a cache assuming the account info is already cached. The
new logic will try to use this method, but if it fails fall back to the
existing `DeriveFromKeyPath` method. All calls after this will use this
new cached key.

Fixes https://github.com/lightningnetwork/lnd/issues/5125.

Basic benchmark before the btcwallet change and after:
```
benchmark                    old ns/op     new ns/op     delta
BenchmarkDerivePrivKey-8     22840583      125           -100.00%

benchmark                    old allocs     new allocs     delta
BenchmarkDerivePrivKey-8     89             2              -97.75%

benchmark                    old bytes     new bytes     delta
BenchmarkDerivePrivKey-8     10225         24            -99.77%
```
2021-08-25 18:55:22 -07:00
Olaoluwa Osuntokun
2206eba91a
build: point to latest btcwallet w/ new cached privkey method 2021-08-25 18:55:19 -07:00
Olaoluwa Osuntokun
df11b0fed0
keychain: add basic benchmark for privkey derivation 2021-08-25 18:55:16 -07:00
Olaoluwa Osuntokun
8fd14bc458
docs/release-notes: add notes for new ping header in 0.14 2021-08-25 16:47:23 -07:00
Olaoluwa Osuntokun
00d275d9f0
lnrpc+rpc: expose last ping message received by peer over ListPeers resp 2021-08-25 16:47:17 -07:00
Olaoluwa Osuntokun
2947076607
peer: store the last ping payload received by a remote peer in an atomic var 2021-08-25 16:47:13 -07:00
Olaoluwa Osuntokun
4287e25494
peer: add message summaries for ping+pong 2021-08-25 16:47:10 -07:00
Olaoluwa Osuntokun
d566e51a52
peer: always send latest block header as part of ping messages
In this commit, we implement a long discussed mechanism to use the
Lightning Network as a redundant block header source. By sending our
latest block header with each ping message, we give peers another source
(outside of the Bitcoin P2P network) they can use to spot check their
chain state. Peers can also use this information to detect if they've
been eclipsed from the traditional Bitcoin P2P network itself.

As is, we only send this data in Ping messages (which are periodically
sent), in the future we could also move to send them as the partial
payload for our pong messages, and also randomize the payload size
requested as well.
2021-08-25 16:47:07 -07:00
Olaoluwa Osuntokun
0d8ffd95dd
chainntnfs/test: add new test assertion to ensure block epoch headers set 2021-08-25 16:47:04 -07:00
Olaoluwa Osuntokun
67aa7a0df7
chainntnfs/bitcoindnotify: always populate block headers for block epochs 2021-08-25 16:47:01 -07:00
Olaoluwa Osuntokun
b2cc4cf088
chainntnfs/btcdnotify: always populate block headers for block epochs 2021-08-25 16:46:59 -07:00
Olaoluwa Osuntokun
99afad1105
chainntnfs/neutrinonotify: always populate block headers for block epochs 2021-08-25 16:46:56 -07:00
Olaoluwa Osuntokun
4eac8577cd
chainntnfs: update impl independent functions to populate new block header 2021-08-25 16:46:53 -07:00
Olaoluwa Osuntokun
4fc6d15075
chainntnfs: add the current block header to the block epoch struct 2021-08-25 16:46:51 -07:00
Oliver Gugger
93d12cd9fc
Merge pull request #5643 from bottlepay/updatepolicy-nested-tx
routing/localchans: fix nested db tx
2021-08-24 17:42:39 +02:00
Oliver Gugger
ed5a3416bc
Merge pull request #5623 from yyforyongyu/update-contrib-guide
docs: explicitly set line wrap rules for error messages [skip ci]
2021-08-24 17:29:18 +02:00
Oliver Gugger
2835cebe90
Merge pull request #5659 from guggero/unit-test-race-fix
multi: fix unit test for high CPU load envs
2021-08-24 15:16:28 +02:00
Oliver Gugger
998abd1886
Merge pull request #5657 from ErikEk/releasedoc-fix
docs: release note fix
2021-08-24 14:00:45 +02:00
Joost Jager
bd07b5f49e
routing/localchans: fix nested db tx
This commit fixes a bug where a db tx is opened within another db tx.
2021-08-24 13:43:26 +02:00
Joost Jager
3f775778c3
channeldb+routing: add tx parameter
Adds an optional tx parameter to ForAllOutgoingChannels and FetchChannel
so that data can be queried within the context of an existing database
transaction.
2021-08-24 13:43:24 +02:00
Oliver Gugger
1f3a6e101d
multi: fix unit test for high CPU load envs
It seems that the GitHub CI runners share a CPU and therefore only have
very few ressources available. This causes the wallet unlocker and breach
arbiter tests to fail if we don't give them enough time to complete.
2021-08-24 13:03:21 +02:00
Oliver Gugger
23cd231483
Merge pull request #4717 from guggero/xprv-wallet-init
walletunlocker: Allow wallet to be created from extended master root key (xprv)
2021-08-24 13:01:41 +02:00
Oliver Gugger
c74c46147f
Merge pull request #5646 from yyforyongyu/fix-context-leak
itest: properly handle the creation of timeout context
2021-08-24 10:44:36 +02:00
Oliver Gugger
648374ec2a
Merge pull request #5354 from ErikEk/itest-include-btcd-backend-rotation-logs
itest: include compressed btcd backend logs from logrotate
2021-08-24 10:40:01 +02:00
Oliver Gugger
8632fc9233
docs: update release notes 2021-08-24 10:37:34 +02:00
Oliver Gugger
0822573743
itest: test wallet recovery from extended master root key
We add an additional test case to the on-chain fund recovery test that
tries restoring the same wallet from the extended master root key
instead of the seed.
2021-08-24 10:37:34 +02:00
Oliver Gugger
3fd944e7e4
lntest: allow node restore by extended root key
To allow testing restoring a node from an extended master root key, we
add an extra argument to the RestoreNodeWithSeed function.
2021-08-24 10:37:33 +02:00
Oliver Gugger
bbd5980d42
lncli: add extended master root key to create command
To allow users to restore a wallet from an existing extended master root
key, we accept one of three answers when asking for an existing seed.
2021-08-24 10:37:33 +02:00
Oliver Gugger
370d056863
lncli: extract printCipherSeedWords 2021-08-24 10:37:33 +02:00
Oliver Gugger
bdae6711af
lncli: extract askRecoveryWindow 2021-08-24 10:37:32 +02:00
Oliver Gugger
aa9435be84
lnd+walletunlocker: allow creating wallet from extended key
In addition to creating a new wallet from an aezeed, we allow specifying
an exteded master root key as the main wallet key directly.
Because an exteded key (xprv) doesn't contain any information about the
creation time of the wallet, we must assume a birthday to start scanning
the chain from (if the user doesn't provide an explicit value). Since
lnd only uses SegWit addresses, it makes sense to
choose the date that corresponds to the first mainnet block that
contained SegWit transactions.
Restoring a wallet from an extended master root key will result in a
significantly longer initial wallet rescan time if the default value is
used.
2021-08-24 10:37:32 +02:00
yyforyongyu
cb6b374b3d
docs: update release note for context leak fix 2021-08-24 12:28:40 +08:00
yyforyongyu
104b7a09db
itest: fix inheritance when creating timeout ctxt
This commit fixes the issue where a wrong context being inherited to
create a timeout context. When a parent context timed out, all its
children contexts also timed out, even the children contexts had a
larger timeout value. This means it only makes sense to inherite from a
parent when its children have smaller timeout value. Given the setup of
the itest, all the timeout contexts need to be created from a context
background(hence no timeout on the parent) unless there's an explicit
timeout bound we want to set.
2021-08-24 12:28:40 +08:00
yyforyongyu
edffd65e92
itest: manage context timeout in utils.go
This commit finishes moving the context management into utils.go.
2021-08-24 12:28:40 +08:00
yyforyongyu
a6c5255e77
itest: manage context timeout inside completePaymentRequests 2021-08-24 12:28:39 +08:00
yyforyongyu
5a94919b7e
itest: manage context timeout inside network harness
This is the last commit to refactor the context management such that all
the timeout are managed inside the network harness.
2021-08-24 12:28:35 +08:00
yyforyongyu
d9e9238b0c
itest: make WaitForTxInMempool a private method 2021-08-24 12:16:46 +08:00
yyforyongyu
16403da91e
itest: manage context in CloseChannel and AssertChannelExists 2021-08-24 12:16:46 +08:00
yyforyongyu
3e26d77f91
itest: manage context inside WaitForChannelOpen and WaitForChannelClose 2021-08-24 12:16:46 +08:00
yyforyongyu
1629858a3d
itest: manage context inside assertions - II
This commit continues moving context management into assertions.
2021-08-24 12:16:40 +08:00
yyforyongyu
02e4c3ad4c
itest: manage context inside assertions - I
This commit changes the methods assertTxLabel, assertReports,
assertSweepFound, and sendAndAssertSuccess to manage their own context
with deadline.
2021-08-24 11:17:20 +08:00
yyforyongyu
74f8fe482d
itest: manage context inside EnsureConnected 2021-08-24 11:06:44 +08:00
yyforyongyu
d10d1e3e24
itest: manage context inside SendCoins 2021-08-24 11:06:44 +08:00
yyforyongyu
8de495b96b
itest: initialize context inside ConnectNodes 2021-08-24 11:06:43 +08:00
yyforyongyu
dca20d80a7
itest: fix context leak in openChannelAndAssert
In this commit, we put the context initialization inside
openChannelAndAssert, thus saving us a few lines and making sure the
context is always properly handled.
2021-08-24 11:06:43 +08:00
ErikEk
599c221d30 docs: note fix 2021-08-24 02:23:46 +02:00
ErikEk
ca7192f8fd itest: include compressed btcd backend logs 2021-08-24 02:00:44 +02:00
Oliver Gugger
6d70468ad5
lnrpc: add extended master key to walletunlocker 2021-08-23 11:26:00 +02:00
Oliver Gugger
d329655bf6
mod: update to latest btcwallet dep 2021-08-23 11:25:39 +02:00
Olaoluwa Osuntokun
4487acc5d9 docs/release-notes: add tor hybrid mode, fix mark down headers 2021-08-22 14:08:20 -05:00