Skip to content

Conversation

@doitian
Copy link
Member

@doitian doitian commented Nov 13, 2025

  • When an invoice state changes in Fiber (settled, failed, expired), the CCH order tracking system automatically detects and synchronizes the state without manual polling or intervention.
  • When an outgoing payment state changes in Fiber (succeeded, failed, pending), the CCH order tracking system automatically detects and synchronizes the state without requiring manual status checks.
  • CCH monitors invoice for the incoming payment. When CCH has received the incoming payment, it will send the outgoing payment to get the preimage.
  • CCH monitors outgoing payment to get the preimage and use the obtained preimage the settle the incoming payment.

This PR will deprecate #615, which has been refactored and split into

Actions:

  • Fix e2e test cross-chain-hub

@doitian doitian force-pushed the feature/cch-monitor-store-changes branch from ddc60c0 to c589196 Compare November 13, 2025 00:48
@doitian doitian marked this pull request as draft November 13, 2025 00:52
@doitian doitian force-pushed the feature/cch-monitor-store-changes branch from c589196 to abf7623 Compare November 13, 2025 00:53
@doitian doitian mentioned this pull request Nov 13, 2025
9 tasks
@doitian doitian force-pushed the feature/cch-monitor-store-changes branch 6 times, most recently from 1e9163b to 77713af Compare November 13, 2025 05:57
@codecov-commenter
Copy link

Codecov Report

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

Files with missing lines Patch % Lines
crates/fiber-lib/src/cch/trackers/lnd_trackers.rs 0.00% 186 Missing ⚠️
crates/fiber-lib/src/cch/actor.rs 0.00% 121 Missing ⚠️
...rates/fiber-lib/src/cch/trackers/fiber_trackers.rs 0.00% 70 Missing ⚠️
crates/fiber-lib/src/cch/events.rs 0.00% 28 Missing ⚠️
crates/fiber-lib/src/cch/order.rs 0.00% 16 Missing ⚠️
crates/fiber-lib/src/store/store_impl/native.rs 0.00% 9 Missing ⚠️
crates/fiber-bin/src/main.rs 0.00% 8 Missing ⚠️
crates/fiber-lib/src/fiber/network.rs 0.00% 2 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #950    +/-   ##
========================================
  Coverage     0.00%   0.00%            
========================================
  Files           61      64     +3     
  Lines        38210   38322   +112     
========================================
- Misses       38210   38322   +112     
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 marked this pull request as ready for review November 13, 2025 06:29
Comment on lines +77 to +89
pub fn is_incoming_invoice_fiber(&self) -> bool {
matches!(self.incoming_invoice, CchInvoice::Fiber(_))
}
pub fn is_incoming_invoice_lnd(&self) -> bool {
matches!(self.incoming_invoice, CchInvoice::Lightning(_))
}
pub fn is_outgoing_payment_fiber(&self) -> bool {
self.is_incoming_invoice_lnd()
}
pub fn is_outgoing_payment_lnd(&self) -> bool {
self.is_incoming_invoice_fiber()
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

the later 2 functions are just alias of the first 2 functions,
proper function naming to keep only 2 function seems more maintainable.

Copy link
Member Author

Choose a reason for hiding this comment

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

The extra 2 functions make code easy to reason. In the place I want to ensure the order is sending outgoing payment to fiber, I can use is_outgoing_payment_fiber. It's more straightforward than is_incoming_invoice_lnd since I have to reason that when incoming invoice is from lnd, the outgoing payment is to fiber.

@doitian doitian force-pushed the feature/cch-monitor-store-changes branch 2 times, most recently from 92c0931 to 58f7f76 Compare November 18, 2025 07:04
@doitian doitian requested a review from chenyukang November 18, 2025 07:05
@doitian doitian marked this pull request as draft November 19, 2025 05:04
@doitian
Copy link
Member Author

doitian commented Nov 19, 2025

Convert to Draft. Wait on #934

@doitian doitian force-pushed the feature/cch-monitor-store-changes branch from 58f7f76 to e75a7da Compare November 24, 2025 07:38
@doitian
Copy link
Member Author

doitian commented Nov 25, 2025

#934 still does not update hold invoice to Received. Wait on #961

@doitian doitian force-pushed the feature/cch-monitor-store-changes branch 2 times, most recently from a7b2dad to 327aed0 Compare November 28, 2025 11:11
@doitian doitian marked this pull request as ready for review November 28, 2025 11:22
- 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
- When an invoice state changes in Fiber (settled, failed, expired), the
  CCH order tracking system automatically detects and synchronizes the
  state without manual polling or intervention.
- When an outgoing payment state changes in Fiber (succeeded, failed,
  pending), the CCH order tracking system automatically detects and
  synchronizes the state without requiring manual status checks.
- CCH monitors invoice for the incoming payment. When CCH has received
  the incoming payment, it will send the outgoing payment to get the
  preimage.
- CCH monitors outgoing payment to get the preimage and use the obtained
  preimage the settle the incoming payment.
@doitian doitian merged commit 0db1714 into nervosnetwork:develop Dec 15, 2025
35 checks passed
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.

3 participants