Skip to content

Conversation

@guggero
Copy link
Collaborator

@guggero guggero commented Jul 8, 2025

Fixed by gemini-cli.

Attempts to fix the following flake:

--- FAIL: TestRbfCloseErr (0.00s)
    --- FAIL: TestRbfCloseErr/send_offer_restart (0.00s)
        rbf_coop_test.go:381: no dust field set, expected: no dust
        rbf_coop_test.go:617: unexpected state transition: ClosingNegotiation(local=LocalOfferSent(proposed_fee=0.00010100 BTC), remote=<nil>)
        rbf_coop_test.go:381: no dust field set, expected: no dust
    --- FAIL: TestRbfCloseErr/recv_offer_restart (0.00s)
        rbf_coop_test.go:696: unexpected state transition: ClosingNegotiation(local=<nil>, remote=ClosePending(txid=4ebd325a4b394cff8c57e8317ccf5a8d0e2bdf1b8526f8aad6c8e43d8240621a, party=Remote, fee_rate=1010 sat/vb))
--- FAIL: TestRbfCloseClosingNegotiationRemote (0.05s)
    --- FAIL: TestRbfCloseClosingNegotiationRemote/recv_offer_rbf_loop_iterations (0.00s)
        rbf_coop_test.go:696: unexpected state transition: ClosingNegotiation(local=LocalCloseStart, remote=ClosePending(txid=4ebd325a4b394cff8c57e8317ccf5a8d0e2bdf1b8526f8aad6c8e43d8240621a, party=Remote, fee_rate=1110 sat/vb))

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.

Summary of Changes

Hello @guggero, 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 addresses and fixes flaky tests within the chancloser package. The primary goal is to enhance the stability and reliability of cooperative channel closing tests, particularly those involving RBF and Taproot fast closes, by refining test logic related to transaction broadcasting and correcting assertion expectations for dust outputs.

Highlights

  • Improved Test Determinism: Refactored the TestTaprootFastClose in chancloser_test.go to use distinct broadcast channels for Alice and Bob. This change replaces a single shared broadcast signal with separate channels (aliceBroadcast and bobBroadcast), ensuring that the test correctly waits for the specific party's transaction broadcast, thereby preventing potential race conditions and improving test reliability.
  • Corrected RBF Test Assertions: Updated the rbf_coop_test.go file to correct an assertion parameter within the assertSingleRbfIteration function. The parameter passed to expectHalfSignerIteration was changed from noDustExpect to dustExpect, indicating a more accurate expectation regarding dust outputs during RBF (Replace-by-Fee) cooperative closing iterations, which resolves a source of test flakiness.
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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

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 issue 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 is currently in preview and 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 to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

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.

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 aims to fix flaky tests in the chancloser package. The changes are well-targeted and improve test stability.

In chancloser_test.go, the TestTaprootFastClose test is refactored to use two separate channels for broadcast signals from Alice and Bob, instead of a single shared channel. This is an excellent change that eliminates potential race conditions and makes the test more deterministic.

In rbf_coop_test.go, a bug in the assertSingleRbfIteration test helper is fixed. The function was previously ignoring its dustExpect parameter. This has been corrected to properly propagate the parameter, ensuring the helper function behaves as intended.

The changes are correct and improve the quality of the test suite. I have no further suggestions.

Copy link
Member

@yyforyongyu yyforyongyu 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🙏

Copy link
Member

@yyforyongyu yyforyongyu left a comment

Choose a reason for hiding this comment

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

hmm looks like we still got one more flake

Makefile Outdated
$(UNIT_BENCH)

#? unit-flake: Run the unit tests continuously until one fails
unit-flake: $(BTCD_BIN)
Copy link
Member

Choose a reason for hiding this comment

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

nit: name it flakehunter-unit-all to keep them consistent below?

@guggero
Copy link
Collaborator Author

guggero commented Jul 9, 2025

hmm looks like we still got one more flake

Yeah, whenever I think I've patched one flake, another pops up... Not sure this is easy to fix. Or I (and Gemini) are just missing something simple... Tried quite a few iterations locally.

@yyforyongyu
Copy link
Member

Yeah, whenever I think I've patched one flake, another pops up... Not sure this is easy to fix. Or I (and Gemini) are just missing something simple... Tried quite a few iterations locally.

yeah why don't we merge what we have so far and then fix it in another PR? Think as long as the number of flaky tests decreases it's still a win.

@guggero
Copy link
Collaborator Author

guggero commented Jul 15, 2025

yeah why don't we merge what we have so far and then fix it in another PR? Think as long as the number of flaky tests decreases it's still a win.

Makes sense. I pushed up one more commit that increases some of the timeouts, perhaps that also helps a bit.

Copy link
Member

@yyforyongyu yyforyongyu left a comment

Choose a reason for hiding this comment

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

Thanks for the fix! LGTM❤️

Copy link
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.

Thanks for the flake fixes!

just a few questions

guggero added 2 commits July 18, 2025 14:07
The param previously was unused so this was likely an oversight or
copy/paste error.
This does not change any behavior, as the method was always called with
the constant previously used. But it makes things more explicit.
This doesn't change the behavior but makes the use of the broadcast
channels more clear.
@guggero
Copy link
Collaborator Author

guggero commented Jul 18, 2025

Okay, after investing HUMAN debugging minutes, I actually found the flake :D

@guggero guggero requested a review from ellemouton July 18, 2025 12:08
Copy link
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.

Nice, thanks!! ✅

guggero added 6 commits July 21, 2025 13:48
These two new goals take all the usual flags like pkg=, case=, nocache= and so
on.
This fixes the actual flake: We didn't wait for next iterations to _not_
come in, so depending on timing, we could read another transition in a
second run.
But making sure we expect all transitions at the same time and then make
sure no further transitions come in makes this not depend on time.
These tests previously only worked because we didn't properly wait for
all transitions to come in. We fix them by correctly asserting the
expected number of state transitions.
Fixes another flake in the unit-race test: Sometimes we miss startup
events if there's a high CPU load (in CI for example).
To avoid that, we register our subscriber before starting the state
machine.
@guggero
Copy link
Collaborator Author

guggero commented Jul 21, 2025

Added another flake fix, this time for the race unit test. Also fixed some more formatting issues.

@guggero guggero requested a review from ellemouton July 21, 2025 12:47
Copy link
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.

🧹 🧼

Comment on lines +829 to +830
// We register our subscriber before starting the state machine, to make
// sure we don't miss any events.
Copy link
Collaborator

Choose a reason for hiding this comment

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

👍

@guggero guggero merged commit 6f09d96 into lightningnetwork:master Jul 23, 2025
26 checks passed
@guggero guggero deleted the rbf-close-err branch July 23, 2025 09:47
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.

3 participants