Skip to content

Finish ChannelMonitor case handling and add more testing #137

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

Closed
TheBlueMatt opened this issue Aug 30, 2018 · 13 comments
Closed

Finish ChannelMonitor case handling and add more testing #137

TheBlueMatt opened this issue Aug 30, 2018 · 13 comments
Milestone

Comments

@TheBlueMatt
Copy link
Collaborator

There's one or two TODOs in ChannelMonitor to handle all the listed cases, plus some TODOs in channel-force-close in ChannelManager to update ChannelMonitor, and the test in ChannelManager which construct networks, do various things to them, and then check monitor validity should be fleshed out way way more.

@TheBlueMatt TheBlueMatt added this to the 0.1 milestone Aug 30, 2018
@ariard
Copy link

ariard commented Sep 5, 2018

Was looking on it, seems to me than for some chain_monitor TODO we need to pass an Arc to ChannelMonitor struct and if so, maybe it's make sense to drop it from SimpleManyChannelMonitor?

@TheBlueMatt
Copy link
Collaborator Author

I assume you're referring to "TODO: Need to register the given script here with a chain_monitor" and the two "TODO: Register all outputs in commitment_tx with the ChainWatchInterface!"? I'm not 100% sure by what you mean by "drop it from SimpleManyChannelMonitor", though? In any case, yea, not sure if it makes more sense to return such values to the callers (ala the Channel::block_connected telling ChannelManager::block_connected how it should handle it) or if it makes more sense to give it yet another Arc.

@ariard
Copy link

ariard commented Sep 6, 2018

Yes I'm referring to this ones, I prefer your suggestion with Channel - ChannelManager because I started on the other side and passing ChainWatchInterface means we have to deal with it in channel_monitor serialization/deserialization. Will open a PR soon on this

@ariard
Copy link

ariard commented Sep 13, 2018

Following BOLT 5 there is a lot of different cases to claim in case of remote node broadcasting a commitment tx.
The Bad Way :

  • to_remote outputs via P2WPKH
  • offered htlc outputs via payment preimage tx
  • received htlc outputs via timeout tx

The Ugly Way :

Seems to me that currently, channel_monitor_network_test currently does only Bad Way 2,3 and Ugly Way 4, do I forget any case ?

@ariard
Copy link

ariard commented Sep 13, 2018

(Alice broadcasting a commitment tx, speaking as Bob viewpoint here)

@TheBlueMatt
Copy link
Collaborator Author

"to_remote outputs via P2WPKH" should be covered by #81 (ie once we have a way for clients to specify the keys they want they should be monitoring the chain for at least the non-derived keys, and obviously documentation should mention this, this also applies to shutdown keys).

The "via revocation key" HTLC outputs are implemented, probably, but aren't tested yet (which you indicated, just being thourough).

The to_local outputs via revocation key I think we impelement? Maybe I'm misunderstanding what the BOLT is referring to, but note that I think we need an interface so that we can tell the client about the availability of an output+the key needed to claim it when we believe the remote side cannot take it (eg its a timelocked output for our latest commitment transaction which we don't think we've ever revoked...we are in no rush to spend it and can let the client do so at their leisure).

@ariard
Copy link

ariard commented Sep 18, 2018

Yes sorry I checked the code in fact the to_local outputs via revocation is implemented, but seems to me there is not test only for it because in some tests (all?) it's trimmed so it doesn't appear specifically.

#184 is tests for "via revocation key" HTLC outputs, need review. While I was writing tests, I was wandering maybe we could cache tx given to check_spend_remote_tx after 1st pass in case of block re-scanning to avoid generate again same punishment tx.

"to_remote_outputs via P2WPKH", seems fine to be covered by #81, noted.

@ariard
Copy link

ariard commented Sep 18, 2018

And yeah for stuff in force_close about ChannelManager I think we need an interface to have the ChainWatchInterface to pass up the payment_preimage extracted from on-chain HTLC-Success input to the ChannelManager and this last one claiming backwards. Seems for HTLC-timeout case, failing backward. Working on it

@TheBlueMatt
Copy link
Collaborator Author

