From 3b250b294c680275e36fdff0df25a537757f3666 Mon Sep 17 00:00:00 2001 From: yyforyongyu Date: Tue, 2 Aug 2022 17:19:01 +0800 Subject: [PATCH] rpcserver+lntemp: add more error logs to `PendingChannels` This commit adds error logs to `PendingChannels` and changes how we assert the num of pending force close channels, see the docs for more info. --- lntemp/harness_assertion.go | 19 ++++++++++++++++++- rpcserver.go | 6 ++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/lntemp/harness_assertion.go b/lntemp/harness_assertion.go index 289186adb..8898374ef 100644 --- a/lntemp/harness_assertion.go +++ b/lntemp/harness_assertion.go @@ -435,7 +435,24 @@ func (h *HarnessTest) AssertNumPendingForceClose(hn *node.HarnessNode, oldForce := hn.State.CloseChannel.PendingForceClose err := wait.NoError(func() error { - resp := hn.RPC.PendingChannels() + // TODO(yy): we should be able to use `hn.RPC.PendingChannels` + // here to avoid checking the RPC error. However, we may get a + // `unable to find arbitrator` error from the rpc point, due to + // a timing issue in rpcserver, + // 1. `r.server.chanStateDB.FetchClosedChannels` fetches + // the pending force close channel. + // 2. `r.arbitratorPopulateForceCloseResp` relies on the + // channel arbitrator to get the report, and, + // 3. the arbitrator may be deleted due to the force close + // channel being resolved. + // Somewhere along the line is missing a lock to keep the data + // consistent. + req := &lnrpc.PendingChannelsRequest{} + resp, err := hn.RPC.LN.PendingChannels(h.runCtx, req) + if err != nil { + return fmt.Errorf("PendingChannels got: %w", err) + } + channels = resp.PendingForceClosingChannels total := len(channels) diff --git a/rpcserver.go b/rpcserver.go index 4b7d490b0..536439feb 100644 --- a/rpcserver.go +++ b/rpcserver.go @@ -3479,6 +3479,9 @@ func (r *rpcServer) fetchPendingForceCloseChannels() (pendingForceClose, &chanPoint, currentHeight, forceClose, ) if err != nil { + rpcsLog.Errorf("unable to populate nursery "+ + "force close resp:%s, %v", + chanPoint, err) return nil, 0, err } @@ -3486,6 +3489,9 @@ func (r *rpcServer) fetchPendingForceCloseChannels() (pendingForceClose, &chanPoint, currentHeight, forceClose, ) if err != nil { + rpcsLog.Errorf("unable to populate arbitrator "+ + "force close resp:%s, %v", + chanPoint, err) return nil, 0, err }