-
Notifications
You must be signed in to change notification settings - Fork 38.7k
kernel, validation: Refactor ProcessNewBlockHeaders to return BlockValidationState #33856
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
base: master
Are you sure you want to change the base?
kernel, validation: Refactor ProcessNewBlockHeaders to return BlockValidationState #33856
Conversation
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. Code Coverage & BenchmarksFor details see: https://corecheck.dev/bitcoin/bitcoin/pulls/33856. ReviewsSee the guideline for information on the review process.
If your review is incorrectly listed, please copy-paste ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
hodlinator
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Concept ACK moving out-reference-parameters to return value
Not familiar with the kernel API but had a brief look at net_processing and validation.
|
Concept ACK |
6cdba25 to
1f589e1
Compare
|
🚧 At least one of the CI tasks failed. HintsTry to run the tests locally, according to the documentation. However, a CI failure may still
Leave a comment here, if you need help tracking down a confusing failure. |
|
Thanks for the review @hodlinator |
|
Concept ACK on refactoring bool to return state. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR eliminates the ambiguity of the boolean return value and improves the clarity of both the internal and kernel APIs.
ACK 1f589e1 (with the above-mentioned nit)
1f589e1 to
8d97193
Compare
|
Thanks for the review @w0xlt
|
8d97193 to
857ebdd
Compare
|
Thanks for the review @TheCharlatan.
|
857ebdd to
f31f7c2
Compare
|
I agree with @sedited comment, the belt-and-suspenders check in ActivateBestChain in validation.cpp is broken by this change. When So dropping the change in |
danielabrozzoni
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
light ACK f31f7c21ff7093a4c90199cd0bb2128d19bf2d33
Code looks good to me, and the interface is cleaner now. I'm only light-acking sicne I'm not familiar with the kernel :)
As I pointed out in a comment, I don't think we needed the Assume(!headers.empty()) at the start of ProcessNewBlockHeaders, but I'm ok with keeping it.
Add C API functions for managing BlockValidationState lifecycle: - btck_block_validation_state_create() - btck_block_validation_state_copy() - btck_block_validation_state_destroy() Introduce BlockValidationStateApi<> template to share common getter methods between BlockValidationState (Handle) and BlockValidationStateView (View) classes in the C++ wrapper. Update ValidationInterface::BlockChecked to use BlockValidationStateView since it doesn't need ownership. This changes prepares the kernel API to return BlockValidationState by value in subsequent commits.
Return BlockValidationState by value instead of using an out-parameter, similar to the TestBlockValidity refactoring in 74690f4. This provides a cleaner API and enables callers to inspect detailed validation state without relying on side effects through reference parameters.
f31f7c2 to
be379fd
Compare
w0xlt
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reACK be379fd
Motivation
This PR refactors
ProcessNewBlockHeaders()to returnBlockValidationStateby value instead of using out-parameters or boolean returns. This follows the pattern established in #31981 (commit 74690f4) which refactoredTestBlockValidity()in a similar manner.Current Issues
ProcessNewBlockHeaders(): Uses an out-parameter
BlockValidationState& state, making the API less intuitive.As noted by @TheCharlatan in #33822 comment and can be a fix for that too:
The changes are split into two commits, see individual commit message for more info.