Skip to content

chainntnfs/btcdnotify: remove redundant config params re-assignment#9237

Merged
guggero merged 1 commit into
lightningnetwork:masterfrom
yyforyongyu:fix-btcdnotify-config
Oct 30, 2024
Merged

chainntnfs/btcdnotify: remove redundant config params re-assignment#9237
guggero merged 1 commit into
lightningnetwork:masterfrom
yyforyongyu:fix-btcdnotify-config

Conversation

@yyforyongyu
Copy link
Copy Markdown
Member

Fix a race case found here,

==================
WARNING: DATA RACE
Write at 0x00c000340110 by goroutine 11:
  github.com/lightningnetwork/lnd/chainntnfs/btcdnotify.New()
      /home/runner/work/lnd/lnd/chainntnfs/btcdnotify/btcd.go:135 +0xa2d
  github.com/lightningnetwork/lnd/chainntnfs/test.TestInterfaces.func3()
      /home/runner/work/lnd/lnd/chainntnfs/test/test_interface.go:1954 +0x70
  github.com/lightningnetwork/lnd/chainntnfs/test.TestInterfaces()
      /home/runner/work/lnd/lnd/chainntnfs/test/test_interface.go:2021 +0x[161](https://github.com/lightningnetwork/lnd/actions/runs/11575782146/job/32223203058?pr=8893#step:8:162)c
  github.com/lightningnetwork/lnd/chainntnfs/test/btcd_test.TestInterfaces()
      /home/runner/work/lnd/lnd/chainntnfs/test/btcd/btcd_test.go:15 +0x32
  testing.tRunner()
      /opt/hostedtoolcache/go/1.22.6/x64/src/testing/testing.go:1689 +0x21e
  testing.(*T).Run.gowrap1()
      /opt/hostedtoolcache/go/1.22.6/x64/src/testing/testing.go:1742 +0x44

Previous read at 0x00c000340110 by goroutine 454:
  github.com/btcsuite/btcd/rpcclient.(*Client).Disconnect()
      /home/runner/go/pkg/mod/github.com/btcsuite/btcd@v0.24.3-0.20240921052913-67b8efd3ba53/rpcclient/infrastructure.go:1135 +0x104
  github.com/btcsuite/btcd/rpcclient.(*Client).wsInHandler()
      /home/runner/go/pkg/mod/github.com/btcsuite/btcd@v0.24.3-0.20240921052913-67b8efd3ba53/rpcclient/infrastructure.go:484 +0x1fe
  github.com/btcsuite/btcd/rpcclient.(*Client).start.gowrap2()
      /home/runner/go/pkg/mod/github.com/btcsuite/btcd@v0.24.3-0.20240921052913-67b8efd3ba53/rpcclient/infrastructure.go:1196 +0x33

Goroutine 11 (running) created at:
  testing.(*T).Run()
      /opt/hostedtoolcache/go/1.22.6/x64/src/testing/testing.go:1742 +0x825
  testing.runTests.func1()
      /opt/hostedtoolcache/go/1.22.6/x64/src/testing/testing.go:2161 +0x85
  testing.tRunner()
      /opt/hostedtoolcache/go/1.22.6/x64/src/testing/testing.go:1689 +0x21e
  testing.runTests()
      /opt/hostedtoolcache/go/1.22.6/x64/src/testing/testing.go:2159 +0x8be
  testing.(*M).Run()
      /opt/hostedtoolcache/go/1.22.6/x64/src/testing/testing.go:2027 +0xf17
  main.main()
      _testmain.go:47 +0x2bd

Goroutine 454 (finished) created at:
  github.com/btcsuite/btcd/rpcclient.(*Client).start()
      /home/runner/go/pkg/mod/github.com/btcsuite/btcd@v0.24.3-0.20240921052913-67b8efd3ba53/rpcclient/infrastructure.go:1196 +0x2c7
  github.com/btcsuite/btcd/rpcclient.(*Client).Connect()
      /home/runner/go/pkg/mod/github.com/btcsuite/btcd@v0.24.3-0.20240921052913-67b8efd3ba53/rpcclient/infrastructure.go:1590 +0x496
  github.com/lightningnetwork/lnd/chainntnfs/btcdnotify.(*BtcdNotifier).startNotifier()
      /home/runner/work/lnd/lnd/chainntnfs/btcdnotify/btcd.go:221 +0x184
  github.com/lightningnetwork/lnd/chainntnfs/btcdnotify.(*BtcdNotifier).Start.func1()
      /home/runner/work/lnd/lnd/chainntnfs/btcdnotify/btcd.go:165 +0x37
  sync.(*Once).doSlow()
      /opt/hostedtoolcache/go/1.22.6/x64/src/sync/once.go:74 +0xf0
  sync.(*Once).Do()
      /opt/hostedtoolcache/go/1.22.6/x64/src/sync/once.go:65 +0x44
  github.com/lightningnetwork/lnd/chainntnfs/btcdnotify.(*BtcdNotifier).Start()
      /home/runner/work/lnd/lnd/chainntnfs/btcdnotify/btcd.go:[164](https://github.com/lightningnetwork/lnd/actions/runs/11575782146/job/32223203058?pr=8893#step:8:165) +0x88
  github.com/lightningnetwork/lnd/chainntnfs/test.TestInterfaces()
      /home/runner/work/lnd/lnd/chainntnfs/test/test_interface.go:1981 +0x104f
  github.com/lightningnetwork/lnd/chainntnfs/test/btcd_test.TestInterfaces()
      /home/runner/work/lnd/lnd/chainntnfs/test/btcd/btcd_test.go:15 +0x32
  testing.tRunner()
      /opt/hostedtoolcache/go/1.22.6/x64/src/testing/testing.go:[168](https://github.com/lightningnetwork/lnd/actions/runs/11575782146/job/32223203058?pr=8893#step:8:169)9 +0x21e
  testing.(*T).Run.gowrap1()
      /opt/hostedtoolcache/go/1.22.6/x64/src/testing/testing.go:1742 +0x44
==================
--- FAIL: TestInterfaces (39.96s)
    testing.go:1398: race detected during execution of test
FAIL
FAIL	github.com/lightningnetwork/lnd/chainntnfs/test/btcd	40.129s
FAIL

Turns out there is a race in the config file, and the fix is to remove the assignment in this New since it's redundant anyway,

rpcConfig := &rpcclient.ConnConfig{
Host: btcdHost,
Endpoint: "ws",
User: btcdUser,
Pass: btcdPass,
Certificates: rpcCert,
DisableTLS: false,
DisableConnectOnNew: true,
DisableAutoReconnect: false,
}
chainNotifier, err := btcdnotify.New(
rpcConfig, cfg.ActiveNetParams.Params, hintCache,
hintCache, cfg.BlockCache,
)

@yyforyongyu yyforyongyu added flake fix no-changelog size/nano trivial move, refactor, renames labels Oct 29, 2024
@yyforyongyu yyforyongyu self-assigned this Oct 29, 2024
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Oct 29, 2024

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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 using 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.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration 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 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 for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Copy Markdown
Collaborator

@ellemouton ellemouton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙏

@guggero guggero merged commit 5da2e8d into lightningnetwork:master Oct 30, 2024
@yyforyongyu yyforyongyu deleted the fix-btcdnotify-config branch October 30, 2024 14:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

flake fix no-changelog size/nano trivial move, refactor, renames

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants