Skip to content

lntest: disable bitcoind v2 P2P transport in itests#10661

Open
ellemouton wants to merge 1 commit intolightningnetwork:masterfrom
ellemouton:worktree-itest-flake-fix
Open

lntest: disable bitcoind v2 P2P transport in itests#10661
ellemouton wants to merge 1 commit intolightningnetwork:masterfrom
ellemouton:worktree-itest-flake-fix

Conversation

@ellemouton
Copy link
Collaborator

Summary

Fixes a flaky itest (open_channel_reorg_test) caused by bitcoind v29's
v2 P2P transport handshake timing out when connecting to the btcd miner.

btcd does not support v2 P2P transport. When bitcoind (the chain backend)
connects to the btcd miner, it first attempts a v2 handshake which btcd
silently ignores. After 30 seconds, bitcoind gives up and retries with
v1, which succeeds immediately. This 30-second delay consumes the entire
DefaultTimeout for WaitForNodeBlockHeight, causing a race that
results in flaky test failures.

The unit test backend (lntest/unittest/backend.go) already disables v2
transport with -v2transport=0 for the same reason. This PR applies the
same fix to:

  • The itest chain backend (lntest/bitcoind_common.go)
  • The bitcoind miner backend (lntest/miner/bitcoind_miner.go)

Log analysis

Example failing build

The bitcoind chain backend log shows the issue clearly:

08:16:48 [net] trying v2 connection 127.0.0.1:10047 lastseen=0.0hrs
08:16:48 [net] Added connection peer=2
08:16:48 [net] send version message: version 70016, blocks=528, peer=2
08:16:48 [net] start sending v2 handshake to peer=2
           ... 30 second gap — v2 handshake hanging ...
08:17:18 [net] socket closed, disconnecting peer=2
08:17:18 [net] retrying with v1 transport protocol for peer=2
08:17:18 [net] trying v1 connection 127.0.0.1:10047 lastseen=0.0hrs
08:17:19 [net] receive version message: .../btcd:0.25.0/: blocks=533, peer=3

The v2 handshake hung for exactly 30s (08:16:48 → 08:17:18), then the v1
fallback connected instantly. Meanwhile, WaitForNodeBlockHeight started
at ~08:16:50 with a 30s timeout and expired at 08:17:20 — just 1 second
after the reorg blocks finally started flowing.

Test plan

  • go build -tags=bitcoind ./lntest/... compiles
  • go build ./lntest/miner/... compiles
  • CI itests pass (bitcoind backend)

bitcoind v29 attempts a v2 P2P handshake when connecting to the btcd
miner, but btcd doesn't support v2 transport. The handshake times out
after 30s before falling back to v1, which consumes the entire
DefaultTimeout budget and causes flakes in tests that rely on timely
block propagation after reconnecting (e.g. open_channel_reorg_test).

Add -v2transport=0 to both the itest chain backend and the bitcoind
miner backend, matching what the unit test backend already does.
@gemini-code-assist
Copy link

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request resolves a persistent flakiness in integration tests by mitigating a P2P transport incompatibility between bitcoind and btcd. By disabling bitcoind's v2 P2P transport when interacting with btcd miners, it eliminates a 30-second connection timeout that was causing test failures due to WaitForNodeBlockHeight exceeding its DefaultTimeout.

Highlights

  • Flaky Test Resolution: Addressed a flaky open_channel_reorg_test by preventing a 30-second timeout during bitcoind's v2 P2P transport handshake with btcd miners.
  • Bitcoind P2P Configuration: Configured bitcoind instances within lntest/bitcoind_common.go and lntest/miner/bitcoind_miner.go to explicitly disable v2 P2P transport using the -v2transport=0 flag.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@ellemouton ellemouton self-assigned this Mar 24, 2026
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request addresses a flaky integration test by disabling bitcoind's v2 P2P transport, which causes a 30-second handshake timeout when connecting to a btcd miner. The fix involves adding the -v2transport=0 flag to the bitcoind command arguments in the itest chain backend and the bitcoind miner backend. The changes are correct, well-commented, and consistent with existing test setups. The added comments clearly explain the reason for the change and include a TODO for future removal. The implementation is straightforward and I have no further suggestions.

Copy link
Collaborator

@bhandras bhandras left a comment

Choose a reason for hiding this comment

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

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants