WIP: Primitives: Combine assignments #35994

Draft
purpleKarrot wants to merge 8 commits from combine-assignments into master AGit
purpleKarrot commented 2026-08-17 13:22:18 +00:00 (Migrated from github.com)

#35904 mentions that validation code does not require the data members of COutPoint, CTxOut, and CTxIn to be individually mutable. This requirement instead comes from test code being written in a procedural rather than declarative style.

This PR presents a bitcoin-tidy check that identifies consecutive assignments to annotated data members of the same object and suggests rewriting them with a constructor invocation. This allows a mechanical refactoring of the majority of mutations and it paves the road for making the types fully immutable.

#35904 mentions that validation code does not require the data members of `COutPoint`, `CTxOut`, and `CTxIn` to be individually mutable. This requirement instead comes from test code being written in a procedural rather than declarative style. This PR presents a `bitcoin-tidy` check that identifies consecutive assignments to annotated data members of the same object and suggests rewriting them with a constructor invocation. This allows a mechanical refactoring of the majority of mutations and it paves the road for making the types fully immutable.
DrahtBot commented 2026-08-17 13:22:27 +00:00 (Migrated from github.com)

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

External sites

Reviews

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

Type Reviewers
Concept ACK l0rinc, josibake, alexanderwiederin

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:

  • #35733 (sign: Remove FillableSigningProvider by achow101)
  • #35580 (bugfix: compare non-adjusted chunk weight against block weight limit by ismaelsadeeq)
  • #35569 (Encapsulation for CTransaction by purpleKarrot)
  • #35477 (test: exercise Schnorr signature cache in txvalidationcache_tests.cpp by theStack)
  • #34360 (bench: add WalletBalanceManySpent for high-history wallet scenario by w0xlt)

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.

<!--e57a25ab6845829454e8d69fc972939a--> The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. <!--006a51241073e994b41acfe9ec718e94--> ### External sites * Code coverage & benchmarks: https://corecheck.dev/bitcoin/bitcoin/pulls/35994 * Ralph review <img src=https://review.fish.foo/assets/bitcoin/bitcoin/35994.png alt="Ralph review status"> https://git.fish.foo/bitcoin/bitcoin/pulls/35994#author-ralph <!--021abf342d371248e50ceaed478a90ca--> ### Reviews See [the guideline](https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#code-review) and [AI policy](https://github.com/bitcoin/bitcoin/blob/master/doc/AI_POLICY.md) for information on the review process. | Type | Reviewers | | ---- | --------- | | Concept ACK | [l0rinc](https://github.com/bitcoin/bitcoin/pull/35994#issuecomment-5319813498), [josibake](https://github.com/bitcoin/bitcoin/pull/35994#issuecomment-5332099006), [alexanderwiederin](https://github.com/bitcoin/bitcoin/pull/35994#pullrequestreview-4965218337) | If your review is incorrectly listed, please copy-paste <code>&lt;!--meta-tag:bot-skip--&gt;</code> into the comment that the bot should ignore. <!--174a7506f384e20aa4161008e828411d--> ### Conflicts Reviewers, this pull request conflicts with the following ones: * [#35733](https://github.com/bitcoin/bitcoin/pull/35733) (sign: Remove FillableSigningProvider by achow101) * [#35580](https://github.com/bitcoin/bitcoin/pull/35580) (bugfix: compare non-adjusted chunk weight against block weight limit by ismaelsadeeq) * [#35569](https://github.com/bitcoin/bitcoin/pull/35569) (Encapsulation for CTransaction by purpleKarrot) * [#35477](https://github.com/bitcoin/bitcoin/pull/35477) (test: exercise Schnorr signature cache in txvalidationcache_tests.cpp by theStack) * [#34360](https://github.com/bitcoin/bitcoin/pull/34360) (bench: add WalletBalanceManySpent for high-history wallet scenario by w0xlt) 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. <!--5faf32d7da4f0f540f40219e4f7537a3-->
DrahtBot commented 2026-08-17 19:30:02 +00:00 (Migrated from github.com)

