lightningnetwork / lnd

Lightning Network Daemon ⚡️
MIT License
7.55k stars 2.06k forks source link

Fix an error string match between different `btcd` versions #8862

Closed yyforyongyu closed 1 week ago

yyforyongyu commented 1 week ago

Here's what happened,

  1. lnd asks btcwallet to publish a tx -> calls btcd RPC
  2. an old btcd is running, and gives an error back: already have transaction ...
  3. btcwallet tries to map the error, using a method imported from new btcd/rpcclient, which matches against already have transaction in mempool ..., which is an error string returned from this new btcd
  4. the match failed

Diving deeper about how to avoid this from a design perspective,

Haven't decided whether this should be a backport suggested by @Crypt-iQ or create a 0.18.1 release?

coderabbitai[bot] commented 1 week ago

[!IMPORTANT]

Review skipped

Auto reviews are limited to specific labels.

Labels to auto review (1) * llm-review

Please 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 to false 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?

Share - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)
Tips ### Chat There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai): - Review comments: Directly reply to a review comment made by CodeRabbit. Example: - `I pushed a fix in commit .` - `Generate unit testing code for this file.` - `Open a follow-up GitHub issue for this discussion.` - Files and specific lines of code (under the "Files changed" tab): Tag `@coderabbitai` in a new review comment at the desired location with your query. Examples: - `@coderabbitai generate unit testing code for this file.` - `@coderabbitai modularize this function.` - PR comments: Tag `@coderabbitai` in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples: - `@coderabbitai generate interesting stats about this repository and render them as a table.` - `@coderabbitai show all the console.log statements in this repository.` - `@coderabbitai read src/utils.ts and generate unit testing code.` - `@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.` - `@coderabbitai help me debug CodeRabbit configuration file.` Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. ### CodeRabbit Commands (invoked as PR comments) - `@coderabbitai pause` to pause the reviews on a PR. - `@coderabbitai resume` to resume the paused reviews. - `@coderabbitai review` to trigger an incremental review. This is useful when automatic reviews are disabled for the repository. - `@coderabbitai full review` to do a full review from scratch and review all the files again. - `@coderabbitai summary` to regenerate the summary of the PR. - `@coderabbitai resolve` resolve all the CodeRabbit review comments. - `@coderabbitai configuration` to show the current CodeRabbit configuration for the repository. - `@coderabbitai help` to get help. Additionally, you can add `@coderabbitai ignore` anywhere in the PR description to prevent this PR from being reviewed. ### CodeRabbit Configration File (`.coderabbit.yaml`) - You can programmatically configure CodeRabbit by adding a `.coderabbit.yaml` file to the root of your repository. - Please see the [configuration documentation](https://docs.coderabbit.ai/guides/configure-coderabbit) for more information. - If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: `# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json` ### Documentation and Community - Visit our [Documentation](https://coderabbit.ai/docs) for detailed information on how to use CodeRabbit. - Join our [Discord Community](https://discord.com/invite/GsXnASn26c) to get help, request features, and share feedback. - Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.
Crypt-iQ commented 1 week ago

v0.18.1 release, looked it up and backports are for older versions than latest, so like v0.17.6 or something

yyforyongyu commented 1 week ago

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