From 09d4660524396cffd387c7bf0a1bfdf8cf76fe03 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Thu, 6 Sep 2018 16:48:50 -0700 Subject: [PATCH 1/4] chanseries: fix panic bug by ensuring we access a non-nil edge In this commit, we fix an existing but that would cause the daemon to at times crash. Before this commit, we access the wrong edge, which would possibly actually be nil, leading to a panic. In this commit we fix this by ensuring we access the proper edge which is known to be non-nil at this point in the control flow. --- chan_series.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chan_series.go b/chan_series.go index ecc29ee2..27a1c3e6 100644 --- a/chan_series.go +++ b/chan_series.go @@ -297,7 +297,7 @@ func (c *chanSeries) FetchChanUpdates(chain chainhash.Hash, HtlcMinimumMsat: e2.MinHTLC, BaseFee: uint32(e2.FeeBaseMSat), FeeRate: uint32(e2.FeeProportionalMillionths), - ExtraOpaqueData: e1.ExtraOpaqueData, + ExtraOpaqueData: e2.ExtraOpaqueData, } chanUpdate.Signature, err = lnwire.NewSigFromRawSignature(e2.SigBytes) if err != nil { From 27ecfbbd3610b0463e889b3f1e469984f2cd21c8 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Thu, 6 Sep 2018 16:49:23 -0700 Subject: [PATCH 2/4] lntest: log the expected and last balance in WaitForBalance error case --- lntest/node.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lntest/node.go b/lntest/node.go index aa965568..8c3c5a87 100644 --- a/lntest/node.go +++ b/lntest/node.go @@ -24,6 +24,7 @@ import ( "github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/rpcclient" "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcutil" "github.com/go-errors/errors" "github.com/lightningnetwork/lnd/lnrpc" "github.com/lightningnetwork/lnd/macaroons" @@ -901,6 +902,7 @@ func (hn *HarnessNode) WaitForBalance(expectedBalance int64, confirmed bool) err ctx := context.Background() req := &lnrpc.WalletBalanceRequest{} + var lastBalance btcutil.Amount doesBalanceMatch := func() bool { balance, err := hn.WalletBalance(ctx, req) if err != nil { @@ -908,15 +910,18 @@ func (hn *HarnessNode) WaitForBalance(expectedBalance int64, confirmed bool) err } if confirmed { + lastBalance = btcutil.Amount(balance.ConfirmedBalance) return balance.ConfirmedBalance == expectedBalance } + lastBalance = btcutil.Amount(balance.UnconfirmedBalance) return balance.UnconfirmedBalance == expectedBalance } err := WaitPredicate(doesBalanceMatch, 30*time.Second) if err != nil { - return errors.New("balances not synced after deadline") + return fmt.Errorf("balances not synced after deadline: "+ + "expected %v, only have %v", expectedBalance, lastBalance) } return nil From 555b7db60267474c0b084228fc619ec0a2f985ca Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Thu, 6 Sep 2018 16:57:28 -0700 Subject: [PATCH 3/4] test: fix flake in link node garbage collection test In this commit, we fix a flake in the link node garbage collection test by ensuring the channels have been fully closed on both sides before we attempt to restart and ensure that they don't actually establish connections. Without this check, it's possible that either side hasn't yet processed all the blocks, so they'll still reconnect to each other on start up. --- lnd_test.go | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/lnd_test.go b/lnd_test.go index ad2c93ec..24079bf3 100644 --- a/lnd_test.go +++ b/lnd_test.go @@ -5715,6 +5715,47 @@ func testGarbageCollectLinkNodes(net *lntest.NetworkHarness, t *harnessTest) { t.Fatalf("unable to generate blocks: %v", err) } + // Before we test reconnection, we'll ensure that the channel has been + // fully cleaned up for both Carol and Alice. + var predErr error + pendingChansRequest := &lnrpc.PendingChannelsRequest{} + err = lntest.WaitPredicate(func() bool { + ctxt, _ = context.WithTimeout(ctxb, timeout) + pendingChanResp, err := net.Alice.PendingChannels( + ctxt, pendingChansRequest, + ) + if err != nil { + predErr = fmt.Errorf("unable to query for pending "+ + "channels: %v", err) + return false + } + + predErr = checkNumForceClosedChannels(pendingChanResp, 0) + if predErr != nil { + return false + } + + ctxt, _ = context.WithTimeout(ctxb, timeout) + pendingChanResp, err = carol.PendingChannels( + ctxt, pendingChansRequest, + ) + if err != nil { + predErr = fmt.Errorf("unable to query for pending "+ + "channels: %v", err) + return false + } + + predErr = checkNumForceClosedChannels(pendingChanResp, 0) + if predErr != nil { + return false + } + + return true + }, time.Second*15) + if err != nil { + t.Fatalf("channels not marked as fully resolved: %v", predErr) + } + testReconnection(carol) // Finally, we'll ensure that Bob and Carol no longer show in Alice's From 5aed80b5ce8617c305e7455e0074e4799ddb901c Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Thu, 6 Sep 2018 16:58:03 -0700 Subject: [PATCH 4/4] build: update to latest version of neutrino In this commit we update to the latest version of neutrino which fixes a bug in the filter header syncing logic. --- Gopkg.lock | 4 ++-- Gopkg.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Gopkg.lock b/Gopkg.lock index a4884838..3c9aa968 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -265,7 +265,7 @@ revision = "462a8a75388506b68f76661af8d649f0b88e5301" [[projects]] - digest = "1:b87ab48ac3bdfcf8d90c51f9c1a4061660dcb2e1c3c12822ccfc131f5a898578" + digest = "1:dba95a15051bdc8ff8373f9c76cf2b63945b896e4302b77e869ea9b9d0dfbee2" name = "github.com/lightninglabs/neutrino" packages = [ ".", @@ -276,7 +276,7 @@ "headerlist", ] pruneopts = "UT" - revision = "cccdda0fbb69281c17de496da88e956c300511e2" + revision = "07e32eee63e2a6f16acbc8df85c6530972015a44" [[projects]] digest = "1:58ab6d6525898cbeb86dc29a68f8e9bfe95254b9032134eb9458779574872260" diff --git a/Gopkg.toml b/Gopkg.toml index 97f781b4..021e095e 100644 --- a/Gopkg.toml +++ b/Gopkg.toml @@ -44,7 +44,7 @@ [[constraint]] name = "github.com/lightninglabs/neutrino" - revision = "cccdda0fbb69281c17de496da88e956c300511e2" + revision = "07e32eee63e2a6f16acbc8df85c6530972015a44" [[constraint]] name = "github.com/lightningnetwork/lightning-onion"