Refresh async static invoices after channel changes#13
Conversation
Async receive offers currently decide static invoice refreshes from timer-based freshness only. Channel changes need a separate selector so callers can rebuild server-side invoices without waiting for the normal age threshold. Add a cache helper that returns used and pending offers for forced invoice refresh. Ready offers stay on the existing offer rotation path because they have not been returned to the application yet. AI-assisted: planning and writing commit Co-Authored-By: OpenAI Codex <codex@openai.com>
The cache can now identify offers whose static invoices should be rebuilt immediately, but callers still need one canonical path that turns those offers into ServeStaticInvoice messages. Thread a forced-refresh entry point through OffersMessageFlow and ChannelManager while reusing the existing static invoice construction code. This keeps the later channel-change behavior focused on deciding when to refresh, not how to rebuild invoices. AI-assisted: planning and writing commit Co-Authored-By: OpenAI Codex <codex@openai.com>
Static invoices contain blinded payment paths built from the recipient's current channels and fees. When channels become usable, close, or require a local fee update, cached async receive offers can otherwise keep serving stale payment instructions until the normal refresh threshold passes. Mark those channel changes as requiring a forced async static invoice refresh, then process the refresh after channel locks are released. The deferred flag avoids rebuilding invoices while holding peer/channel locks, since invoice rebuilding needs a fresh usable-channel snapshot. AI-assisted: planning and writing commit Co-Authored-By: OpenAI Codex <codex@openai.com>
|
Warning Review limit reached
More reviews will be available in 55 minutes and 53 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits. 🚦 How do rate limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe PR adds forced async receive static-invoice refreshes on channel-state changes, coordinates pending refreshes in ChangesAsync receive static invoice refresh
Sequence Diagram(s)sequenceDiagram
participant ChannelManager
participant OffersMessageFlow
participant AsyncReceiveOfferCache
participant Recipient
participant StaticInvoiceServer
ChannelManager->>OffersMessageFlow: process_pending_async_receive_static_invoice_refresh()
OffersMessageFlow->>AsyncReceiveOfferCache: offers_needing_forced_invoice_refresh()
OffersMessageFlow->>Recipient: ServeStaticInvoice
Recipient->>StaticInvoiceServer: deliver ServeStaticInvoice
StaticInvoiceServer->>StaticInvoiceServer: PersistStaticInvoice
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@lightning/src/ln/async_payments_tests.rs`:
- Around line 433-434: The extractor in async_payments_tests should ignore
OfferPathsRequest instead of rejecting every message, since this refresh path
can queue a server-bound path request before ServeStaticInvoice. Update the call
to extract_expected_om to use a predicate that filters out
AsyncPaymentsMessage::OfferPathsRequest while still matching the expected
invoice-related message, so the test follows the same construction flow used
elsewhere in the file.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: f8f507a7-f4a9-48e0-8076-4e87cdb9b6eb
📒 Files selected for processing (4)
lightning/src/ln/async_payments_tests.rslightning/src/ln/channelmanager.rslightning/src/offers/async_receive_offer_cache.rslightning/src/offers/flow.rs
a945650 to
c7a7887
Compare
Used async receive offers may already be published by the application, so a new usable channel should refresh the static invoice stored by the server without waiting for the normal age threshold. Add a focused async payments test that marks an offer used, opens another channel to the static invoice server, and asserts that a replacement ServeStaticInvoice is sent for the same server slot. AI-assisted: planning and writing commit Co-Authored-By: OpenAI Codex <codex@openai.com>
c7a7887 to
5f3f1f0
Compare
Refresh async receive static invoices when local channel state changes, so
already-published async offers do not keep serving stale payment paths until the
normal refresh threshold.
This adds a forced refresh path for cached async receive offers:
are queued
Ready unused offers are left to the existing offer rotation path because they
have not been returned to the application yet.
Summary by CodeRabbit
New Features
Bug Fixes
Tests