Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add PersistClaimInfo and ClaimInfoRequest events #3067

Conversation

G8XSU
Copy link
Contributor

@G8XSU G8XSU commented May 16, 2024

Based on #3057

Introduce two new events i.e. PersistClaimInfo and ClaimInfoRequest.

PersistClaimInfo: Indicates that [ClaimInfo] should be durably persisted.

ClaimInfoRequest: Used to request [ClaimInfo] for a specific counterparty commitment transaction.

This PR is still in progress as event writing changes are pending and is not in mergeable state but the api and interface can still be reviewed. Mostly ignore docs, they should be legible but need some more work.

As part of #3049

@codecov-commenter
Copy link

codecov-commenter commented May 16, 2024

Codecov Report

Attention: Patch coverage is 0% with 19 lines in your changes missing coverage. Please review.

Project coverage is 89.70%. Comparing base (50d21b7) to head (7fad4ee).
Report is 357 commits behind head on main.

Files with missing lines Patch % Lines
lightning/src/events/mod.rs 0.00% 19 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3067      +/-   ##
==========================================
- Coverage   89.75%   89.70%   -0.06%     
==========================================
  Files         122      122              
  Lines      101791   101810      +19     
  Branches   101791   101810      +19     
==========================================
- Hits        91367    91327      -40     
- Misses       7743     7795      +52     
- Partials     2681     2688       +7     

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

@G8XSU G8XSU force-pushed the 2024-05-08-claimable-persist-3049-events branch 4 times, most recently from 2c9e408 to a34b67e Compare May 17, 2024 19:31
Copy link
Collaborator

@TheBlueMatt TheBlueMatt left a comment

Choose a reason for hiding this comment

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

Makes sense to me. We'll definitely want some code that uses this so we can check that ClaimMetadata has the right contents before we land.

@G8XSU G8XSU force-pushed the 2024-05-08-claimable-persist-3049-events branch from a34b67e to 8a56137 Compare July 30, 2024 23:16
@G8XSU G8XSU changed the title [WIP] Add PersistClaimInfo and ClaimInfoRequest events Add PersistClaimInfo and ClaimInfoRequest events Jul 30, 2024
@G8XSU G8XSU marked this pull request as ready for review July 30, 2024 23:20
Copy link
Collaborator

@TheBlueMatt TheBlueMatt left a comment

Choose a reason for hiding this comment

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

Feel free to squash fixups, but we shouldn't land this as-is without cfg-tags, but honestly IMO we should just land this as a part of a later PR that handles these events.

///
/// This event is generated when there is a need for [`ClaimInfo`] that was previously stored
/// using [`PersistClaimInfo`] for the specified counterparty commitment transaction.
/// This event can be safely ignored if [`PersistClaimInfo`] event is being ignored.
Copy link
Collaborator

Choose a reason for hiding this comment

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

This event can never be ignored, cause if it is generated PersistClaimInfo is being handled.

Suggested change
/// This event can be safely ignored if [`PersistClaimInfo`] event is being ignored.
/// This event will never be generated if the [`PersistClaimInfo`] event is being ignored.

@TheBlueMatt
Copy link
Collaborator

Also, please include at least a bit of detail in the commit messages.

///
/// The response to this event should be handled by calling
/// [`ChainMonitor::provide_claim_info`] with the [`ClaimInfo`] that was previously stored and
/// [`ClaimMetadata`] from this event.
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should probably have some kind of advice for what users should do if they don't find the claim info on disk - I assume they should probably treat it as if they definitely just lost funds (panic or whatever)?

/// [`ClaimMetadata`] from this event.
///
/// [`ChainMonitor::provide_claim_info`]: crate::chain::chainmonitor::ChainMonitor::provide_claim_info
/// [`PersistClaimInfo`]: Event::PersistClaimInfo
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: No need to add this reference if in the same module. Then again, we may want to move the new structs to ChainMonitor?

/// [`ClaimInfoRequest`]: Event::ClaimInfoRequest
PersistClaimInfo {
/// The [`OutPoint`] identifying the channel monitor with which this claim is associated.
monitor_id: transaction::OutPoint,
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be called funding_txo? Do we already now how this will work in the context of splicing? If this is indeed a monitor_id, should we use an opaque MonitorId type that would allow us to change its semantics internally in the future? If not, can we make this a bitcoin::OutPoint to avoid mixing the two different OutPoint types across our public API?

/// Additional metadata that must be supplied in the call to [`ChainMonitor::provide_claim_info`].
///
/// [`ChainMonitor::provide_claim_info`]: crate::chain::chainmonitor::ChainMonitor::provide_claim_info
claim_metadata: ClaimMetadata,
Copy link
Contributor

Choose a reason for hiding this comment

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

ClaimInfo and ClaimMetadata are very similar and very generic names. Can we make them a bit more specific, i.e., reflect their purpose a bit better?

///
/// [`ChainMonitor::provide_claim_info`]: crate::chain::chainmonitor::ChainMonitor::provide_claim_info
/// [`PersistClaimInfo`]: Event::PersistClaimInfo
ClaimInfoRequest {
Copy link
Contributor

Choose a reason for hiding this comment

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

The names of other event types usually either reflect that something happened (PaymentClaimed/PaymentFailed) or that something needs to be done (DiscardFunding, ConnectionNeeded). ClaimInfoRequest (and to an extend also PersistClaimInfo) doesn't make it easy to infer whether it's simply informational or if the user needs to take action. Could this be improved?

@tnull
Copy link
Contributor

tnull commented Aug 8, 2024

This needs a rebase now.

@G8XSU
Copy link
Contributor Author

G8XSU commented Aug 28, 2024

Merging this into #3106 as per feedback.
Addressed most of the comments here, some might be unanswered.
Will move some questions to 3106, and close the rest here.

@tnull
Copy link
Contributor

tnull commented Aug 29, 2024

Merging this into #3106 as per feedback.

Should this PR get closed then?

@G8XSU
Copy link
Contributor Author

G8XSU commented Aug 29, 2024

Yes i will close this after answering some comments or moving them to new pr.

@G8XSU G8XSU closed this Sep 17, 2024
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.

4 participants