@@ -112,3 +112,28 @@ func flakePaymentStreamReturnEarly() {
112
112
// commitment.
113
113
time .Sleep (2 * time .Second )
114
114
}
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
+ }
0 commit comments