Skip to content

Avoid generating redundant claims after initial confirmation #1753

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

Conversation

wpaulino
Copy link
Contributor

@wpaulino wpaulino commented Oct 5, 2022

These claims will never be valid as a previous claim has already confirmed. If a previous claim is reorged out of the chain, a new claim will be generated bypassing the new behavior.

While this doesn't change much for our existing transaction-based claims, as broadcasting an already confirmed transaction acts as a NOP, it prevents us from yielding redundant event-based claims, which will be introduced as part of the anchors patchset.

@codecov-commenter
Copy link

codecov-commenter commented Oct 5, 2022

Codecov Report

Base: 90.72% // Head: 90.70% // Decreases project coverage by -0.01% ⚠️

Coverage data is based on head (4e20072) compared to base (6957fb6).
Patch coverage: 86.66% of modified lines in pull request are covered.

❗ Current head 4e20072 differs from pull request most recent head a089136. Consider uploading reports for the commit a089136 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1753      +/-   ##
==========================================
- Coverage   90.72%   90.70%   -0.02%     
==========================================
  Files          87       87              
  Lines       47361    47356       -5     
  Branches    47361    47356       -5     
==========================================
- Hits        42968    42956      -12     
- Misses       4393     4400       +7     
Impacted Files Coverage Δ
lightning/src/ln/functional_tests.rs 96.91% <ø> (-0.10%) ⬇️
lightning/src/chain/onchaintx.rs 95.00% <86.66%> (-0.30%) ⬇️
lightning/src/ln/channel.rs 88.64% <0.00%> (-0.03%) ⬇️
lightning/src/ln/monitor_tests.rs 99.55% <0.00%> (+0.11%) ⬆️
lightning/src/ln/peer_channel_encryptor.rs 93.62% <0.00%> (+0.24%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@wpaulino wpaulino force-pushed the avoid-redundant-claims-after-initial-conf branch from 4ce1645 to 5b0ba3a Compare October 6, 2022 19:39
Copy link

@ariard ariard left a comment

Choose a reason for hiding this comment

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

SGTM

@TheBlueMatt
Copy link
Collaborator

Feel free to squash.

@wpaulino wpaulino force-pushed the avoid-redundant-claims-after-initial-conf branch 2 times, most recently from 6c864b8 to 4e20072 Compare October 31, 2022 17:56
@wpaulino
Copy link
Contributor Author

Squashed and rebased on latest.

.any(|event_entry| if let OnchainEvent::Claim { claim_request } = event_entry.event {
for outpoint in &request_outpoints {
if let Some(first_claim_txid_height) = self.claimable_outpoints.get(outpoint) {
if first_claim_txid_height.0 != claim_request {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hmm, is this right? It seems what this is asking is "is there a single confirming claim package that spent all the outpoints of the one being generated", but instead I think we may want to answer "is there at least a single confirming claim package which spent the outpoint in question". This would imply an outer for outpoint in &request_outpoints { loop, with a claimable_outpoints.get lookup inside it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I believe we still want the former. The goal here is to prevent the same claims from being generated when nothing has materially changed after an initial confirmation.

Copy link
Collaborator

Choose a reason for hiding this comment

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

But won't this break if we, for example, split a package because one input has to be spent soon, but then the previous version of the package confirms?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, good point! Fixed.

arik-so
arik-so previously approved these changes Nov 1, 2022
Copy link
Contributor

@arik-so arik-so left a comment

Choose a reason for hiding this comment

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

Seems fine to me, but I'm not quite sure I have sufficient context 🫥

These claims will never be valid as a previous claim has already
confirmed. If a previous claim is reorged out of the chain, a new claim
will be generated bypassing the new behavior.

While this doesn't change much for our existing transaction-based
claims, as broadcasting an already confirmed transaction acts as a NOP,
it prevents us from yielding redundant event-based claims, which will be
introduced as part of the anchors patchset.
@wpaulino wpaulino force-pushed the avoid-redundant-claims-after-initial-conf branch from 4e20072 to a089136 Compare November 2, 2022 17:08
// transaction is reorged out.
let mut all_inputs_have_confirmed_spend = true;
for outpoint in &request_outpoints {
if let Some(first_claim_txid_height) = self.claimable_outpoints.get(outpoint) {
Copy link
Contributor

Choose a reason for hiding this comment

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

btw, this variable name is a bit confusing, because it sounds like it's the height of the txid, but it's actually the (txid, height) tuple

Copy link
Contributor

Choose a reason for hiding this comment

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

that said, I don't have any better ideas ¯_(ツ)_/¯

Copy link
Collaborator

Choose a reason for hiding this comment

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

Its copied from another of other places, so if we want to change it ISTM we should do it broadly through the file and in a followup.

@TheBlueMatt TheBlueMatt merged commit a6609d6 into lightningdevkit:main Nov 2, 2022
@wpaulino wpaulino deleted the avoid-redundant-claims-after-initial-conf branch November 2, 2022 19:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants