Closed yyforyongyu closed 1 week ago
[!IMPORTANT]
Review skipped
Auto reviews are limited to specific labels.
Labels to auto review (1)
* llm-reviewPlease check the settings in the CodeRabbit UI or the
.coderabbit.yaml
file in this repository. To trigger a single review, invoke the@coderabbitai review
command.You can disable this status message by setting the
reviews.review_status
tofalse
in the CodeRabbit configuration file.
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?
v0.18.1 release, looked it up and backports are for older versions than latest, so like v0.17.6 or something
Tested locally by pointing this line to btcd v0.24.0
,
https://github.com/lightningnetwork/lnd/blob/6b64703db428a20d075a8eb5e0965b7e076c4267/Makefile#L113
Without this patch,
2024-06-26 01:36:48.461 [INF] LNWL: aeac04fe635c365820b85eba14dbfcce963efe2a314b2ab9d494ad66799aaa21: broadcast failed because of: undefined: -26: TX rejected: already have transaction aeac04fe635c365820b85eba14dbfcce963efe2a314b2ab9d494ad66799aaa21
2024-06-26 01:36:48.471 [ERR] FNDG: Unable to broadcast funding tx 02000000000101006c7c9697e610eb0ecc9dc7fa02985e409cb6f7ce8ba8a1341f06ce998934d000000000000000000002a086010000000000220020fd0af6a0a92651744f2a979dbd0a3143bc98754db9ddfd19a0df2bfe334c5206333af40500000000225120ddbafe4263de72752432fac6de787e08f304beba9256f6e75005c062375383c602483045022100b61e48e101bfb45d2c424085421c51effc7d7e733ed30c334199b9fab7f4d0de02200dc534bdc9a3ba8aeaae13e8fbd97baa8754beca17ddf77cddac1a00df32dd66012102406ee24555a9562c978e097c9fca6b9ba73f62acca950ee55ca4e0099557f15700000000 for ChannelPoint(aeac04fe635c365820b85eba14dbfcce963efe2a314b2ab9d494ad66799aaa21:0): undefined: -26: TX rejected: already have transaction aeac04fe635c365820b85eba14dbfcce963efe2a314b2ab9d494ad66799aaa21
With this patch, the error is caught and handled,
2024-06-26 01:31:39.448 [INF] LNWL: e5ef91a10d899ee66634401022354bfa63b06c406a1c2386defe4da8d467b277: tx already in mempool
Here's what happened,
lnd
asksbtcwallet
to publish a tx -> callsbtcd
RPCbtcd
is running, and gives an error back:already have transaction ...
btcwallet
tries to map the error, using a method imported from newbtcd/rpcclient
, which matches againstalready have transaction in mempool ...
, which is an error string returned from this newbtcd
Diving deeper about how to avoid this from a design perspective,
remove the broadcaster, which is designed for
neutrino
backend, and replace it with a mempool rebroadcaster - today we always broadcast twice for each tx, and rebroadcast it in every new block - this is unnecessary or not enough as the tx may fall out of the mempool during the 10min. I think a better approach is to poll the mempool for this published tx, and rebroadcast it only if it falls out of the mempool.move the multi-chain rpc handling from
btcd
tobtcwallet
, in specific, thebtcd/rpcclient
package is more suitable to be placed inbtcwallet
, which imo is the root cause of this bug,btcwallet
imports a newer version ofbtcd
to use thebtcd/rpcclient
package, while the runningbtcd
is in an older version. The RPC related to handling different chain backends should be moved into thebtcwallet
for clarity.Haven't decided whether this should be a backport suggested by @Crypt-iQ or create a 0.18.1 release?