Skip to content

Commit b26be81

Browse files
committed
Merge branch 'v0-16-3-branch-7681' into v0-16-3-branch
2 parents fdbeb1e + 4d0136a commit b26be81

File tree

7 files changed

+56
-19
lines changed

7 files changed

+56
-19
lines changed
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Release Notes
2+
3+
## Mempool
4+
5+
Optimized [mempool
6+
management](https://github.com/lightningnetwork/lnd/pull/7681) to lower the CPU
7+
usage.
8+
9+
# Contributors (Alphabetical Order)
10+
* Yong Yu

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ require (
99
github.com/btcsuite/btcd/btcutil/psbt v1.1.8
1010
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.2
1111
github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f
12-
github.com/btcsuite/btcwallet v0.16.9
12+
github.com/btcsuite/btcwallet v0.16.10-0.20230517173256-aa62c04afcdf
1313
github.com/btcsuite/btcwallet/wallet/txauthor v1.3.2
1414
github.com/btcsuite/btcwallet/wallet/txrules v1.2.0
1515
github.com/btcsuite/btcwallet/walletdb v1.4.0

go.sum

+2-2
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ github.com/btcsuite/btcd/chaincfg/chainhash v1.0.2/go.mod h1:7SFka0XMvUgj3hfZtyd
8989
github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f h1:bAs4lUbRJpnnkd9VhRV3jjAVU7DJVjMaK+IsvSeZvFo=
9090
github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f/go.mod h1:TdznJufoqS23FtqVCzL0ZqgP5MqXbb4fg/WgDys70nA=
9191
github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d/go.mod h1:+5NJ2+qvTyV9exUAL/rxXi3DcLg2Ts+ymUAY5y4NvMg=
92-
github.com/btcsuite/btcwallet v0.16.9 h1:hLAzEJvsiSn+r6j374G7ThnrYD/toa+Lv7l1Rm6+0oM=
93-
github.com/btcsuite/btcwallet v0.16.9/go.mod h1:T3DjEAMZYIqQ28l+ixlB6DX4mFJXCX8Pzz+yACQcLsc=
92+
github.com/btcsuite/btcwallet v0.16.10-0.20230517173256-aa62c04afcdf h1:YRY292S4axfeDPJrZYkDq4+JaRhaPvjMueZ65evmUfc=
93+
github.com/btcsuite/btcwallet v0.16.10-0.20230517173256-aa62c04afcdf/go.mod h1:T3DjEAMZYIqQ28l+ixlB6DX4mFJXCX8Pzz+yACQcLsc=
9494
github.com/btcsuite/btcwallet/wallet/txauthor v1.3.2 h1:etuLgGEojecsDOYTII8rYiGHjGyV5xTqsXi+ZQ715UU=
9595
github.com/btcsuite/btcwallet/wallet/txauthor v1.3.2/go.mod h1:Zpk/LOb2sKqwP2lmHjaZT9AdaKsHPSbNLm2Uql5IQ/0=
9696
github.com/btcsuite/btcwallet/wallet/txrules v1.2.0 h1:BtEN5Empw62/RVnZ0VcJaVtVlBijnLlJY+dwjAye2Bg=

itest/lnd_mpp_test.go

+3
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,9 @@ func (m *mppTestScenario) openChannels(r *mppOpenChannelRequest) {
296296
for _, cp := range m.channelPoints {
297297
m.ht.AssertTopologyChannelOpen(hn, cp)
298298
}
299+
300+
// Each node should have exactly 6 edges.
301+
m.ht.AssertNumEdges(hn, len(m.channelPoints), false)
299302
}
300303
}
301304

itest/lnd_multi-hop_test.go

+33-4
Original file line numberDiff line numberDiff line change
@@ -1940,23 +1940,52 @@ func runExtraPreimageFromRemoteCommit(ht *lntest.HarnessTest,
19401940
numBlocks = htlc.ExpirationHeight - uint32(height) -
19411941
lncfg.DefaultOutgoingBroadcastDelta
19421942

1943-
// Mine empty blocks so Carol's htlc success tx stays in mempool. Once
1944-
// the height is reached, Bob's timeout resolver will resolve the htlc
1945-
// by extracing the preimage from the mempool.
1946-
ht.MineEmptyBlocks(int(numBlocks))
1943+
// We should now have Carol's htlc suucess tx in the mempool.
1944+
numTxesMempool := 1
19471945

19481946
// For neutrino backend, the timeout resolver needs to extract the
19491947
// preimage from the blocks.
19501948
if ht.IsNeutrinoBackend() {
19511949
// Mine a block to confirm Carol's 2nd level success tx.
19521950
ht.MineBlocksAndAssertNumTxes(1, 1)
1951+
numTxesMempool--
19531952
}
1953+
// Mine empty blocks so Carol's htlc success tx stays in mempool. Once
1954+
// the height is reached, Bob's timeout resolver will resolve the htlc
1955+
// by extracing the preimage from the mempool.
1956+
ht.MineEmptyBlocks(int(numBlocks))
19541957

19551958
// Finally, check that the Alice's payment is marked as succeeded as
19561959
// Bob has settled the htlc using the preimage extracted from Carol's
19571960
// 2nd level success tx.
19581961
ht.AssertPaymentStatus(alice, preimage, lnrpc.Payment_SUCCEEDED)
19591962

1963+
switch c {
1964+
// For non-anchor channel type, we should expect to see Bob's commit
1965+
// sweep in the mempool.
1966+
case lnrpc.CommitmentType_LEGACY:
1967+
numTxesMempool++
1968+
1969+
// For non-anchor channel type, we should expect to see Bob's commit
1970+
// sweep and his anchor sweep tx in the mempool.
1971+
case lnrpc.CommitmentType_ANCHORS:
1972+
numTxesMempool += 2
1973+
1974+
// For script-enforced leased channel, we should expect to see Bob's
1975+
// anchor sweep tx in the mempool.
1976+
case lnrpc.CommitmentType_SCRIPT_ENFORCED_LEASE:
1977+
numTxesMempool++
1978+
1979+
// For neutrino backend, because of the additional block mined,
1980+
// Bob's output is now mature.
1981+
if ht.IsNeutrinoBackend() {
1982+
numTxesMempool++
1983+
}
1984+
}
1985+
1986+
// Mine a block to clean the mempool.
1987+
ht.MineBlocksAndAssertNumTxes(1, numTxesMempool)
1988+
19601989
// NOTE: for non-standby nodes there's no need to clean up the force
19611990
// close as long as the mempool is cleaned.
19621991
ht.CleanShutDown()

itest/lnd_switch_test.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,7 @@ func testSwitchOfflineDeliveryOutgoingOffline(ht *lntest.HarnessTest) {
264264
// three channels. Note that we won't call the cleanUp function here as
265265
// we will manually stop the node Carol and her channel.
266266
s := setupScenarioFourNodes(ht)
267+
defer s.cleanUp()
267268

268269
// Disconnect the two intermediaries, Alice and Dave, so that when carol
269270
// restarts, the response will be held by Dave.
@@ -296,7 +297,7 @@ func testSwitchOfflineDeliveryOutgoingOffline(ht *lntest.HarnessTest) {
296297
// Shutdown carol and leave her offline for the rest of the test. This
297298
// is critical, as we wish to see if Dave can propragate settles even if
298299
// the outgoing link is never revived.
299-
ht.Shutdown(s.carol)
300+
restartCarol := ht.SuspendNode(s.carol)
300301

301302
// Now restart Dave, ensuring he is both persisting the settles, and is
302303
// able to reforward them to Alice after recovering from a restart.
@@ -339,8 +340,8 @@ func testSwitchOfflineDeliveryOutgoingOffline(ht *lntest.HarnessTest) {
339340
amountPaid+(baseFee*numPayments)*2, int64(0),
340341
)
341342

342-
ht.CloseChannel(s.alice, s.chanPointAliceBob)
343-
ht.CloseChannel(s.dave, s.chanPointDaveAlice)
343+
// Finally, restart Carol so the cleanup process can be finished.
344+
require.NoError(ht, restartCarol())
344345
}
345346

346347
// scenarioFourNodes specifies a scenario which we have a topology that has

lntest/harness.go

+3-9
Original file line numberDiff line numberDiff line change
@@ -1632,18 +1632,12 @@ func (h *HarnessTest) cleanMempool() {
16321632
blocks := h.Miner.MineBlocksSlow(1)
16331633
bestBlock = blocks[len(blocks)-1]
16341634

1635+
// Make sure all the active nodes are synced.
1636+
h.AssertActiveNodesSyncedTo(bestBlock)
1637+
16351638
return fmt.Errorf("still have %d txes in mempool", len(mem))
16361639
}, wait.MinerMempoolTimeout)
16371640
require.NoError(h, err, "timeout cleaning up mempool")
1638-
1639-
// Exit early if the best block is nil, which means we haven't mined
1640-
// any blocks during the cleanup.
1641-
if bestBlock == nil {
1642-
return
1643-
}
1644-
1645-
// Make sure all the active nodes are synced.
1646-
h.AssertActiveNodesSyncedTo(bestBlock)
16471641
}
16481642

16491643
// CleanShutDown is used to quickly end a test by shutting down all non-standby

0 commit comments

Comments
 (0)