Skip to content

itest: tolerate deferred HTLC timeout sweeps#10909

Draft
yyforyongyu wants to merge 1 commit into
lightningnetwork:masterfrom
yyforyongyu:fix-htlc-timeout-immediate-sweep
Draft

itest: tolerate deferred HTLC timeout sweeps#10909
yyforyongyu wants to merge 1 commit into
lightningnetwork:masterfrom
yyforyongyu:fix-htlc-timeout-immediate-sweep

Conversation

@yyforyongyu

@yyforyongyu yyforyongyu commented Jun 18, 2026

Copy link
Copy Markdown
Member

Change Description

The local-claim outgoing HTLC itest assumed Bob's mature timeout sweep is in the mempool immediately after the force-close block is processed. In practice, the resolver can offer the mature input after the sweeper has already processed that block, so publication can wait for the next blockbeat.

This PR updates the itest to accept both valid scheduler outcomes. If the sweep is not in the mempool yet, the test mines an empty block to trigger the next sweep round, then confirms the sweep. No production sweeper or resolver behavior changes are included.

Steps to Test

  • GOWORK=off make fmt
  • git diff --check 2a4aab892a8aa48ebdf103726562080f029b7884..HEAD
  • GOWORK=off make itest backend=bitcoind dbbackend=postgres nativesql=1 icase=multihop-local_claim_outgoing_htlc_simple_taproot_zero_conf
  • GOWORK=off make lint

Pull Request Checklist

Testing

  • Your PR passes all CI checks.
  • Tests covering the positive and negative (error paths) are included.
  • Bug fixes contain tests triggering the bug to prevent regressions.

Code Style and Documentation

  • The change is not insubstantial.
  • The change obeys the Code Documentation and Commenting guidelines, and lines wrap at 80.
  • Commits follow the Ideal Git Commit Structure.
  • Any new logging statements use an appropriate subsystem and logging level.
  • Any new lncli commands have appropriate tags in the comments for the rpc in the proto file.
  • No release note is included because this is an itest-only flake fix.

@gemini-code-assist

Copy link
Copy Markdown

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 addresses a timing issue where outgoing HTLC timeout resolvers might delay publication of sweep inputs until the next block, even when the input is already mature. By setting the 'Immediate' flag in the sweep parameters, the system ensures these deadline-sensitive transactions are published immediately upon being offered to the sweeper.

Highlights

  • Immediate HTLC Timeout Sweeps: Updated HTLC timeout resolvers to mark sweep inputs as 'Immediate', ensuring they are published as soon as they are offered, even if the sweeper has already processed the maturity block.
  • Test Suite Enhancement: Updated the mock sweeper and test cases to verify that HTLC timeout sweeps are correctly configured with the 'Immediate' flag.
New Features

🧠 You can now enable Memory (public preview) 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 the 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 counterproductive. 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.

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

Copy link
Copy Markdown

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 updates the HTLC timeout resolver to sweep inputs immediately by setting the Immediate parameter to true for both timeout transactions and direct HTLC outputs. It also updates the mock sweeper and unit tests to verify this behavior. The review feedback suggests improving code formatting by adding spacing between case stanzas in a select block in the tests, and adding a comment explaining the reasoning behind setting Immediate: true for direct HTLC outputs to ensure consistency and maintainability.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread contractcourt/commit_sweep_resolver_test.go Outdated
Comment thread contractcourt/htlc_timeout_resolver.go Outdated
Comment thread contractcourt/htlc_timeout_resolver.go Outdated
@github-actions github-actions Bot added the severity-critical Requires expert review - security/consensus critical label Jun 18, 2026
@github-actions

Copy link
Copy Markdown

🔴 PR Severity: CRITICAL

Automated classification | 2 files (excl. tests) | 15 lines changed (excl. tests)

🔴 Critical (1 file)
  • contractcourt/htlc_timeout_resolver.go - On-chain HTLC timeout dispute resolution logic (contractcourt/*)
🟢 Low (1 file)
  • docs/release-notes/release-notes-0.22.0.md - Release notes documentation
Excluded from severity count (2 files)
  • contractcourt/commit_sweep_resolver_test.go - test file
  • contractcourt/htlc_timeout_resolver_test.go - test file

Analysis

This PR modifies contractcourt/htlc_timeout_resolver.go, which is part of the contractcourt package responsible for on-chain dispute resolution and HTLC timeout handling. Changes here directly affect the state machine that resolves HTLCs on-chain when a channel is force-closed — incorrect behavior could result in loss of funds if timeout outputs are not swept correctly before expiry.

The change is small (7 additions, 2 deletions in the production file), but the contractcourt package warrants expert review given its role in fund safety. The accompanying test additions cover the modified behavior.


To override, add a severity-override-{critical,high,medium,low} label.
<!-- pr-severity-bot -->

@yyforyongyu yyforyongyu force-pushed the fix-htlc-timeout-immediate-sweep branch from f734389 to 32a67df Compare June 18, 2026 12:13
@yyforyongyu yyforyongyu added no-changelog severity-low Best-effort review and removed severity-critical Requires expert review - security/consensus critical labels Jun 18, 2026
@yyforyongyu yyforyongyu changed the title contractcourt: sweep HTLC timeouts immediately itest: tolerate deferred HTLC timeout sweeps Jun 18, 2026
@yyforyongyu yyforyongyu force-pushed the fix-htlc-timeout-immediate-sweep branch from 32a67df to 171b2b2 Compare June 18, 2026 12:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant