Skip to content

Conversation

@doitian
Copy link
Member

@doitian doitian commented Nov 11, 2025

  • Define payment and invoice events to be sent to CCH for both fiber and
    lnd.
  • These events can be emitted from fiber store changes in a later PR.
  • Extract lnd trackers into its own module.
  • Limit concurrent lnd invoice trackers to 5, scheduling them at
    5-minute intervals using a round-robin strategy.

Actions:

  • Fix Failed to spawn test actor: ActorAlreadyRegistered("test_lnd_tracker")

@doitian
Copy link
Member Author

doitian commented Nov 11, 2025

This PR can simplify the task in #944 that uses store change event to monitor invoices and payments changes.

@doitian doitian force-pushed the feature/refactor-cch-lnd-trackers branch 2 times, most recently from 2fb5370 to b551c25 Compare November 11, 2025 03:39
@doitian doitian requested a review from Copilot November 11, 2025 03:42
Copilot finished reviewing on behalf of doitian November 11, 2025 03:43
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors LND payment and invoice tracking by extracting the functionality into a dedicated actor module and introducing a unified event-based architecture for handling payment status changes.

Key Changes:

  • Introduced CchIncomingEvent enum to represent payment and invoice status changes for both Fiber and LND
  • Extracted LND tracking logic from CchActor into a dedicated LndTrackerActor with concurrency control (max 5 concurrent invoice trackers)
  • Implemented timeout-based re-queuing for invoice trackers (5-minute timeout)

Reviewed Changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
crates/fiber-lib/src/cch/trackers/mod.rs New module definition for LND trackers
crates/fiber-lib/src/cch/trackers/lnd_trackers.rs Core implementation of LndTrackerActor with queue management and timeout logic
crates/fiber-lib/src/cch/tests/lnd_trackers_tests.rs Unit tests for tracker queue and timeout behavior
crates/fiber-lib/src/cch/events.rs Defines event types and status enums for payment/invoice tracking
crates/fiber-lib/src/cch/actor.rs Refactored to use LndTrackerActor and event-based handling
crates/fiber-lib/src/cch/order.rs Removed direct LND status conversions (moved to events module)
crates/fiber-lib/src/cch/error.rs Updated error message for clarity
crates/fiber-lib/src/cch/mod.rs Updated exports for new modules

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@doitian doitian force-pushed the feature/refactor-cch-lnd-trackers branch from 2fc0bb1 to 60fcff8 Compare November 11, 2025 03:48
@doitian doitian force-pushed the feature/refactor-cch-lnd-trackers branch from 60fcff8 to 2b4f39e Compare November 13, 2025 00:47
@doitian doitian mentioned this pull request Nov 13, 2025
7 tasks
@doitian doitian force-pushed the feature/refactor-cch-lnd-trackers branch 2 times, most recently from 79f39b4 to 7ae0df4 Compare November 13, 2025 02:56
@codecov-commenter
Copy link

codecov-commenter commented Nov 13, 2025

Codecov Report

❌ Patch coverage is 0% with 301 lines in your changes missing coverage. Please review.
✅ Project coverage is 0.00%. Comparing base (0a887a6) to head (edbd824).

Files with missing lines Patch % Lines
crates/fiber-lib/src/cch/trackers/lnd_trackers.rs 0.00% 190 Missing ⚠️
crates/fiber-lib/src/cch/actor.rs 0.00% 83 Missing ⚠️
crates/fiber-lib/src/cch/events.rs 0.00% 28 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #948    +/-   ##
========================================
  Coverage     0.00%   0.00%            
========================================
  Files           61      63     +2     
  Lines        38210   38314   +104     
========================================
- Misses       38210   38314   +104     
Flag Coverage Δ
unittests 0.00% <0.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@doitian doitian force-pushed the feature/refactor-cch-lnd-trackers branch from 8e078d0 to e2b7c82 Compare November 13, 2025 04:13
@doitian doitian requested a review from chenyukang November 13, 2025 04:32
@doitian doitian force-pushed the feature/refactor-cch-lnd-trackers branch from 34e526d to 07ebe6a Compare November 13, 2025 04:41
- Define payment and invoice events to be sent to CCH for both fiber and
  lnd.
- These events can be emitted from fiber store changes in a later PR.
- Extract lnd trackers into its own module.
- Limit concurrent lnd invoice trackers to 5, scheduling them at
  5-minute intervals using a round-robin strategy.
Add gauges to monitor the LND tracker's internal state for better observability.

- Track invoice queue length to monitor backlog size
- Monitor count of active invoice trackers for capacity awareness
- Conditionally compile metrics behind "metrics" feature flag
@doitian doitian force-pushed the feature/refactor-cch-lnd-trackers branch from 0a03d7f to 11de423 Compare November 28, 2025 11:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[cch] Calling receive_btc multiple times in a fiber will cause the fiber to keep connecting to lnd until an error occurs: "Too many open files".

3 participants