🚧 At least one of the CI tasks failed.
Task 32 bit ARM: https://github.com/bitcoin/bitcoin/actions/runs/32057506973/job/95470930565
LLM reason (✨ experimental): CI failed at compile time because transaction.h is inconsistent with the COutPoint/CTxIn/CTxOut class definitions (missing fields like hash/n, prevout, scriptSig, etc.).

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.

<!--85328a0da195eb286784d51f73fa0af9--> 🚧 At least one of the CI tasks failed. <sub>Task `32 bit ARM`: https://github.com/bitcoin/bitcoin/actions/runs/32057506973/job/95470930565</sub> <sub>LLM reason (✨ experimental): CI failed at compile time because `transaction.h` is inconsistent with the `COutPoint`/`CTxIn`/`CTxOut` class definitions (missing fields like `hash`/`n`, `prevout`, `scriptSig`, etc.).</sub> <details><summary>Hints</summary> 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. </details>
l0rinc commented 2026-08-17 20:22:20 +00:00 (Migrated from github.com)

I understand that it's not always trivial to run every check locally, but we're getting notifications about every push and it doesn't really increase the confidence in changes like this if they don't even pass CI.
I usually push these to my own fork first to make sure the change makes sense before pushing here.
Also, the Primitives: Combine assignments give no clue about what this PR is about, but reading the code seems to make sense, concept ACK.

I understand that it's not always trivial to run every check locally, but we're getting notifications about every push and it doesn't really increase the confidence in changes like this if they don't even pass CI. I usually push these to my own fork first to make sure the change makes sense before pushing here. Also, the `Primitives: Combine assignments` give no clue about what this PR is about, but reading the code seems to make sense, concept ACK.
maflcko (Migrated from github.com) reviewed 2026-08-18 05:39:44 +00:00
maflcko (Migrated from github.com) left a comment

Looks like this is mostly a test-only cleanup (modulo ~6 instances in real code).

