Skip to content

refactor: deduplicate block validation state catcher - #36389

Closed
enochaz wants to merge 1 commit into
bitcoin:masterfrom
enochaz:master
Closed

enochaz wants to merge 1 commit into
bitcoin:masterfrom
enochaz:master

Conversation

@enochaz

@enochaz enochaz commented Sep 30, 2026

Copy link
Copy Markdown
Contributor

As mentioned in #34644 (comment) and #35675 (comment), the validation state catchers were defined in the block template manager, submitblock rpc and mining test helpers, even though they do the same thing.

Moved this helper into node/block_validation_state_catcher.h and reuse it across all three callers. An optional validation state replaces the separate found flag where used, preserving each caller's registration and result handling

@DrahtBot

DrahtBot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Code Coverage & Benchmarks

For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/36389.

Reviews

See the guideline and AI policy for information on the review process.

Type Reviewers
Concept ACK w0xlt

If your review is incorrectly listed, please copy-paste <!--meta-tag:bot-skip--> into the comment that the bot should ignore.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #36356 (mining: move getblocktemplate cache into BlockTemplateManager by w0xlt)
  • #35671 (mining: add TxCollection to bandwidth-efficiently validate external block templates by Sjors)
  • #33922 (mining: add getMemoryLoad() and track template non-mempool memory footprint by Sjors)

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.

LLM Linter (✨ experimental)

Possible places where named args for integral literals may be used (e.g. func(x, /*named_arg=*/0) in C++, and func(x, named_arg=0) in Python):

  • ProcessNewBlock(block, true, true, &new_block) in src/test/util/mining.cpp

2026-09-30 11:50:19

@DrahtBot

Copy link
Copy Markdown
Contributor

🚧 At least one of the CI tasks failed.
Task lint: https://github.com/bitcoin/bitcoin/actions/runs/36709743890/job/109868408911
LLM reason (✨ experimental): CI failed due to lint errors in src/node/block_validation_state_catcher.h—missing the required include guard and using quote-based #include instead of bracket syntax.

Hints

Try to run the tests locally, according to the documentation. However, a CI failure may still
happen due to a number of reasons, for example:

  • Possibly due to a silent merge conflict (the changes in this pull request being
    incompatible with the current code in the target branch). If so, make sure to rebase on the latest
    commit of the target branch.

  • A sanitizer issue, which can only be found by compiling with the sanitizer and running the
    affected test.

  • An intermittent issue.

Leave a comment here, if you need help tracking down a confusing failure.

Move the shared BlockValidationStateCatcher into a dedicated header
and reuse it it in the block template manager, submitblock rpc, and
mining test helpers

Use an optional validation state instead of a separate 'found' flag,
preserving each caller's existing result handling
@w0xlt

w0xlt commented Sep 30, 2026

Copy link
Copy Markdown
Contributor

Concept ACK

@enochaz

enochaz commented Oct 8, 2026

Copy link
Copy Markdown
Contributor Author

Had opened this on the wrong branch, closing this in favor of #36469

sedited added a commit that referenced this pull request Oct 14, 2026
c9cccf6 refactor: deduplicate block validation state catcher (Enoch Azariah)

Pull request description:

  As mentioned in #34644 (comment) and #35675 (comment), the validation state catchers were defined in the block template manager, `submitblock` rpc and mining test helpers, even though they do the same thing.

  Moved this helper into `node/block_validation_state_catcher.h` and reuse it across all three callers. An optional validation state replaces the separate `found` flag where used, preserving each caller's registration and result handling

  Replaces #36389 with the same commit on a dedicated branch.

ACKs for top commit:
  maflcko:
    review ACK c9cccf6 🖋
  ismaelsadeeq:
    ACK c9cccf6
  sedited:
    ACK c9cccf6
  w0xlt:
    ACK c9cccf6

Tree-SHA512: ae4bea2f2da9df4350099e5787e7743d07d86acf2c6e6150a9d7b9b659c14c217a07bfd3a0c8c6ee9a75043ff458aec0ea1d01ca86f89f6818866cca377e2318
Sjors pushed a commit to Sjors/bitcoin that referenced this pull request Oct 14, 2026
…cher

c9cccf6 refactor: deduplicate block validation state catcher (Enoch Azariah)

Pull request description:

  As mentioned in bitcoin#34644 (comment) and bitcoin#35675 (comment), the validation state catchers were defined in the block template manager, `submitblock` rpc and mining test helpers, even though they do the same thing.

  Moved this helper into `node/block_validation_state_catcher.h` and reuse it across all three callers. An optional validation state replaces the separate `found` flag where used, preserving each caller's registration and result handling

  Replaces bitcoin#36389 with the same commit on a dedicated branch.

ACKs for top commit:
  maflcko:
    review ACK c9cccf6 🖋
  ismaelsadeeq:
    ACK c9cccf6
  sedited:
    ACK c9cccf6
  w0xlt:
    ACK c9cccf6

Tree-SHA512: ae4bea2f2da9df4350099e5787e7743d07d86acf2c6e6150a9d7b9b659c14c217a07bfd3a0c8c6ee9a75043ff458aec0ea1d01ca86f89f6818866cca377e2318
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.

3 participants