Merge pull request #3924 from guggero/itest-scrypt
itest: use fast scrypt options for aezeed, macaroons DB and wallet DB
This commit is contained in:
commit
d9bcd711d7
13
aezeed/cipherseed_rpctest.go
Normal file
13
aezeed/cipherseed_rpctest.go
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
// +build rpctest
|
||||||
|
|
||||||
|
package aezeed
|
||||||
|
|
||||||
|
import "github.com/btcsuite/btcwallet/waddrmgr"
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
// For the purposes of our itest, we'll crank down the scrypt params a
|
||||||
|
// bit.
|
||||||
|
scryptN = waddrmgr.FastScryptOptions.N
|
||||||
|
scryptR = waddrmgr.FastScryptOptions.R
|
||||||
|
scryptP = waddrmgr.FastScryptOptions.P
|
||||||
|
}
|
2
go.mod
2
go.mod
@ -8,7 +8,7 @@ require (
|
|||||||
github.com/btcsuite/btcd v0.20.1-beta
|
github.com/btcsuite/btcd v0.20.1-beta
|
||||||
github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f
|
github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f
|
||||||
github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d
|
github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d
|
||||||
github.com/btcsuite/btcwallet v0.11.1-0.20200219004649-ae9416ad7623
|
github.com/btcsuite/btcwallet v0.11.1-0.20200323235326-015c045a3bb7
|
||||||
github.com/btcsuite/btcwallet/wallet/txauthor v1.0.0
|
github.com/btcsuite/btcwallet/wallet/txauthor v1.0.0
|
||||||
github.com/btcsuite/btcwallet/wallet/txrules v1.0.0
|
github.com/btcsuite/btcwallet/wallet/txrules v1.0.0
|
||||||
github.com/btcsuite/btcwallet/walletdb v1.2.0
|
github.com/btcsuite/btcwallet/walletdb v1.2.0
|
||||||
|
4
go.sum
4
go.sum
@ -26,8 +26,8 @@ github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f h1:bAs4lUbRJpnnkd9
|
|||||||
github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f/go.mod h1:TdznJufoqS23FtqVCzL0ZqgP5MqXbb4fg/WgDys70nA=
|
github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f/go.mod h1:TdznJufoqS23FtqVCzL0ZqgP5MqXbb4fg/WgDys70nA=
|
||||||
github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d h1:yJzD/yFppdVCf6ApMkVy8cUxV0XrxdP9rVf6D87/Mng=
|
github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d h1:yJzD/yFppdVCf6ApMkVy8cUxV0XrxdP9rVf6D87/Mng=
|
||||||
github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d/go.mod h1:+5NJ2+qvTyV9exUAL/rxXi3DcLg2Ts+ymUAY5y4NvMg=
|
github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d/go.mod h1:+5NJ2+qvTyV9exUAL/rxXi3DcLg2Ts+ymUAY5y4NvMg=
|
||||||
github.com/btcsuite/btcwallet v0.11.1-0.20200219004649-ae9416ad7623 h1:ZuJRjucNsTmlrbZncsqzD0z3EaXrOobCx2I4lc12R4g=
|
github.com/btcsuite/btcwallet v0.11.1-0.20200323235326-015c045a3bb7 h1:ubYJYIi13atgwPCX7FZQZV2mytkaRHWPycDFdF28U0o=
|
||||||
github.com/btcsuite/btcwallet v0.11.1-0.20200219004649-ae9416ad7623/go.mod h1:1O1uRHMPXHdwA4/od8nqYqrgclVKp+wtfXUAqHmeRvE=
|
github.com/btcsuite/btcwallet v0.11.1-0.20200323235326-015c045a3bb7/go.mod h1:1O1uRHMPXHdwA4/od8nqYqrgclVKp+wtfXUAqHmeRvE=
|
||||||
github.com/btcsuite/btcwallet/wallet/txauthor v1.0.0 h1:KGHMW5sd7yDdDMkCZ/JpP0KltolFsQcB973brBnfj4c=
|
github.com/btcsuite/btcwallet/wallet/txauthor v1.0.0 h1:KGHMW5sd7yDdDMkCZ/JpP0KltolFsQcB973brBnfj4c=
|
||||||
github.com/btcsuite/btcwallet/wallet/txauthor v1.0.0/go.mod h1:VufDts7bd/zs3GV13f/lXc/0lXrPnvxD/NvmpG/FEKU=
|
github.com/btcsuite/btcwallet/wallet/txauthor v1.0.0/go.mod h1:VufDts7bd/zs3GV13f/lXc/0lXrPnvxD/NvmpG/FEKU=
|
||||||
github.com/btcsuite/btcwallet/wallet/txrules v1.0.0 h1:2VsfS0sBedcM5KmDzRMT3+b6xobqWveZGvjb+jFez5w=
|
github.com/btcsuite/btcwallet/wallet/txrules v1.0.0 h1:2VsfS0sBedcM5KmDzRMT3+b6xobqWveZGvjb+jFez5w=
|
||||||
|
@ -627,7 +627,7 @@ func (l *channelLink) syncChanStates() error {
|
|||||||
|
|
||||||
if err := l.cfg.Peer.SendMessage(true, localChanSyncMsg); err != nil {
|
if err := l.cfg.Peer.SendMessage(true, localChanSyncMsg); err != nil {
|
||||||
return fmt.Errorf("Unable to send chan sync message for "+
|
return fmt.Errorf("Unable to send chan sync message for "+
|
||||||
"ChannelPoint(%v)", l.channel.ChannelPoint())
|
"ChannelPoint(%v): %v", l.channel.ChannelPoint(), err)
|
||||||
}
|
}
|
||||||
|
|
||||||
var msgsToReSend []lnwire.Message
|
var msgsToReSend []lnwire.Message
|
||||||
@ -3121,7 +3121,7 @@ func (l *channelLink) fail(linkErr LinkFailureError,
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
l.log.Errorf("failing link: %s", reason)
|
l.log.Errorf("failing link: %s with error: %v", reason, linkErr)
|
||||||
|
|
||||||
// Set failed, such that we won't process any more updates, and notify
|
// Set failed, such that we won't process any more updates, and notify
|
||||||
// the peer about the failure.
|
// the peer about the failure.
|
||||||
|
@ -7328,10 +7328,12 @@ func testRevokedCloseRetribution(net *lntest.NetworkHarness, t *harnessTest) {
|
|||||||
|
|
||||||
// Carol will be the breached party. We set --nolisten to ensure Bob
|
// Carol will be the breached party. We set --nolisten to ensure Bob
|
||||||
// won't be able to connect to her and trigger the channel data
|
// won't be able to connect to her and trigger the channel data
|
||||||
// protection logic automatically.
|
// protection logic automatically. We also can't have Carol
|
||||||
|
// automatically re-connect too early, otherwise DLP would be initiated
|
||||||
|
// instead of the breach we want to provoke.
|
||||||
carol, err := net.NewNode(
|
carol, err := net.NewNode(
|
||||||
"Carol",
|
"Carol",
|
||||||
[]string{"--hodl.exit-settle", "--nolisten"},
|
[]string{"--hodl.exit-settle", "--nolisten", "--minbackoff=1h"},
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unable to create new carol node: %v", err)
|
t.Fatalf("unable to create new carol node: %v", err)
|
||||||
@ -7591,10 +7593,12 @@ func testRevokedCloseRetributionZeroValueRemoteOutput(net *lntest.NetworkHarness
|
|||||||
|
|
||||||
// Dave will be the breached party. We set --nolisten to ensure Carol
|
// Dave will be the breached party. We set --nolisten to ensure Carol
|
||||||
// won't be able to connect to him and trigger the channel data
|
// won't be able to connect to him and trigger the channel data
|
||||||
// protection logic automatically.
|
// protection logic automatically. We also can't have Dave automatically
|
||||||
|
// re-connect too early, otherwise DLP would be initiated instead of the
|
||||||
|
// breach we want to provoke.
|
||||||
dave, err := net.NewNode(
|
dave, err := net.NewNode(
|
||||||
"Dave",
|
"Dave",
|
||||||
[]string{"--hodl.exit-settle", "--nolisten"},
|
[]string{"--hodl.exit-settle", "--nolisten", "--minbackoff=1h"},
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unable to create new node: %v", err)
|
t.Fatalf("unable to create new node: %v", err)
|
||||||
@ -8658,15 +8662,23 @@ func assertDLPExecuted(net *lntest.NetworkHarness, t *harnessTest,
|
|||||||
dave *lntest.HarnessNode, daveStartingBalance int64,
|
dave *lntest.HarnessNode, daveStartingBalance int64,
|
||||||
anchors bool) {
|
anchors bool) {
|
||||||
|
|
||||||
|
// We disabled auto-reconnect for some tests to avoid timing issues.
|
||||||
|
// To make sure the nodes are initiating DLP now, we have to manually
|
||||||
|
// re-connect them.
|
||||||
|
ctxb := context.Background()
|
||||||
|
err := net.ConnectNodes(ctxb, carol, dave)
|
||||||
|
if err != nil && !strings.Contains(err.Error(), "already connected") {
|
||||||
|
t.Fatalf("unable to connect Carol to Dave to initiate DLP: %v",
|
||||||
|
err)
|
||||||
|
}
|
||||||
|
|
||||||
// Upon reconnection, the nodes should detect that Dave is out of sync.
|
// Upon reconnection, the nodes should detect that Dave is out of sync.
|
||||||
// Carol should force close the channel using her latest commitment.
|
// Carol should force close the channel using her latest commitment.
|
||||||
expectedTxes := 1
|
expectedTxes := 1
|
||||||
if anchors {
|
if anchors {
|
||||||
expectedTxes = 2
|
expectedTxes = 2
|
||||||
}
|
}
|
||||||
|
_, err = waitForNTxsInMempool(
|
||||||
ctxb := context.Background()
|
|
||||||
_, err := waitForNTxsInMempool(
|
|
||||||
net.Miner.Node, expectedTxes, minerMempoolTimeout,
|
net.Miner.Node, expectedTxes, minerMempoolTimeout,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -8777,8 +8789,12 @@ func testDataLossProtection(net *lntest.NetworkHarness, t *harnessTest) {
|
|||||||
|
|
||||||
// Carol will be the up-to-date party. We set --nolisten to ensure Dave
|
// Carol will be the up-to-date party. We set --nolisten to ensure Dave
|
||||||
// won't be able to connect to her and trigger the channel data
|
// won't be able to connect to her and trigger the channel data
|
||||||
// protection logic automatically.
|
// protection logic automatically. We also can't have Carol
|
||||||
carol, err := net.NewNode("Carol", []string{"--nolisten"})
|
// automatically re-connect too early, otherwise DLP would be initiated
|
||||||
|
// at the wrong moment.
|
||||||
|
carol, err := net.NewNode(
|
||||||
|
"Carol", []string{"--nolisten", "--minbackoff=1h"},
|
||||||
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unable to create new carol node: %v", err)
|
t.Fatalf("unable to create new carol node: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -23,5 +23,5 @@ const (
|
|||||||
|
|
||||||
// AsyncBenchmarkTimeout is the timeout used when running the async
|
// AsyncBenchmarkTimeout is the timeout used when running the async
|
||||||
// payments benchmark.
|
// payments benchmark.
|
||||||
AsyncBenchmarkTimeout = time.Minute
|
AsyncBenchmarkTimeout = 2 * time.Minute
|
||||||
)
|
)
|
||||||
|
23
lnwallet/btcwallet/btcwallet_rpctest.go
Normal file
23
lnwallet/btcwallet/btcwallet_rpctest.go
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
// +build rpctest
|
||||||
|
|
||||||
|
package btcwallet
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/btcsuite/btcwallet/snacl"
|
||||||
|
"github.com/btcsuite/btcwallet/waddrmgr"
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
// Instruct waddrmgr to use the cranked down scrypt parameters when
|
||||||
|
// creating new wallet encryption keys. This will speed up the itests
|
||||||
|
// considerably.
|
||||||
|
fastScrypt := waddrmgr.FastScryptOptions
|
||||||
|
keyGen := func(passphrase *[]byte, config *waddrmgr.ScryptOptions) (
|
||||||
|
*snacl.SecretKey, error) {
|
||||||
|
|
||||||
|
return snacl.NewSecretKey(
|
||||||
|
passphrase, fastScrypt.N, fastScrypt.R, fastScrypt.P,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
waddrmgr.SetSecretKeyGen(keyGen)
|
||||||
|
}
|
13
macaroons/security.go
Normal file
13
macaroons/security.go
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
// +build !rpctest
|
||||||
|
|
||||||
|
package macaroons
|
||||||
|
|
||||||
|
import "github.com/btcsuite/btcwallet/snacl"
|
||||||
|
|
||||||
|
var (
|
||||||
|
// Below are the default scrypt parameters that are used when creating
|
||||||
|
// the encryption key for the macaroon database with snacl.NewSecretKey.
|
||||||
|
scryptN = snacl.DefaultN
|
||||||
|
scryptR = snacl.DefaultR
|
||||||
|
scryptP = snacl.DefaultP
|
||||||
|
)
|
14
macaroons/security_rpctest.go
Normal file
14
macaroons/security_rpctest.go
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
// +build rpctest
|
||||||
|
|
||||||
|
package macaroons
|
||||||
|
|
||||||
|
import "github.com/btcsuite/btcwallet/waddrmgr"
|
||||||
|
|
||||||
|
var (
|
||||||
|
// Below are the reduced scrypt parameters that are used when creating
|
||||||
|
// the encryption key for the macaroon database with snacl.NewSecretKey.
|
||||||
|
// We use very low values for our itest/rpctest to speed things up.
|
||||||
|
scryptN = waddrmgr.FastScryptOptions.N
|
||||||
|
scryptR = waddrmgr.FastScryptOptions.R
|
||||||
|
scryptP = waddrmgr.FastScryptOptions.P
|
||||||
|
)
|
12
macaroons/security_test.go
Normal file
12
macaroons/security_test.go
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
package macaroons
|
||||||
|
|
||||||
|
import "github.com/btcsuite/btcwallet/waddrmgr"
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
// Below are the reduced scrypt parameters that are used when creating
|
||||||
|
// the encryption key for the macaroon database with snacl.NewSecretKey.
|
||||||
|
// We use very low values for our itest/rpctest to speed things up.
|
||||||
|
scryptN = waddrmgr.FastScryptOptions.N
|
||||||
|
scryptR = waddrmgr.FastScryptOptions.R
|
||||||
|
scryptP = waddrmgr.FastScryptOptions.P
|
||||||
|
}
|
@ -106,8 +106,9 @@ func (r *RootKeyStorage) CreateUnlock(password *[]byte) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// We haven't yet stored a key, so create a new one.
|
// We haven't yet stored a key, so create a new one.
|
||||||
encKey, err := snacl.NewSecretKey(password, snacl.DefaultN,
|
encKey, err := snacl.NewSecretKey(
|
||||||
snacl.DefaultR, snacl.DefaultP)
|
password, scryptN, scryptR, scryptP,
|
||||||
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user