I'd hope it doesn't need to get added in ChainWatchInterface, maybe ChannelMonitors should have a different block_connected fn that ChannelManager calls that returns more information and watchtowers (or other calls into ChannelMonitor via ChainWatchInterface) can just ignore the extra data.
The which-object-is-registered-with-ChainWatchInterface stuff is already a mess (see #80) so I don't think rejiggering what calls what is that big a deal right now. Eventually we'll need to rewrite it all and make it harder to misuse but that doesn't need to happen ASAP.

@ariard
Copy link

ariard commented Oct 3, 2018

Hmm, just a side-note to not forget to add the case of a revoked commitment tx solved by a justice tx, detect it and fail backward. Will go in #198

ariard pushed a commit to ariard/rust-lightning that referenced this issue Oct 9, 2018
Add test_commitment_revoked_fail_backward

Close lightningdevkit#137
ariard pushed a commit to ariard/rust-lightning that referenced this issue Oct 10, 2018
Refactor block_connected to ease output resolution

Add test_commitment_revoked_fail_backward

Close lightningdevkit#137
ariard pushed a commit to ariard/rust-lightning that referenced this issue Oct 12, 2018
Refactor block_connected to ease output resolution

Add test_commitment_revoked_fail_backward

Close lightningdevkit#137
ariard pushed a commit to ariard/rust-lightning that referenced this issue Nov 17, 2018
Refactor block_connected to ease output resolution

Add test_commitment_revoked_fail_backward

Close lightningdevkit#137
ariard pushed a commit to ariard/rust-lightning that referenced this issue Nov 19, 2018
Refactor block_connected to ease output resolution

Add test_commitment_revoked_fail_backward

Close lightningdevkit#137
ariard pushed a commit to ariard/rust-lightning that referenced this issue Nov 21, 2018
Refactor block_connected to ease output resolution

Add test_commitment_revoked_fail_backward

Close lightningdevkit#137
ariard pushed a commit to ariard/rust-lightning that referenced this issue Nov 22, 2018
Refactor block_connected to ease output resolution

Add test_commitment_revoked_fail_backward

Close lightningdevkit#137
ariard pushed a commit to ariard/rust-lightning that referenced this issue Nov 23, 2018
Refactor block_connected to ease output resolution

Add test_commitment_revoked_fail_backward

Close lightningdevkit#137
ariard pushed a commit to ariard/rust-lightning that referenced this issue Nov 26, 2018
Refactor block_connected to ease output resolution

Add test_commitment_revoked_fail_backward

Close lightningdevkit#137
ariard pushed a commit to ariard/rust-lightning that referenced this issue Nov 27, 2018
Refactor block_connected to ease output resolution

Add test_commitment_revoked_fail_backward

Close lightningdevkit#137
ariard pushed a commit to ariard/rust-lightning that referenced this issue Nov 27, 2018
Refactor block_connected to ease output resolution

Add test_commitment_revoked_fail_backward

Close lightningdevkit#137
ariard pushed a commit to ariard/rust-lightning that referenced this issue Nov 28, 2018
Refactor block_connected to ease output resolution

Add test_commitment_revoked_fail_backward

Close lightningdevkit#137
ariard pushed a commit to ariard/rust-lightning that referenced this issue Nov 30, 2018
Refactor block_connected to ease output resolution

Add test_commitment_revoked_fail_backward

Close lightningdevkit#137
ariard pushed a commit to ariard/rust-lightning that referenced this issue Nov 30, 2018
Refactor block_connected to ease output resolution

Add test_commitment_revoked_fail_backward

Close lightningdevkit#137
ariard pushed a commit to ariard/rust-lightning that referenced this issue Nov 30, 2018
Refactor block_connected to ease output resolution

Add test_commitment_revoked_fail_backward

Close lightningdevkit#137
ariard pushed a commit to ariard/rust-lightning that referenced this issue Nov 30, 2018
Refactor block_connected to ease output resolution

Add test_commitment_revoked_fail_backward

Close lightningdevkit#137
ariard pushed a commit to ariard/rust-lightning that referenced this issue Dec 1, 2018
Refactor block_connected to ease output resolution

Add test_commitment_revoked_fail_backward

Close lightningdevkit#137
ariard pushed a commit to ariard/rust-lightning that referenced this issue Dec 3, 2018
Refactor block_connected to ease output resolution

Add test_commitment_revoked_fail_backward

Close lightningdevkit#137
ariard pushed a commit to ariard/rust-lightning that referenced this issue Dec 4, 2018
Refactor block_connected to ease output resolution

Add test_commitment_revoked_fail_backward

Close lightningdevkit#137
ariard pushed a commit to ariard/rust-lightning that referenced this issue Dec 5, 2018
Refactor block_connected to ease output resolution

Add test_commitment_revoked_fail_backward

Close lightningdevkit#137
ariard pushed a commit to ariard/rust-lightning that referenced this issue Dec 6, 2018
Refactor block_connected to ease output resolution

Add test_commitment_revoked_fail_backward

Close lightningdevkit#137
@ariard
Copy link

ariard commented Dec 13, 2018

Some notes to check if we have covered everything on on-chain Channel resolution.

Local Node seeing a Local Commitment Tx :

  • commitment tx :

  • HTLC-Timeout tx (from any commitment tx offered_htlc_output) :

  • HTLC-Success tx (from any commitment tx received_htlc_output) :

Local Node seeing a Non-Revoked Remote Commitment Tx :

[WIP]

@ariard
Copy link

ariard commented Oct 26, 2019

Killed by #336 IMO, not sure if bumping engine is in the scope.

@TheBlueMatt
Copy link
Collaborator Author

Nah, I think its fine as-is. I'd like to get better test coverage on it, but this bug itself is probably done.

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

No branches or pull requests

2 participants