Skip to content

Add .to_best_block() method to ValidatedBlockHeader #1777

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

Conversation

MaxFangX
Copy link
Contributor

@MaxFangX MaxFangX commented Oct 18, 2022

Adds a new method .to_best_block() to ValidatedBlockHeader which returns a BestBlock that nodes can pass into the channel manager during a fresh start, in order to prevent a possible race condition which eventually results in a channel manager panic when a node is started for the first time.

Required for the bugfix in lightningdevkit/ldk-sample#78.

@codecov-commenter
Copy link

codecov-commenter commented Oct 18, 2022

Codecov Report

Base: 90.86% // Head: 90.77% // Decreases project coverage by -0.08% ⚠️

Coverage data is based on head (a384bb1) compared to base (4ae65e8).
Patch has no changes to coverable lines.

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

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1777      +/-   ##
==========================================
- Coverage   90.86%   90.77%   -0.09%     
==========================================
  Files          86       87       +1     
  Lines       46482    46969     +487     
  Branches    46482    46969     +487     
==========================================
+ Hits        42234    42637     +403     
- Misses       4248     4332      +84     
Impacted Files Coverage Δ
lightning-block-sync/src/init.rs 90.90% <ø> (-2.66%) ⬇️
lightning-invoice/src/utils.rs 94.85% <0.00%> (-1.92%) ⬇️
lightning-invoice/src/payment.rs 89.85% <0.00%> (-1.02%) ⬇️
lightning/src/ln/chan_utils.rs 94.55% <0.00%> (-0.95%) ⬇️
lightning/src/ln/peer_handler.rs 55.96% <0.00%> (-0.74%) ⬇️
lightning/src/routing/router.rs 91.62% <0.00%> (-0.45%) ⬇️
lightning/src/util/enforcing_trait_impls.rs 89.07% <0.00%> (-0.40%) ⬇️
lightning-block-sync/src/test_utils.rs 93.14% <0.00%> (-0.33%) ⬇️
lightning-net-tokio/src/lib.rs 76.73% <0.00%> (-0.31%) ⬇️
... and 39 more

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.

@MaxFangX MaxFangX force-pushed the max/best-block-header-best-block branch from a384bb1 to 1712a13 Compare October 18, 2022 20:29
@MaxFangX MaxFangX requested a review from jkczyz October 18, 2022 20:47
@MaxFangX
Copy link
Contributor Author

Pushed changes @jkczyz, removed the new init function entirely and replaced it with a new .best_block() method on ValidatedBlockHeader. It's a lot cleaner this way, thanks for the suggestion!

@MaxFangX MaxFangX changed the title Implement validate_best_block_header_and_best_block() Add .best_block() method to ValidatedBlockHeader Oct 18, 2022
@MaxFangX MaxFangX force-pushed the max/best-block-header-best-block branch from 1712a13 to 4d75a90 Compare October 18, 2022 21:47
@MaxFangX MaxFangX changed the title Add .best_block() method to ValidatedBlockHeader Add .to_best_block() method to ValidatedBlockHeader Oct 18, 2022
@MaxFangX MaxFangX force-pushed the max/best-block-header-best-block branch from 4d75a90 to a9f8b6e Compare October 18, 2022 21:48
@MaxFangX MaxFangX requested a review from jkczyz October 18, 2022 21:50
@MaxFangX
Copy link
Contributor Author

Implemented once again @jkczyz

Copy link
Contributor

@jkczyz jkczyz 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 putting this together!

Copy link
Contributor

@tnull tnull left a comment

Choose a reason for hiding this comment

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

LGTM

@jkczyz jkczyz merged commit ee17faf into lightningdevkit:main Oct 19, 2022
@MaxFangX MaxFangX deleted the max/best-block-header-best-block branch October 21, 2022 08:05
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.

6 participants