From 64d6d26a1c8d396d8d774dd441c581e40e00c34a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hampus=20Sj=C3=B6berg?= Date: Mon, 5 Apr 2021 13:19:30 +0200 Subject: [PATCH 1/5] build: update to latest version of neutrino This commit updates neutrino to the latest version. This is to deal with on-chain transaction issues, where in certain situations the transaction wouldn't be broadcasted. --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 2f3a853a..f2cd4829 100644 --- a/go.mod +++ b/go.mod @@ -47,7 +47,7 @@ require ( github.com/juju/utils v0.0.0-20180820210520-bf9cc5bdd62d // indirect github.com/juju/version v0.0.0-20180108022336-b64dbd566305 // indirect github.com/kkdai/bstream v0.0.0-20181106074824-b3251f7901ec - github.com/lightninglabs/neutrino v0.11.1-0.20210326011815-f363e0ee1584 + github.com/lightninglabs/neutrino v0.11.1-0.20210429202752-e6974af1494e github.com/lightninglabs/protobuf-hex-display v1.3.3-0.20191212020323-b444784ce75d github.com/lightningnetwork/lightning-onion v1.0.2-0.20200501022730-3c8c8d0b89ea github.com/lightningnetwork/lnd/cert v1.0.3 diff --git a/go.sum b/go.sum index 8e061d08..d8fc8d0d 100644 --- a/go.sum +++ b/go.sum @@ -185,8 +185,8 @@ github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/lightninglabs/gozmq v0.0.0-20191113021534-d20a764486bf h1:HZKvJUHlcXI/f/O0Avg7t8sqkPo78HFzjmeYFl6DPnc= github.com/lightninglabs/gozmq v0.0.0-20191113021534-d20a764486bf/go.mod h1:vxmQPeIQxPf6Jf9rM8R+B4rKBqLA2AjttNxkFBL2Plk= github.com/lightninglabs/neutrino v0.11.0/go.mod h1:CuhF0iuzg9Sp2HO6ZgXgayviFTn1QHdSTJlMncK80wg= -github.com/lightninglabs/neutrino v0.11.1-0.20210326011815-f363e0ee1584 h1:EDsSkmAvl2VqDV1HU7lxof1MPZEvk1DaqPUCTbRBPyc= -github.com/lightninglabs/neutrino v0.11.1-0.20210326011815-f363e0ee1584/go.mod h1:d7zCVUnGmKW1L8DIgdduiCtjEziWMbTL0XhpqQs8zVY= +github.com/lightninglabs/neutrino v0.11.1-0.20210429202752-e6974af1494e h1:bu8vT4/mXk9pX/H5Z/ZPoLYqsI/vEclAu+LafBd5MHk= +github.com/lightninglabs/neutrino v0.11.1-0.20210429202752-e6974af1494e/go.mod h1:d7zCVUnGmKW1L8DIgdduiCtjEziWMbTL0XhpqQs8zVY= github.com/lightninglabs/protobuf-hex-display v1.3.3-0.20191212020323-b444784ce75d h1:QWD/5MPnaZfUVP7P8wLa4M8Td2DI7XXHXt2vhVtUgGI= github.com/lightninglabs/protobuf-hex-display v1.3.3-0.20191212020323-b444784ce75d/go.mod h1:KDb67YMzoh4eudnzClmvs2FbiLG9vxISmLApUkCa4uI= github.com/lightningnetwork/lightning-onion v1.0.2-0.20200501022730-3c8c8d0b89ea h1:oCj48NQ8u7Vz+MmzHqt0db6mxcFZo3Ho7M5gCJauY/k= From 2084cb0ad5316263d6dbc897662a3743602090ee Mon Sep 17 00:00:00 2001 From: Wilmer Paulino Date: Wed, 28 Apr 2021 16:16:34 -0700 Subject: [PATCH 2/5] lncfg: add config options for new neutrino options --- lncfg/neutrino.go | 2 ++ lnd.go | 2 ++ sample-lnd.conf | 6 ++++++ 3 files changed, 10 insertions(+) diff --git a/lncfg/neutrino.go b/lncfg/neutrino.go index f8a84a44..999b5d73 100644 --- a/lncfg/neutrino.go +++ b/lncfg/neutrino.go @@ -15,4 +15,6 @@ type Neutrino struct { UserAgentName string `long:"useragentname" description:"Used to help identify ourselves to other bitcoin peers"` UserAgentVersion string `long:"useragentversion" description:"Used to help identify ourselves to other bitcoin peers"` ValidateChannels bool `long:"validatechannels" description:"Validate every channel in the graph during sync by downloading the containing block. This is the inverse of routing.assumechanvalid, meaning that for Neutrino the validation is turned off by default for massively increased graph sync performance. This speedup comes at the risk of using an unvalidated view of the network for routing. Overwrites the value of routing.assumechanvalid if Neutrino is used. (default: false)"` + BroadcastTimeout time.Duration `long:"broadcasttimeout" description:"The amount of time to wait before giving up on a transaction broadcast attempt."` + PersistFilters bool `long:"persistfilters" description:"Whether compact filters fetched from the P2P network should be persisted to disk."` } diff --git a/lnd.go b/lnd.go index 2559d0aa..f8e0d6e6 100644 --- a/lnd.go +++ b/lnd.go @@ -1670,6 +1670,8 @@ func initNeutrinoBackend(cfg *Config, chainDir string, }, AssertFilterHeader: headerStateAssertion, BlockCache: blockCache.Cache, + BroadcastTimeout: cfg.NeutrinoMode.BroadcastTimeout, + PersistToDisk: cfg.NeutrinoMode.PersistFilters, } neutrino.MaxPeers = 8 diff --git a/sample-lnd.conf b/sample-lnd.conf index 06158331..a9129070 100644 --- a/sample-lnd.conf +++ b/sample-lnd.conf @@ -482,6 +482,12 @@ bitcoin.node=btcd ; Used to help identify ourselves to other bitcoin peers (default: 0.11.0-beta). ; neutrino.useragentversion=0.11.0-beta +; The amount of time to wait before giving up on a transaction broadcast attempt. +; neutrino.broadcasttimeout=5s + +; Whether compact filters fetched from the P2P network should be persisted to disk. +; neutrino.persistfilters=true + ; Validate every channel in the graph during sync by downloading the containing ; block. This is the inverse of routing.assumechanvalid, meaning that for ; Neutrino the validation is turned off by default for massively increased graph From 6bb7b00a801f4d7bf6cf15607991a4956cda0f37 Mon Sep 17 00:00:00 2001 From: Wilmer Paulino Date: Wed, 28 Apr 2021 16:17:11 -0700 Subject: [PATCH 3/5] lntest: decrease broadcast timeout for neutrino-backed integration tests Since we don't have to worry about network latency within our integration tests, we can shorten the broadcast timeout for neutrino integration tests from 5s to 1s. --- lntest/neutrino.go | 1 + 1 file changed, 1 insertion(+) diff --git a/lntest/neutrino.go b/lntest/neutrino.go index fe2a2a0b..f16b3e15 100644 --- a/lntest/neutrino.go +++ b/lntest/neutrino.go @@ -27,6 +27,7 @@ func (b NeutrinoBackendConfig) GenArgs() []string { // We enable validating channels so that we can obtain the outpoint for // channels within the graph and make certain assertions based on them. args = append(args, "--neutrino.validatechannels") + args = append(args, "--neutrino.broadcasttimeout=1s") return args } From f26cfac440f25c3ad971afb4c9d8044f58edd6ef Mon Sep 17 00:00:00 2001 From: Wilmer Paulino Date: Wed, 28 Apr 2021 16:20:57 -0700 Subject: [PATCH 4/5] itest: use wait predicate for balance assertion in assertDLPExecuted This assertion would at times fail if the wallet balance hadn't been updated yet. --- lntest/itest/lnd_test.go | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/lntest/itest/lnd_test.go b/lntest/itest/lnd_test.go index 5e7dd921..3c2fa586 100644 --- a/lntest/itest/lnd_test.go +++ b/lntest/itest/lnd_test.go @@ -9705,16 +9705,24 @@ func assertDLPExecuted(net *lntest.NetworkHarness, t *harnessTest, assertNumPendingChannels(t, carol, 0, 0) // Make sure Carol got her balance back. - ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) - carolBalResp, err := carol.WalletBalance(ctxt, balReq) + err = wait.NoError(func() error { + ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) + carolBalResp, err := carol.WalletBalance(ctxt, balReq) + if err != nil { + return fmt.Errorf("unable to get carol's balance: %v", err) + } + + carolBalance := carolBalResp.ConfirmedBalance + if carolBalance <= carolStartingBalance { + return fmt.Errorf("expected carol to have balance "+ + "above %d, instead had %v", carolStartingBalance, + carolBalance) + } + + return nil + }, defaultTimeout) if err != nil { - t.Fatalf("unable to get carol's balance: %v", err) - } - carolBalance := carolBalResp.ConfirmedBalance - if carolBalance <= carolStartingBalance { - t.Fatalf("expected carol to have balance above %d, "+ - "instead had %v", carolStartingBalance, - carolBalance) + t.Fatalf(err.Error()) } assertNodeNumChannels(t, dave, 0) From c59c8d9c199fb7c8418330b84f6b52360cb950c8 Mon Sep 17 00:00:00 2001 From: Wilmer Paulino Date: Wed, 28 Apr 2021 16:25:22 -0700 Subject: [PATCH 5/5] build: increase global test timeout to 60m This doesn't affect our travis builds as much as our integration suite is ran in parellel, but it is needed when running it sequentially. --- make/testing_flags.mk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/make/testing_flags.mk b/make/testing_flags.mk index 7637d601..569e86f4 100644 --- a/make/testing_flags.mk +++ b/make/testing_flags.mk @@ -68,11 +68,11 @@ LOG_TAGS := nolog endif # If a timeout was requested, construct initialize the proper flag for the go -# test command. If not, we set 20m (up from the default 10m). +# test command. If not, we set 60m (up from the default 10m). ifneq ($(timeout),) TEST_FLAGS += -test.timeout=$(timeout) else -TEST_FLAGS += -test.timeout=40m +TEST_FLAGS += -test.timeout=60m endif GOLIST := go list -tags="$(DEV_TAGS)" -deps $(PKG)/... | grep '$(PKG)'| grep -v '/vendor/'