Skip to content

Watch all outputs irrespective of claimable outpoints #3081

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

G8XSU
Copy link
Contributor

@G8XSU G8XSU commented May 23, 2024

@codecov-commenter
Copy link

codecov-commenter commented May 23, 2024

Codecov Report

Attention: Patch coverage is 95.00000% with 1 line in your changes missing coverage. Please review.

Project coverage is 89.88%. Comparing base (7326334) to head (149fa12).

Files Patch % Lines
lightning/src/chain/channelmonitor.rs 95.00% 1 Missing ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3081      +/-   ##
==========================================
- Coverage   89.90%   89.88%   -0.03%     
==========================================
  Files         117      117              
  Lines       97415    97406       -9     
  Branches    97415    97406       -9     
==========================================
- Hits        87581    87550      -31     
- Misses       7272     7285      +13     
- Partials     2562     2571       +9     

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

@G8XSU
Copy link
Contributor Author

G8XSU commented May 23, 2024

To fix testcases:
I had to convert channel_monitor.outputs_to_watch from
HashMap<Txid, Vec<(u32, ScriptBuf)>> to HashMap<Txid, HashSet<(u32, ScriptBuf)>>

This is because earlier we were only returning new_watched_outputs from block_confirmed/transactions_confirmed if no output existed against the txid. But we would still go ahead and replace watched_outputs against a txid. see: here

In case where we see something like

first we encounter : txid1 -> o1
then we encounter: txid1 -> o2, o3

we would replace watched_outputs with o2, o3 but not return them from block_confirmed/transactions_confirmed.
This would result in o2,o3 not being watched.

So after the fix in second commit, we will now watch all of o1, o2, o3.

Not sure if this is the right fix but there is definitely something wrong here. Will fix the one remaining commented testcase which uses old_serialized monitor if this is the right fix.

Ready for review!

@G8XSU G8XSU changed the title [WIP] Watch all outputs irrespective of claimable outpoints Watch all outputs irrespective of claimable outpoints May 23, 2024
@G8XSU G8XSU marked this pull request as ready for review May 23, 2024 23:12
@G8XSU G8XSU requested a review from TheBlueMatt May 23, 2024 23:12
for (idx, outp) in tx.output.iter().enumerate() {
new_watch_outputs.push((idx as u32, outp.clone()));
}
watch_outputs.push((txid, new_watch_outputs));
Copy link
Collaborator

Choose a reason for hiding this comment

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

Discussed it offline, but this is currently also applying to holder commitment transactions, which causes issues in that its watching a different set. IMO we should consider only watching all outputs if the commitment transactions is unknown to us (or revoked-counterparty).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

in the latest patch, we check for check_spend_holder_transaction before check_spend_counterparty.

and we watch all outputs only if it is not a current/prev holder_tx.

@G8XSU G8XSU force-pushed the 2024-05-08-claimable-persist-3049-outputs branch 3 times, most recently from b2decaf to da226cc Compare June 1, 2024 00:26
@G8XSU G8XSU requested a review from TheBlueMatt June 1, 2024 00:43
TheBlueMatt
TheBlueMatt previously approved these changes Jun 3, 2024
@G8XSU G8XSU dismissed TheBlueMatt’s stale review June 3, 2024 17:30

The merge-base changed after approval.

This removes dependency of watched_outputs from
per_commitment_claimable_outpoints, it is required since we will
no longer have direct access to per_commitment_claimable_outpoints
once we start publishing PersistClaimInfo as part of lightningdevkit#3049.
@G8XSU G8XSU force-pushed the 2024-05-08-claimable-persist-3049-outputs branch from da226cc to 149fa12 Compare June 3, 2024 18:54
@G8XSU
Copy link
Contributor Author

G8XSU commented Jun 3, 2024

Rebased PR on main.

@@ -3252,7 +3250,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
( $thing : expr ) => {
match $thing {
Ok(a) => a,
Err(_) => return (claimable_outpoints, (commitment_txid, watch_outputs), to_counterparty_output_info)
Err(_) => return (claimable_outpoints, to_counterparty_output_info)
Copy link
Contributor

Choose a reason for hiding this comment

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

am I blind or is ignore_error only getting called once? Should we just get rid of it while we're here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Created another PR for this: #3093
as it was separate commit in any case.
Let me know if i should merge that into this one, i didn't because this one already has 1 approval.

Copy link
Contributor

Choose a reason for hiding this comment

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

thanks! I don't think it needs to be in this PR, and thanks for creating the followup!

@G8XSU G8XSU requested a review from arik-so June 4, 2024 20:12
@TheBlueMatt TheBlueMatt merged commit 8880b55 into lightningdevkit:main Jun 4, 2024
16 checks passed
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.

4 participants