Skip to content

Commit feeb9ac

Browse files
committed
itest: document flakeRaceInBitcoinClientNotifications
1 parent f030076 commit feeb9ac

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

itest/flakes.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,3 +112,28 @@ func flakePaymentStreamReturnEarly() {
112112
// commitment.
113113
time.Sleep(2 * time.Second)
114114
}
115+
116+
// flakeRaceInBitcoinClientNotifications documents a bug found that the
117+
// `ListUnspent` gives inaccurate results. In specific,
118+
// - an output is confirmed in block X, which is under the process of being
119+
// credited to our wallet.
120+
// - `ListUnspent` is called between the above process, returning an
121+
// inaccurate result, causing the sweeper to think there's no wallet utxo.
122+
// - the sweeping will fail at block X due to not enough inputs.
123+
//
124+
// Under the hood, the RPC client created for handling wallet txns and handling
125+
// block notifications are independent. For the block notification, which is
126+
// registered via `RegisterBlockEpochNtfn`, is managed by the `chainntnfs`,
127+
// which is hooked to a bitcoind client created at startup. For the wallet, it
128+
// uses another bitcoind client to receive online events. Although they share
129+
// the same bitcoind RPC conn, these two clients are acting independently.
130+
// With this setup, it means there's no coordination between the two system -
131+
// `lnwallet` and `chainntnfs` can disagree on the latest onchain state for a
132+
// short period, causing an inconsistent state which leads to the failed
133+
// sweeping attempt.
134+
//
135+
// TODO(yy): We need to adhere to the SSOT principle, and make the effort to
136+
// ensure the whole system only uses one bitcoind client.
137+
func flakeRaceInBitcoinClientNotifications(ht *lntest.HarnessTest) {
138+
ht.MineEmptyBlocks(1)
139+
}

itest/lnd_sweep_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,8 @@ func testSweepCPFPAnchorOutgoingTimeout(ht *lntest.HarnessTest) {
340340
// needed to clean up the mempool.
341341
ht.MineBlocksAndAssertNumTxes(1, 2)
342342

343+
flakeRaceInBitcoinClientNotifications(ht)
344+
343345
// The above mined block should confirm Bob's force close tx, and his
344346
// contractcourt will offer the HTLC to his sweeper. We are not testing
345347
// the HTLC sweeping behaviors so we just perform a simple check and

0 commit comments

Comments
 (0)