Skip to content

Remove unnecessary todo #746

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

Merged
merged 1 commit into from
Nov 10, 2020

Conversation

valentinewallace
Copy link
Contributor

@valentinewallace valentinewallace commented Nov 6, 2020

The OnchainTxHandler already monitors the chain for counterparties
revealing preimages, etc, and will give the HTLCSources back to the
ChannelManager for claiming. Thus it's unnecessary for the ChannelManager
to monitor these HTLCs itself.

I had the start of a "solution" for this todo in the course of a #611 rabbit hole, then realized it's unnecessary. So figured it might be worth removing.

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.

Technically, I think this is only really resolved by #611, but we should be using issues, not TODO's anyway as we move forward.

@valentinewallace
Copy link
Contributor Author

Technically, I think this is only really resolved by #611

Oh, I guess in the sense that any TODO relating to claiming backwards HTLCs is only truly solved by 611... (unless I misunderstand)

@TheBlueMatt
Copy link
Collaborator

Heh, right, I read it that way, but the fact that it can be read multiple ways is maybe even a better reason to remove it :)

@codecov
Copy link

codecov bot commented Nov 6, 2020

Codecov Report

Merging #746 (2b2d83a) into main (9c7c3b9) will decrease coverage by 0.01%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #746      +/-   ##
==========================================
- Coverage   91.38%   91.36%   -0.02%     
==========================================
  Files          37       37              
  Lines       22067    22065       -2     
==========================================
- Hits        20165    20159       -6     
- Misses       1902     1906       +4     
Impacted Files Coverage Δ
lightning/src/ln/channel.rs 87.43% <ø> (-0.01%) ⬇️
lightning/src/ln/functional_tests.rs 96.93% <0.00%> (-0.10%) ⬇️
lightning/src/util/ser.rs 87.78% <0.00%> (+0.32%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9c7c3b9...8e7b291. Read the comment docs.

@ariard
Copy link

ariard commented Nov 7, 2020

I think commit message is confusing. IIRC it's the ChannelMonitor responsibility to scan commitment and pass off-chain the preimage. It's done in is_resolving_htlc_output :

  • if it's an incoming HTLC on a counterparty commitment, L2025
  • if it's an outgoing HTLC on a holder commitment, L2015

I agree this TODO is already covered, as it mentions outgoing-onchain-to-incoming-offchain preimage processing. #611 is about outgoing-offchain-to-incoming-onchain-if-already-closed.

The ChannelMonitor already monitors the chain for counterparties
revealing preimages, and will give the HTLCSources back to the
ChannelManager for claiming. Thus it's unnecessary for the ChannelManager
to monitor these HTLCs itself.

See is_resolving_htlc_output:
- if the counterparty broadcasted and then claimed one of the HTLCs we
  offered them, line 2015 is where the ChannelMonitor gives the ChannelManager
  the HTLC source
- if we broadcasted and they claimed an HTLC we offered them, line 2025 is
  where the ChannelMonitor gives the ChannelManager the HTLC source
@valentinewallace
Copy link
Contributor Author

* if it's an incoming HTLC on a counterparty commitment, L2025

* if it's an outgoing HTLC on a holder commitment, L2015

Hmm, I think the counterparty commitment case is L2015? Lmk if I'm off on that.

Good point on the ChannelMonitor being the one passing the ChannelManager HTLC sources, updated commit msg!

@ariard
Copy link

ariard commented Nov 9, 2020

Hmm, I think the counterparty commitment case is L2015? Lmk if I'm off on that.

EDIT: You're right an accepted HTLC is an incoming one on the counterparty commitment, which make sense for them to claim it with a preimage. This code should be better documented I guess :)

LGTM.

@TheBlueMatt TheBlueMatt merged commit 6882719 into lightningdevkit:main Nov 10, 2020
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