Seems fine, as this should reduce test issues due to re-using dirty state accidentally (c.f. https://github.com/bitcoin/bitcoin/pull/35863 et al)

Looks like this is mostly a test-only cleanup (modulo ~6 instances in real code). Seems fine, as this should reduce test issues due to re-using dirty state accidentally (c.f. https://github.com/bitcoin/bitcoin/pull/35863 et al)
maflcko (Migrated from github.com) commented 2026-08-18 05:36:59 +00:00

Is there a reason to not use the C++11 narrowing checks for new code? Other places use a static_cast<uint32_t>() for the second arg, and I think this is useful to know about and be explicit.

    t1.vin[2].prevout = COutPoint{dummyTransactions[1].GetHash(), 1};
Is there a reason to not use the C++11 narrowing checks for new code? Other places use a `static_cast<uint32_t>()` for the second arg, and I think this is useful to know about and be explicit. ```suggestion t1.vin[2].prevout = COutPoint{dummyTransactions[1].GetHash(), 1}; ```
maflcko (Migrated from github.com) commented 2026-08-18 05:35:09 +00:00

Is the annotation really required? I'd guess that clang-tidy should be able to iterator over all ctors with args itself and then derive this itself?

The benefit would be that there is only a single source of truth and this won't go stale. Also, manual marking wouldn't be needed. (If you want to limit this to a selected set of classes, it would be better to pass the list as an option to clang-tidy?)

Is the annotation really required? I'd guess that clang-tidy should be able to iterator over all ctors with args itself and then derive this itself? The benefit would be that there is only a single source of truth and this won't go stale. Also, manual marking wouldn't be needed. (If you want to limit this to a selected set of classes, it would be better to pass the list as an option to clang-tidy?)
maflcko (Migrated from github.com) reviewed 2026-08-18 05:40:55 +00:00
maflcko (Migrated from github.com) commented 2026-08-18 05:40:55 +00:00
        CheckFactories.registerCheck<CombineAssignments>("bitcoin-prefer-ctor");

Given that the was confusion about the name, maybe name it differently?

```suggestion CheckFactories.registerCheck<CombineAssignments>("bitcoin-prefer-ctor"); ``` Given that the was confusion about the name, maybe name it differently?
purpleKarrot commented 2026-08-18 07:29:40 +00:00 (Migrated from github.com)

I pushed this both to back the claim that most mutations appear in test code, but also as a base for discussion about the approach.

One approach would be to submit this PR as is.

An alternative approach would be to focus on one class at a time, like "COutPoint: Make type immutable". Such a PR would then apply bitcoin-prefer-ctor as introduced here, bitcoin-use-observers from #35569, some manual fixes, plus the change to make the data members private. In this approach, https://github.com/bitcoin/bitcoin/pull/35994#discussion_r3801299334 would be less of an issue, because the annotations would be temporary anyway.

Yet another approach would be to just use this PR as a backlog to identify "places of interest" and then rewrite the code manually, one file at a time, in a declarative style. For example, this code:

github.com/bitcoin/bitcoin@6751a323c0/src/bench/ccoins_caching.cpp (L35-L51)

could be rewritten (assuming the necessary constructors are made available) as:

const CTransaction tx_1{
    std::vector{
        CTxIn{COutPoint{dummyTransactions[0].GetHash(), 1}, CScript{} << std::vector<unsigned char>(65, 0)},
        CTxIn{COutPoint{dummyTransactions[1].GetHash(), 0}, CScript{} << std::vector<unsigned char>(65, 0) << std::vector<unsigned char>(33, 4)},
        CTxIn{COutPoint{dummyTransactions[1].GetHash(), 1}, CScript{} << std::vector<unsigned char>(65, 0) << std::vector<unsigned char>(33, 4)},
    },
    std::vector{
        CTxOut{90 * COIN, CScript{} << OP_1},
        CTxOut{},
    },
};

In this approach, https://github.com/bitcoin/bitcoin/pull/35994#discussion_r3801307204 can be applied directly, with explicit conversions where necessary.

I pushed this both to back the claim that most mutations appear in test code, but also as a base for discussion about the approach. One approach would be to submit this PR as is. An alternative approach would be to focus on one class at a time, like "COutPoint: Make type immutable". Such a PR would then apply `bitcoin-prefer-ctor` as introduced here, `bitcoin-use-observers` from #35569, some manual fixes, plus the change to make the data members private. In this approach, https://github.com/bitcoin/bitcoin/pull/35994#discussion_r3801299334 would be less of an issue, because the annotations would be temporary anyway. Yet another approach would be to just use this PR as a backlog to identify "places of interest" and then rewrite the code manually, one file at a time, in a declarative style. For example, this code: https://github.com/bitcoin/bitcoin/blob/6751a323c0130310880c84e03f7104f6bb86385d/src/bench/ccoins_caching.cpp#L35-L51 could be rewritten (assuming the necessary constructors are made available) as: ```cpp const CTransaction tx_1{ std::vector{ CTxIn{COutPoint{dummyTransactions[0].GetHash(), 1}, CScript{} << std::vector<unsigned char>(65, 0)}, CTxIn{COutPoint{dummyTransactions[1].GetHash(), 0}, CScript{} << std::vector<unsigned char>(65, 0) << std::vector<unsigned char>(33, 4)}, CTxIn{COutPoint{dummyTransactions[1].GetHash(), 1}, CScript{} << std::vector<unsigned char>(65, 0) << std::vector<unsigned char>(33, 4)}, }, std::vector{ CTxOut{90 * COIN, CScript{} << OP_1}, CTxOut{}, }, }; ``` In this approach, https://github.com/bitcoin/bitcoin/pull/35994#discussion_r3801307204 can be applied directly, with explicit conversions where necessary.
purpleKarrot (Migrated from github.com) reviewed 2026-08-18 07:35:17 +00:00
purpleKarrot (Migrated from github.com) commented 2026-08-18 07:35:17 +00:00

Yes, there are a few places where aggregate initialization would not compile, unfortunately.

Yes, there are a few places where aggregate initialization would not compile, unfortunately.
purpleKarrot (Migrated from github.com) reviewed 2026-08-18 07:46:32 +00:00
purpleKarrot (Migrated from github.com) commented 2026-08-18 07:46:32 +00:00

I don't want to build too many heuristics into the clang-tidy check. But depending on how we approach the change, it may be less of an issue or not be needed at all (see https://github.com/bitcoin/bitcoin/pull/35994#issuecomment-5325013842).

I don't want to build too many heuristics into the clang-tidy check. But depending on how we approach the change, it may be less of an issue or not be needed at all (see https://github.com/bitcoin/bitcoin/pull/35994#issuecomment-5325013842).
maflcko (Migrated from github.com) reviewed 2026-08-18 10:45:21 +00:00
maflcko (Migrated from github.com) commented 2026-08-18 10:45:21 +00:00

Ok, I see. I wonder if it is worth it to update them manually (either by adding a static_cast, or by updating the outer type to unsigned, or so)?

Given that such a patch should be easy to review and test-only, with other benefits, it seems fine to submit it and I'd be happy to review it, but no strong opinion.

Ok, I see. I wonder if it is worth it to update them manually (either by adding a static_cast, or by updating the outer type to `unsigned`, or so)? Given that such a patch should be easy to review and test-only, with other benefits, it seems fine to submit it and I'd be happy to review it, but no strong opinion.
janb84 commented 2026-08-18 11:56:27 +00:00 (Migrated from github.com)

If i'm not mistaken, I read 3 options from the comment of purpleKarrot:

A. Merge this PR as is. The tooling lands in this PR but needs annotations to work. The drawback is that the CONSTRUCTOR_ARGUMENT annotations stay in primitives/transaction.h with no guarantee that a follow-up removes them, and reviewers approve a large mechanical diff with the justification in a future PR.

B. One class at a time, ending in "immutability". For example "COutPoint: Make type immutable": annotate, run the check, run use-observers from #35569, fix the rest by hand, make the members private, and delete the annotations in the same PR. Each PR is self contained and can be judged as a whole if the change is worth the churn.

C. Use the check as a backlog only. Never merge the annotations. Run the check locally to find candidate files and rewrite them by hand in declarative style.

--

Personally I would opt for option B, where a tracking issue can be used to identify and coordinate the effort, keep this bitcoin-tidy code etc. If i'm not mistaken (or mis-understood the comment) this will result in PR's that are self contained with no, or little, follow ups so that the benefits, churn and results are clearly visible in one PR.

If i'm not mistaken, I read 3 options from the [comment of purpleKarrot:](https://github.com/bitcoin/bitcoin/pull/35994#issuecomment-5325013842) **A. Merge this PR as is.** The tooling lands in this PR but needs annotations to work. The drawback is that the `CONSTRUCTOR_ARGUMENT` annotations stay in `primitives/transaction.h` with no guarantee that a follow-up removes them, and reviewers approve a large mechanical diff with the justification in a future PR. **B. One class at a time, ending in "immutability".** For example "COutPoint: Make type immutable": annotate, run the check, run use-observers from #35569, fix the rest by hand, make the members private, and delete the annotations in the same PR. Each PR is self contained and can be judged as a whole if the change is worth the churn. **C. Use the check as a backlog only.** Never merge the annotations. Run the check locally to find candidate files and rewrite them by hand in declarative style. -- Personally I would opt for option B, where a tracking issue can be used to identify and coordinate the effort, keep this bitcoin-tidy code etc. If i'm not mistaken (or mis-understood the comment) this will result in PR's that are self contained with no, or little, follow ups so that the benefits, churn and results are clearly visible in one PR.
maflcko commented 2026-08-18 12:28:13 +00:00 (Migrated from github.com)

I am not sure about throwing this in the same bucket as https://github.com/bitcoin/bitcoin/pull/35569. I think it is pretty clear that a CTransaction should not be mutable (otherwise there wouldn't be a MutableTransaction).

However, for other structs, is there much value/benefit? https://github.com/bitcoin/bitcoin/pull/35569 seems a bit controversial, so expanding it to stuff that has even less benefit may not be the best approach?

I'd leave this a mostly test-only cleanup (plus maybe https://github.com/bitcoin/bitcoin/pull/35994#discussion_r3803317221), but no strong opinion.

I am not sure about throwing this in the same bucket as https://github.com/bitcoin/bitcoin/pull/35569. I think it is pretty clear that a CTransaction should not be mutable (otherwise there wouldn't be a MutableTransaction). However, for other structs, is there much value/benefit? https://github.com/bitcoin/bitcoin/pull/35569 seems a bit controversial, so expanding it to stuff that has even less benefit may not be the best approach? I'd leave this a mostly test-only cleanup (plus maybe https://github.com/bitcoin/bitcoin/pull/35994#discussion_r3803317221), but no strong opinion.
josibake commented 2026-08-18 18:01:39 +00:00 (Migrated from github.com)

Concept ACK

However, for other structs, is there much value/benefit?

Cleaning up the tests is a convention. It does nothing to stop the same buggy behaviour being repeated in the future. Can you explain what benefit you see to keeping the structs in this PR mutable?

Concept ACK > However, for other structs, is there much value/benefit? Cleaning up the tests is a convention. It does nothing to stop the same buggy behaviour being repeated in the future. Can you explain what benefit you see to keeping the structs in this PR mutable?
alexanderwiederin (Migrated from github.com) reviewed 2026-08-18 19:55:10 +00:00
alexanderwiederin (Migrated from github.com) commented 2026-08-18 19:55:10 +00:00

I tried switching the fix-it to emit {}. From what I can tell everything that then fails to compile is in test/bench.

I tried switching the fix-it to emit {}. From what I can tell everything that then fails to compile is in test/bench.
alexanderwiederin (Migrated from github.com) reviewed 2026-08-18 20:16:42 +00:00
alexanderwiederin (Migrated from github.com) left a comment

Concept ACK

Do the checks here need to be run to a fixed point or is a single pass sufficient? Might be worth adding the invocation in the commit messages, so the mechanical changes can be verified.

Concept ACK Do the checks here need to be run to a fixed point or is a single pass sufficient? Might be worth adding the invocation in the commit messages, so the mechanical changes can be verified.
alexanderwiederin (Migrated from github.com) commented 2026-08-18 19:57:43 +00:00

Does this drop the witness?

Does this drop the witness?
purpleKarrot (Migrated from github.com) reviewed 2026-08-18 20:22:28 +00:00
purpleKarrot (Migrated from github.com) commented 2026-08-18 20:22:28 +00:00

Indeed.

Indeed.
purpleKarrot commented 2026-08-18 20:38:13 +00:00 (Migrated from github.com)

I am not sure about throwing this in the same bucket as https://github.com/bitcoin/bitcoin/pull/35569. I think it is pretty clear that a CTransaction should not be mutable (otherwise there wouldn't be a MutableTransaction).

They do belong into the same bucket. As I wrote in https://github.com/bitcoin/bitcoin/pull/35569#issuecomment-5281383955:

The idea of having an immutable type associated with a "builder" is alien to C++. It is a necessary evil in languages built on reference semantics, where this pattern is very common. You can compare how strings work differently in C++ vs C#. The fundamental idea is that mutability and sharing should be mutually exclusive to prevent conflicts. Where everything is shared by default (C#), you want to restrict mutation. When things are copied by default (C++), mutation is less of an issue.

For CTransaction however (and also for CBlock, CTxIn, CTxOut, and COutPoint), mutation is a rare use case.
Those types should be made immutable, with no associated builder (no CMutableTransaction), and code that "builds" those types in procedural code should be rewritten in a declarative style (this mostly affects test code).

Which is exactly the claim that I wanted to back with this draft.

Concerning the approach, I actually lean towards C.

> I am not sure about throwing this in the same bucket as https://github.com/bitcoin/bitcoin/pull/35569. I think it is pretty clear that a CTransaction should not be mutable (otherwise there wouldn't be a MutableTransaction). They do belong into the same bucket. As I wrote in https://github.com/bitcoin/bitcoin/pull/35569#issuecomment-5281383955: > The idea of having an immutable type associated with a "builder" is alien to C++. It is a necessary evil in languages built on reference semantics, where this pattern is very common. You can compare how strings work differently in C++ vs C#. The fundamental idea is that mutability and sharing should be mutually exclusive to prevent conflicts. Where everything is shared by default (C#), you want to restrict mutation. When things are copied by default (C++), mutation is less of an issue. > > For `CTransaction` however (and also for `CBlock`, `CTxIn`, `CTxOut`, and `COutPoint`), mutation is a rare use case. Those types should be made immutable, with no associated builder (no `CMutableTransaction`), and code that "builds" those types in procedural code should be rewritten in a declarative style (this mostly affects test code). Which is exactly the claim that I wanted to back with this draft. Concerning the approach, I actually lean towards **C**.
alexanderwiederin commented 2026-08-19 08:02:50 +00:00 (Migrated from github.com)

I actually lean towards C.

That sounds reasonable to me. It means the surrounding context gets read, the narrowing conversions get made explicit and comments in the affected blocks survive.

I've started on a couple of these in /bench. Happy to keep going if that's useful.

> I actually lean towards **C**. That sounds reasonable to me. It means the surrounding context gets read, the narrowing conversions get made explicit and comments in the affected blocks survive. I've started on a couple of these in `/bench`. Happy to keep going if that's useful.
DrahtBot commented 2026-08-21 08:16:41 +00:00 (Migrated from github.com)

🐙 This pull request conflicts with the target branch and needs rebase.

<!--cf906140f33d8803c4a75a2196329ecb--> 🐙 This pull request conflicts with the target branch and [needs rebase](https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#rebasing-changes).
DrahtBot commented 2026-08-21 10:53:23 +00:00 (Migrated from github.com)

🚧 At least one of the CI tasks failed.
Task tidy: https://github.com/bitcoin/bitcoin/actions/runs/32467526648/job/96727213621
LLM reason (✨ experimental): Clang-tidy failed due to bitcoin-combine-assignments warnings-as-errors in test/mempool_fee_estimator_tests.cpp (separate member assignments not combined).

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.

<!--85328a0da195eb286784d51f73fa0af9--> 🚧 At least one of the CI tasks failed. <sub>Task `tidy`: https://github.com/bitcoin/bitcoin/actions/runs/32467526648/job/96727213621</sub> <sub>LLM reason (✨ experimental): Clang-tidy failed due to `bitcoin-combine-assignments` warnings-as-errors in `test/mempool_fee_estimator_tests.cpp` (separate member assignments not combined).</sub> <details><summary>Hints</summary> 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. </details>
maflcko (Migrated from github.com) reviewed 2026-08-24 08:50:20 +00:00
maflcko (Migrated from github.com) commented 2026-08-24 08:50:20 +00:00
should probably use init-list, like https://github.com/bitcoin/bitcoin/pull/36019#discussion_r3811388178
DrahtBot commented 2026-08-24 09:18:57 +00:00 (Migrated from github.com)

🐙 This pull request conflicts with the target branch and needs rebase.

<!--cf906140f33d8803c4a75a2196329ecb--> 🐙 This pull request conflicts with the target branch and [needs rebase](https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#rebasing-changes).
maflcko commented 2026-10-29 16:30:55 +00:00 (Migrated from github.com)

CI is red and this draft is inactive for months. I guess it can be closed?

CI is red and this draft is inactive for months. I guess it can be closed?
First-time contributor

🔴 Major · The new check makes tidy CI fail on an unconverted test file

With bitcoin-* enabled and WarningsAsErrors: '*', the untouched MakeRandomTx assignments in mempool_fee_estimator_tests.cpp should make the tidy job fail; this is inferred from the code, not a CI run.

Location: contrib/devtools/bitcoin-tidy/bitcoin-tidy.cpp:15 (head).

🟠 Minor · BuildSpendingTransaction drops the supplied script witness

The helper returns an input without the caller's witness, although current tests still pass because DoTest supplies that witness directly to VerifyScript.

Location: src/test/util/transaction_utils.cpp:33 (head).

🟠 Minor · The fix-it can change side effects, dependencies, and repeated assignments

The rewrite is not always equivalent; in this change it also makes the order of RNG draws in sighash_tests.cpp unspecified.

Location: contrib/devtools/bitcoin-tidy/combine-assignments.cpp:169 (head).

🟠 Minor · Compound assignments are rewritten as plain assignments

A compound update followed by another annotated-field assignment can be rewritten to a constructor that drops the existing value and the compound operation; no current in-tree site with this shape was identified.

Location: contrib/devtools/bitcoin-tidy/combine-assignments.cpp:72 (head).

🔵 Suggestion · Annotations reach ordinary Clang builds of hot transaction fields

Clang lowers accesses to annotated fields through llvm.ptr.annotation, which can inhibit optimization; the impact on Bitcoin Core has not been measured.

Location: src/attributes.h:29 (head).

🔵 Suggestion · The fix-it deletes comments between combined statements

The mechanical rewrite silently removed explanatory comments from several tests in this change.

Location: contrib/devtools/bitcoin-tidy/combine-assignments.cpp:174 (head).

Review coverage was incomplete.


Reviewed: 95ea8fca11e4 · Full review report · Previous reports

<!-- forgejo-review-bot:bitcoin/bitcoin --> <!-- ralph-engine:current:6f232c871bca65facadc248ad7ecd634f87b0b5f6936bc30593af890589888f1:0cfbbc826fdd30e42f35c9a5b7d389c0902089c94f2400654bb32123e69823f6 --> <!-- ralph-base:6ed5aad06111177c39f9b9f07a52634476380ae1 --> <!-- ralph-head:95ea8fca11e459354b99d90d83280eefd5621c86 --> <!-- ralph-case:1954ac872a1410313034cb4a21ea00cdfa7d6e815eb339f8e03ec9f950364ea4 --> **🔴 Major · The new check makes tidy CI fail on an unconverted test file** With `bitcoin-*` enabled and `WarningsAsErrors: '*'`, the untouched `MakeRandomTx` assignments in `mempool_fee_estimator_tests.cpp` should make the tidy job fail; this is inferred from the code, not a CI run. Location: [`contrib/devtools/bitcoin-tidy/bitcoin-tidy.cpp:15`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/95ea8fca11e459354b99d90d83280eefd5621c86/contrib/devtools/bitcoin-tidy/bitcoin-tidy.cpp#L15>) (head). **🟠 Minor · BuildSpendingTransaction drops the supplied script witness** The helper returns an input without the caller's witness, although current tests still pass because `DoTest` supplies that witness directly to `VerifyScript`. Location: [`src/test/util/transaction_utils.cpp:33`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/95ea8fca11e459354b99d90d83280eefd5621c86/src/test/util/transaction_utils.cpp#L33>) (head). **🟠 Minor · The fix-it can change side effects, dependencies, and repeated assignments** The rewrite is not always equivalent; in this change it also makes the order of RNG draws in `sighash_tests.cpp` unspecified. Location: [`contrib/devtools/bitcoin-tidy/combine-assignments.cpp:169`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/95ea8fca11e459354b99d90d83280eefd5621c86/contrib/devtools/bitcoin-tidy/combine-assignments.cpp#L169>) (head). **🟠 Minor · Compound assignments are rewritten as plain assignments** A compound update followed by another annotated-field assignment can be rewritten to a constructor that drops the existing value and the compound operation; no current in-tree site with this shape was identified. Location: [`contrib/devtools/bitcoin-tidy/combine-assignments.cpp:72`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/95ea8fca11e459354b99d90d83280eefd5621c86/contrib/devtools/bitcoin-tidy/combine-assignments.cpp#L72>) (head). **🔵 Suggestion · Annotations reach ordinary Clang builds of hot transaction fields** Clang lowers accesses to annotated fields through `llvm.ptr.annotation`, which can inhibit optimization; the impact on Bitcoin Core has not been measured. Location: [`src/attributes.h:29`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/95ea8fca11e459354b99d90d83280eefd5621c86/src/attributes.h#L29>) (head). **🔵 Suggestion · The fix-it deletes comments between combined statements** The mechanical rewrite silently removed explanatory comments from several tests in this change. Location: [`contrib/devtools/bitcoin-tidy/combine-assignments.cpp:174`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/95ea8fca11e459354b99d90d83280eefd5621c86/contrib/devtools/bitcoin-tidy/combine-assignments.cpp#L174>) (head). Review coverage was incomplete. <!-- Review tier: sensitive --> --- Reviewed: [`95ea8fca11e4`](<https://git.fish.foo/bitcoin/bitcoin/commit/95ea8fca11e459354b99d90d83280eefd5621c86>) · [Full review report](<https://review.fish.foo/traces/35994-95ea8fca11e459354b99d90d83280eefd5621c86-1712-1.html>) · [Previous reports](<https://review.fish.foo/traces/35994/>)
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
bitcoin/bitcoin!35994
No description provided.