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

Sanity check for ChannelManager and KeysInterface #1250

Merged
merged 1 commit into from
Jan 22, 2022

Conversation

vss96
Copy link
Contributor

@vss96 vss96 commented Jan 18, 2022

This fixes #1174.

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.

Thanks!

While you're here, can you also add a similar script check in KeysManager::spend_spendable_outputs in the second for loop in the SpendableOutputDescriptor::StaticOutput match variant?

@codecov-commenter
Copy link

codecov-commenter commented Jan 19, 2022

Codecov Report

Merging #1250 (442d455) into main (34cdca9) will decrease coverage by 0.03%.
The diff coverage is 85.71%.

❗ Current head 442d455 differs from pull request most recent head 2f01d68. Consider uploading reports for the commit 2f01d68 to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1250      +/-   ##
==========================================
- Coverage   90.42%   90.39%   -0.04%     
==========================================
  Files          70       70              
  Lines       38087    38131      +44     
==========================================
+ Hits        34441    34467      +26     
- Misses       3646     3664      +18     
Impacted Files Coverage Δ
lightning/src/ln/channelmanager.rs 84.23% <75.00%> (-0.03%) ⬇️
lightning/src/chain/keysinterface.rs 95.81% <100.00%> (+0.05%) ⬆️
lightning/src/routing/router.rs 91.81% <0.00%> (-0.25%) ⬇️
lightning-invoice/src/de.rs 80.73% <0.00%> (-0.21%) ⬇️
lightning/src/ln/functional_tests.rs 97.27% <0.00%> (-0.10%) ⬇️
lightning/src/ln/channel.rs 89.35% <0.00%> (-0.03%) ⬇️

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 34cdca9...2f01d68. Read the comment docs.

@vss96
Copy link
Contributor Author

vss96 commented Jan 19, 2022

@TheBlueMatt I created the script from segwit script hash for spendable_outputs:

let payment_script = bitcoin::Address::p2wsh(&witness_script, Network::Testnet).script_pubkey();
assert_eq!(payment_script, output.script_pubkey);

I ran the tests locally and they seem to be failing. Maybe I'm doing something wrong?

@TheBlueMatt
Copy link
Collaborator

let payment_script = bitcoin::Address::p2wsh(&witness_script, Network::Testnet).script_pubkey();

This should also be a p2wpkh, not p2wsh.

@vss96 vss96 changed the title [Draft] Sanity check for ChannelManager and KeysInterface Sanity check for ChannelManager and KeysInterface Jan 19, 2022
@vss96 vss96 force-pushed the sanity_check branch 4 times, most recently from ff874fc to 1dff756 Compare January 19, 2022 18:43
@vss96
Copy link
Contributor Author

vss96 commented Jan 19, 2022

@TheBlueMatt I'm done with the changes for the pr but I'm facing issues with squashing the commits 😭

@TheBlueMatt
Copy link
Collaborator

The Bitcoin Core docs have some discussion of how to do it at https://github.com/bitcoin/bitcoin/blob/master/doc/productivity.md

@vss96 vss96 force-pushed the sanity_check branch 8 times, most recently from 84ba02a to 1dff756 Compare January 20, 2022 12:41
@vss96
Copy link
Contributor Author

vss96 commented Jan 20, 2022

@TheBlueMatt I was trying to rebase and squash the 6 commits but by the time I'm done with it, the branch is behind by like 390 commits and when I force push I see a lot of other changes.

@TheBlueMatt
Copy link
Collaborator

You shouldn't need to rebase unless there is a conflict (there currently is not). If you're using rebase, it may be simplest to rebase on top of 34cdca91baa, which is the current commit this is based on.

@vss96
Copy link
Contributor Author

vss96 commented Jan 20, 2022

That worked! I was trying to do git rebase -i HEAD~6 and that included the merged commits as well and was causing some issues.

TheBlueMatt
TheBlueMatt previously approved these changes Jan 20, 2022
@valentinewallace valentinewallace self-requested a review January 21, 2022 16:56
@vss96 vss96 force-pushed the sanity_check branch 2 times, most recently from d94fe37 to 2e45d68 Compare January 21, 2022 18:29
@vss96
Copy link
Contributor Author

vss96 commented Jan 21, 2022

@TheBlueMatt Valentine had pointed out how the docs for the methods in keysinterface mention the conditions under which Err is returned, so I went ahead and updated them.

Copy link
Contributor

@valentinewallace valentinewallace left a comment

Choose a reason for hiding this comment

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

Thanks for the docs updates!

Fix build errors

Create script using p2wsh for comparison

Using p2wpkh for generating the payment script

spendable_outputs sanity check

Return err in spendable_outputs

Doc updates in keysinterface
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.

Thanks!

@TheBlueMatt TheBlueMatt merged commit 19fdde2 into lightningdevkit:main Jan 22, 2022
@vss96 vss96 deleted the sanity_check branch January 22, 2022 18:28
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.

Sanity Check KeysInterface on ChannelManager Deserialization
4 participants