From 5e1664dc820ce2817872b7803ce2601d9a473be2 Mon Sep 17 00:00:00 2001 From: yyforyongyu Date: Tue, 9 May 2023 21:31:53 +0800 Subject: [PATCH 1/5] mod: update btcwallet's version --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index dc1139bb8..23d58a359 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,7 @@ require ( github.com/btcsuite/btcd/btcutil/psbt v1.1.8 github.com/btcsuite/btcd/chaincfg/chainhash v1.0.2 github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f - github.com/btcsuite/btcwallet v0.16.9 + github.com/btcsuite/btcwallet v0.16.10-0.20230517173256-aa62c04afcdf github.com/btcsuite/btcwallet/wallet/txauthor v1.3.2 github.com/btcsuite/btcwallet/wallet/txrules v1.2.0 github.com/btcsuite/btcwallet/walletdb v1.4.0 diff --git a/go.sum b/go.sum index 1d9141fa5..b707f0f17 100644 --- a/go.sum +++ b/go.sum @@ -89,8 +89,8 @@ github.com/btcsuite/btcd/chaincfg/chainhash v1.0.2/go.mod h1:7SFka0XMvUgj3hfZtyd github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f h1:bAs4lUbRJpnnkd9VhRV3jjAVU7DJVjMaK+IsvSeZvFo= github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f/go.mod h1:TdznJufoqS23FtqVCzL0ZqgP5MqXbb4fg/WgDys70nA= github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d/go.mod h1:+5NJ2+qvTyV9exUAL/rxXi3DcLg2Ts+ymUAY5y4NvMg= -github.com/btcsuite/btcwallet v0.16.9 h1:hLAzEJvsiSn+r6j374G7ThnrYD/toa+Lv7l1Rm6+0oM= -github.com/btcsuite/btcwallet v0.16.9/go.mod h1:T3DjEAMZYIqQ28l+ixlB6DX4mFJXCX8Pzz+yACQcLsc= +github.com/btcsuite/btcwallet v0.16.10-0.20230517173256-aa62c04afcdf h1:YRY292S4axfeDPJrZYkDq4+JaRhaPvjMueZ65evmUfc= +github.com/btcsuite/btcwallet v0.16.10-0.20230517173256-aa62c04afcdf/go.mod h1:T3DjEAMZYIqQ28l+ixlB6DX4mFJXCX8Pzz+yACQcLsc= github.com/btcsuite/btcwallet/wallet/txauthor v1.3.2 h1:etuLgGEojecsDOYTII8rYiGHjGyV5xTqsXi+ZQ715UU= github.com/btcsuite/btcwallet/wallet/txauthor v1.3.2/go.mod h1:Zpk/LOb2sKqwP2lmHjaZT9AdaKsHPSbNLm2Uql5IQ/0= github.com/btcsuite/btcwallet/wallet/txrules v1.2.0 h1:BtEN5Empw62/RVnZ0VcJaVtVlBijnLlJY+dwjAye2Bg= From 1ce7559110b9c07f2bdb74792554900d533b9c49 Mon Sep 17 00:00:00 2001 From: yyforyongyu Date: Thu, 18 May 2023 17:56:39 +0800 Subject: [PATCH 2/5] lntest+itest: clean mempool in `testHtlcTimeoutResolverExtractPreimageRemote` --- itest/lnd_multi-hop_test.go | 37 +++++++++++++++++++++++++++++++++---- lntest/harness.go | 12 +++--------- 2 files changed, 36 insertions(+), 13 deletions(-) diff --git a/itest/lnd_multi-hop_test.go b/itest/lnd_multi-hop_test.go index 61b5cf9fa..2985cc23b 100644 --- a/itest/lnd_multi-hop_test.go +++ b/itest/lnd_multi-hop_test.go @@ -1940,23 +1940,52 @@ func runExtraPreimageFromRemoteCommit(ht *lntest.HarnessTest, numBlocks = htlc.ExpirationHeight - uint32(height) - lncfg.DefaultOutgoingBroadcastDelta - // Mine empty blocks so Carol's htlc success tx stays in mempool. Once - // the height is reached, Bob's timeout resolver will resolve the htlc - // by extracing the preimage from the mempool. - ht.MineEmptyBlocks(int(numBlocks)) + // We should now have Carol's htlc suucess tx in the mempool. + numTxesMempool := 1 // For neutrino backend, the timeout resolver needs to extract the // preimage from the blocks. if ht.IsNeutrinoBackend() { // Mine a block to confirm Carol's 2nd level success tx. ht.MineBlocksAndAssertNumTxes(1, 1) + numTxesMempool-- } + // Mine empty blocks so Carol's htlc success tx stays in mempool. Once + // the height is reached, Bob's timeout resolver will resolve the htlc + // by extracing the preimage from the mempool. + ht.MineEmptyBlocks(int(numBlocks)) // Finally, check that the Alice's payment is marked as succeeded as // Bob has settled the htlc using the preimage extracted from Carol's // 2nd level success tx. ht.AssertPaymentStatus(alice, preimage, lnrpc.Payment_SUCCEEDED) + switch c { + // For non-anchor channel type, we should expect to see Bob's commit + // sweep in the mempool. + case lnrpc.CommitmentType_LEGACY: + numTxesMempool++ + + // For non-anchor channel type, we should expect to see Bob's commit + // sweep and his anchor sweep tx in the mempool. + case lnrpc.CommitmentType_ANCHORS: + numTxesMempool += 2 + + // For script-enforced leased channel, we should expect to see Bob's + // anchor sweep tx in the mempool. + case lnrpc.CommitmentType_SCRIPT_ENFORCED_LEASE: + numTxesMempool++ + + // For neutrino backend, because of the additional block mined, + // Bob's output is now mature. + if ht.IsNeutrinoBackend() { + numTxesMempool++ + } + } + + // Mine a block to clean the mempool. + ht.MineBlocksAndAssertNumTxes(1, numTxesMempool) + // NOTE: for non-standby nodes there's no need to clean up the force // close as long as the mempool is cleaned. ht.CleanShutDown() diff --git a/lntest/harness.go b/lntest/harness.go index b57471193..1c836881d 100644 --- a/lntest/harness.go +++ b/lntest/harness.go @@ -1632,18 +1632,12 @@ func (h *HarnessTest) cleanMempool() { blocks := h.Miner.MineBlocksSlow(1) bestBlock = blocks[len(blocks)-1] + // Make sure all the active nodes are synced. + h.AssertActiveNodesSyncedTo(bestBlock) + return fmt.Errorf("still have %d txes in mempool", len(mem)) }, wait.MinerMempoolTimeout) require.NoError(h, err, "timeout cleaning up mempool") - - // Exit early if the best block is nil, which means we haven't mined - // any blocks during the cleanup. - if bestBlock == nil { - return - } - - // Make sure all the active nodes are synced. - h.AssertActiveNodesSyncedTo(bestBlock) } // CleanShutDown is used to quickly end a test by shutting down all non-standby From 43b774d1e61adf8e60309dd503dbb8c2e31fa342 Mon Sep 17 00:00:00 2001 From: yyforyongyu Date: Fri, 19 May 2023 15:17:11 +0800 Subject: [PATCH 3/5] itest: make sure edges are updated in mpp tests --- itest/lnd_mpp_test.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/itest/lnd_mpp_test.go b/itest/lnd_mpp_test.go index e54da0aa4..690658208 100644 --- a/itest/lnd_mpp_test.go +++ b/itest/lnd_mpp_test.go @@ -296,6 +296,9 @@ func (m *mppTestScenario) openChannels(r *mppOpenChannelRequest) { for _, cp := range m.channelPoints { m.ht.AssertTopologyChannelOpen(hn, cp) } + + // Each node should have exactly 6 edges. + m.ht.AssertNumEdges(hn, len(m.channelPoints), false) } } From caabfb7eb4c8581a84eccbd077fd40606db298fd Mon Sep 17 00:00:00 2001 From: yyforyongyu Date: Fri, 19 May 2023 18:37:03 +0800 Subject: [PATCH 4/5] itest: cleanup channels for `testSwitchOfflineDeliveryOutgoingOffline` --- itest/lnd_switch_test.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/itest/lnd_switch_test.go b/itest/lnd_switch_test.go index fc3a6cd5b..be1992ed4 100644 --- a/itest/lnd_switch_test.go +++ b/itest/lnd_switch_test.go @@ -264,6 +264,7 @@ func testSwitchOfflineDeliveryOutgoingOffline(ht *lntest.HarnessTest) { // three channels. Note that we won't call the cleanUp function here as // we will manually stop the node Carol and her channel. s := setupScenarioFourNodes(ht) + defer s.cleanUp() // Disconnect the two intermediaries, Alice and Dave, so that when carol // restarts, the response will be held by Dave. @@ -296,7 +297,7 @@ func testSwitchOfflineDeliveryOutgoingOffline(ht *lntest.HarnessTest) { // Shutdown carol and leave her offline for the rest of the test. This // is critical, as we wish to see if Dave can propragate settles even if // the outgoing link is never revived. - ht.Shutdown(s.carol) + restartCarol := ht.SuspendNode(s.carol) // Now restart Dave, ensuring he is both persisting the settles, and is // able to reforward them to Alice after recovering from a restart. @@ -339,8 +340,8 @@ func testSwitchOfflineDeliveryOutgoingOffline(ht *lntest.HarnessTest) { amountPaid+(baseFee*numPayments)*2, int64(0), ) - ht.CloseChannel(s.alice, s.chanPointAliceBob) - ht.CloseChannel(s.dave, s.chanPointDaveAlice) + // Finally, restart Carol so the cleanup process can be finished. + require.NoError(ht, restartCarol()) } // scenarioFourNodes specifies a scenario which we have a topology that has From 4d0136af8c5b826eb1f0d8eba6f6c4ea90a21c3c Mon Sep 17 00:00:00 2001 From: yyforyongyu Date: Thu, 18 May 2023 18:47:26 +0800 Subject: [PATCH 5/5] docs: add release notes 0.16.3 --- docs/release-notes/release-notes-0.16.3.md | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 docs/release-notes/release-notes-0.16.3.md diff --git a/docs/release-notes/release-notes-0.16.3.md b/docs/release-notes/release-notes-0.16.3.md new file mode 100644 index 000000000..514dfc3cf --- /dev/null +++ b/docs/release-notes/release-notes-0.16.3.md @@ -0,0 +1,10 @@ +# Release Notes + +## Mempool + +Optimized [mempool +management](https://github.com/lightningnetwork/lnd/pull/7681) to lower the CPU +usage. + +# Contributors (Alphabetical Order) +* Yong Yu