test: fix coinbases built on arbitrary parents #36109

Manually merged
l0rinc merged 5 commits from l0rinc/test-build-valid-fork-blocks into master 2026-11-24 22:52:02 +00:00 AGit
l0rinc commented 2026-08-28 00:17:31 +00:00 (Migrated from github.com)

Problem: Test helpers that attach active-tip templates to arbitrary parents retain the template's subsidy.
Existing reorg tests can pass with underpaid coinbases.
A fork crossing a halving can overpay and fail with bad-cb-amount.
At heights 1 through 16, encoding only the height leaves the coinbase input script too short and triggers bad-cb-length.

Fix: Share parent-dependent reconstruction between BuildChain() and MinerTestingSetup::Block(), deriving difficulty and coinbase fields from the actual parent.
Pad rebuilt coinbase input scripts.
Require coinbase-only templates so replacing the reward with the subsidy cannot discard transaction fees.

**Problem:** Test helpers that attach active-tip templates to arbitrary parents retain the template's subsidy. Existing reorg tests can pass with underpaid coinbases. A fork crossing a halving can overpay and fail with `bad-cb-amount`. At heights 1 through 16, encoding only the height leaves the coinbase input script too short and triggers `bad-cb-length`. **Fix:** Share parent-dependent reconstruction between `BuildChain()` and `MinerTestingSetup::Block()`, deriving difficulty and coinbase fields from the actual parent. Pad rebuilt coinbase input scripts. Require coinbase-only templates so replacing the reward with the subsidy cannot discard transaction fees.
DrahtBot commented 2026-08-28 00:17:38 +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
ACK maflcko, jeanpablojp, Sjors, achow101

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:

  • #36918 (Witness stacks in serialized form (optimization follow-ups) by sipa)
  • #36909 (kernel: add btck_witness_stack_get_items by pzafonte)
  • #36895 (Keep witness stacks in serialized form in CScriptWitness by sipa)
  • #36792 (validation: avoid partial override of non-valid validation state by optout21)
  • #35570 (refactor: Change some validation.cpp methods to return BlockValidationState by optout21)

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/36109 * Ralph review <img src=https://review.fish.foo/assets/bitcoin/bitcoin/36109.png alt="Ralph review status"> https://git.fish.foo/bitcoin/bitcoin/pulls/36109#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 | | ---- | --------- | | ACK | [maflcko](https://github.com/bitcoin/bitcoin/pull/36109#issuecomment-6978850564), [jeanpablojp](https://github.com/bitcoin/bitcoin/pull/36109#issuecomment-6980793397), [Sjors](https://github.com/bitcoin/bitcoin/pull/36109#issuecomment-7006064058), [achow101](https://github.com/bitcoin/bitcoin/pull/36109#issuecomment-7146452953) | 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: * [#36918](https://github.com/bitcoin/bitcoin/pull/36918) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36918.svg"></sub> (Witness stacks in serialized form (optimization follow-ups) by sipa) * [#36909](https://github.com/bitcoin/bitcoin/pull/36909) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36909.svg"></sub> (kernel: add btck_witness_stack_get_items by pzafonte) * [#36895](https://github.com/bitcoin/bitcoin/pull/36895) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36895.svg"></sub> (Keep witness stacks in serialized form in CScriptWitness by sipa) * [#36792](https://github.com/bitcoin/bitcoin/pull/36792) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36792.svg"></sub> (validation: avoid partial override of non-valid validation state by optout21) * [#35570](https://github.com/bitcoin/bitcoin/pull/35570) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/35570.svg"></sub> (refactor: Change some validation.cpp methods to return BlockValidationState by optout21) 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-->
jeanpablojp (Migrated from github.com) reviewed 2026-09-08 18:27:14 +00:00
jeanpablojp (Migrated from github.com) left a comment

Concept ACK

Built each commit and ran the unit tests, with a before and after of both cases against master.

Concept ACK Built each commit and ran the unit tests, with a before and after of both cases against master.
jeanpablojp (Migrated from github.com) commented 2026-09-08 18:27:14 +00:00

Removing the target, subsidy or padding line here leaves blockfilter_index_tests and baseindex_tests green, so nothing on that side covers what the branch changes. The new assertions in MinerTestingSetup::Block catch the subsidy and the padding, and the target has nothing anywhere.

These two cover all four fields, if they are worth having. The target one calls the helper directly, which is the only way in, since on regtest the recalculated target always equals the template's and no chain can tell the line apart. The coinbase one passes here and fails on master, first on the script length and then at the halving block. Both compile in blockfilter_index_tests.cpp.

BOOST_FIXTURE_TEST_CASE(rebuild_block_for_parent_target, RegTestingSetup)
{
    const auto& consensus{Params().GetConsensus()};
    const auto genesis{Params().GenesisBlock()};
    const auto parent_hash{genesis.GetHash()};
    CBlockIndex parent{genesis};
    parent.phashBlock = &parent_hash;
    --parent.nBits; // A valid target, different from the one the template carries.

    // Regtest allows min-difficulty blocks, and parent has no pprev, so
    // GetNextWorkRequired returns the parent's target below the threshold and the
    // pow limit above it.
    const auto threshold{uint32_t(2 * consensus.nPowTargetSpacing)};
    for (const auto delay : {1U, threshold, threshold + 1}) {
        CBlock block{genesis};
        RebuildBlockForParent(block, parent, parent.nTime + delay, consensus);
        BOOST_CHECK_EQUAL(block.nBits, delay > threshold ? genesis.nBits : parent.nBits);
    }
}

BOOST_FIXTURE_TEST_CASE(rebuild_block_for_parent_coinbase, TestChain100Setup)
{
    const auto& consensus{Params().GetConsensus()};
    auto process = [&](const std::vector<std::shared_ptr<CBlock>>& chain) {
        for (const auto& block : chain) {
            BOOST_CHECK(m_node.chainman->ProcessNewBlock(block, /*force_processing=*/true, /*min_pow_checked=*/true, nullptr));
        }
    };

    // A fork rooted below height 17 needs the dummy OP_0, since the BIP34
    // height alone is one byte there (bad-cb-length).
    {
        const CBlockIndex* genesis{WITH_LOCK(cs_main, return m_node.chainman->ActiveChain().Genesis())};
        std::vector<std::shared_ptr<CBlock>> fork;
        BOOST_REQUIRE(BuildChain(m_node, genesis, CScript() << OP_TRUE, 3, fork));
        BOOST_CHECK_EQUAL(fork.front()->vtx[0]->vin[0].scriptSig.size(), 2U);
        process(fork);
    }

    // BuildChain only submits headers, so every template keeps being built on
    // the active tip. A chain long enough to pass the halving would otherwise
    // carry the tip's subsidy and fail to connect (bad-cb-amount).
    {
        const CBlockIndex* tip{WITH_LOCK(cs_main, return m_node.chainman->ActiveChain().Tip())};
        const int start{tip->nHeight};
        const int length{consensus.nSubsidyHalvingInterval + 10 - start};
        BOOST_REQUIRE(length > 0);
        std::vector<std::shared_ptr<CBlock>> chain;
        BOOST_REQUIRE(BuildChain(m_node, tip, CScript() << OP_TRUE, length, chain));
        for (int i = 0; i < length; ++i) {
            BOOST_CHECK_EQUAL(chain.at(i)->vtx[0]->vout[0].nValue, GetBlockSubsidy(start + 1 + i, consensus));
        }
        process(chain);
        BOOST_CHECK_EQUAL(WITH_LOCK(cs_main, return m_node.chainman->ActiveChain().Height()), start + length);
    }
}
Removing the target, subsidy or padding line here leaves `blockfilter_index_tests` and `baseindex_tests` green, so nothing on that side covers what the branch changes. The new assertions in `MinerTestingSetup::Block` catch the subsidy and the padding, and the target has nothing anywhere. These two cover all four fields, if they are worth having. The target one calls the helper directly, which is the only way in, since on regtest the recalculated target always equals the template's and no chain can tell the line apart. The coinbase one passes here and fails on master, first on the script length and then at the halving block. Both compile in `blockfilter_index_tests.cpp`. ```cpp BOOST_FIXTURE_TEST_CASE(rebuild_block_for_parent_target, RegTestingSetup) { const auto& consensus{Params().GetConsensus()}; const auto genesis{Params().GenesisBlock()}; const auto parent_hash{genesis.GetHash()}; CBlockIndex parent{genesis}; parent.phashBlock = &parent_hash; --parent.nBits; // A valid target, different from the one the template carries. // Regtest allows min-difficulty blocks, and parent has no pprev, so // GetNextWorkRequired returns the parent's target below the threshold and the // pow limit above it. const auto threshold{uint32_t(2 * consensus.nPowTargetSpacing)}; for (const auto delay : {1U, threshold, threshold + 1}) { CBlock block{genesis}; RebuildBlockForParent(block, parent, parent.nTime + delay, consensus); BOOST_CHECK_EQUAL(block.nBits, delay > threshold ? genesis.nBits : parent.nBits); } } BOOST_FIXTURE_TEST_CASE(rebuild_block_for_parent_coinbase, TestChain100Setup) { const auto& consensus{Params().GetConsensus()}; auto process = [&](const std::vector<std::shared_ptr<CBlock>>& chain) { for (const auto& block : chain) { BOOST_CHECK(m_node.chainman->ProcessNewBlock(block, /*force_processing=*/true, /*min_pow_checked=*/true, nullptr)); } }; // A fork rooted below height 17 needs the dummy OP_0, since the BIP34 // height alone is one byte there (bad-cb-length). { const CBlockIndex* genesis{WITH_LOCK(cs_main, return m_node.chainman->ActiveChain().Genesis())}; std::vector<std::shared_ptr<CBlock>> fork; BOOST_REQUIRE(BuildChain(m_node, genesis, CScript() << OP_TRUE, 3, fork)); BOOST_CHECK_EQUAL(fork.front()->vtx[0]->vin[0].scriptSig.size(), 2U); process(fork); } // BuildChain only submits headers, so every template keeps being built on // the active tip. A chain long enough to pass the halving would otherwise // carry the tip's subsidy and fail to connect (bad-cb-amount). { const CBlockIndex* tip{WITH_LOCK(cs_main, return m_node.chainman->ActiveChain().Tip())}; const int start{tip->nHeight}; const int length{consensus.nSubsidyHalvingInterval + 10 - start}; BOOST_REQUIRE(length > 0); std::vector<std::shared_ptr<CBlock>> chain; BOOST_REQUIRE(BuildChain(m_node, tip, CScript() << OP_TRUE, length, chain)); for (int i = 0; i < length; ++i) { BOOST_CHECK_EQUAL(chain.at(i)->vtx[0]->vout[0].nValue, GetBlockSubsidy(start + 1 + i, consensus)); } process(chain); BOOST_CHECK_EQUAL(WITH_LOCK(cs_main, return m_node.chainman->ActiveChain().Height()), start + length); } } ```
jeanpablojp (Migrated from github.com) commented 2026-09-08 18:27:14 +00:00

This is an assignment rather than an adjustment, so the template's fees go with it. MinerTestingSetup::Block asks for its template with the mempool on, and with one transaction in it the coinbase reward comes out at 5000001000 on master and 5000000000 here, with the block still carrying that transaction.

Nothing hits it today, since the mempool is empty at every call. Would .use_mempool = false on that template call be simpler? It makes the site match BuildChain, so the overwrite is exact, and the three suites stay green with it.

This is an assignment rather than an adjustment, so the template's fees go with it. `MinerTestingSetup::Block` asks for its template with the mempool on, and with one transaction in it the coinbase reward comes out at 5000001000 on master and 5000000000 here, with the block still carrying that transaction. Nothing hits it today, since the mempool is empty at every call. Would `.use_mempool = false` on that template call be simpler? It makes the site match `BuildChain`, so the overwrite is exact, and the three suites stay green with it.
DrahtBot commented 2026-09-24 05:42:53 +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).
l0rinc (Migrated from github.com) reviewed 2026-09-25 01:32:50 +00:00
l0rinc (Migrated from github.com) left a comment

Rebased to resolve conflicts and applied the review suggestions.
The block’s difficulty now uses its actual parent and timestamp, and its coinbase pays the subsidy for its resulting height.
I also added focused tests for the target and coinbase fields through the first halving.

Rebased to resolve conflicts and applied the review suggestions. The block’s difficulty now uses its actual parent and timestamp, and its coinbase pays the subsidy for its resulting height. I also added focused tests for the target and coinbase fields through the first halving.
l0rinc (Migrated from github.com) commented 2026-09-25 01:26:07 +00:00

Thanks! I added similar tests, with the coinbase cases combined into one fork test. I also credited you as a co-author on the commits containing them.

Thanks! I added similar tests, with the coinbase cases combined into one fork test. I also credited you as a co-author on the commits containing them.
l0rinc (Migrated from github.com) commented 2026-09-25 01:18:57 +00:00

Sure, added .use_mempool = false to MinerTestingSetup::Block() and asserted the shared helper receives a coinbase-only block.

Sure, added `.use_mempool = false` to `MinerTestingSetup::Block()` and asserted the shared helper receives a coinbase-only block.
First-time contributor

Earlier concerns remain unresolved; see the Run archive linked from the Review report.

🔵 Suggestion · The Block() subsidy change lacks a distinguishing assertion

The new subsidy assertions cover BuildChain(), but the tests using MinerTestingSetup::Block() would still accept its previous active-tip template reward.

Location: src/test/validation_block_tests.cpp:98 (head).

🔵 Suggestion · The Block() migration spans the subsidy and padding commits

The series temporarily rewrites Block()'s coinbase input script twice; migrating the caller after the padding change would make that migration independently reviewable without changing the final tree.

Location: src/test/validation_block_tests.cpp:98 (commit).

Review coverage was incomplete.


Reviewed: b7b762880e75 · Review report · Previous reports

permalink

<!-- forgejo-review-bot:bitcoin/bitcoin --> <!-- ralph-engine:current:2b20819f882b885f79f242c01722f54f2a55e27dcfa7d5e13701b4a0b5214248:c39fdacfa3b84799844a5e841c04997e3cd1142653dfad8e36dbb07c4b1e684b --> <!-- ralph-base:6832a273e22796a02f76b04b10ce8bd26f7bebfe --> <!-- ralph-head:b7b762880e7583a06429f9eca525670a2ee18e5e --> <!-- ralph-case:07345e2b4276f680275f4ec77ec88598133ab905383303d51bfe85e8d848a6d1 --> Earlier concerns remain unresolved; see the Run archive linked from the Review report. **🔵 Suggestion · The `Block()` subsidy change lacks a distinguishing assertion** The new subsidy assertions cover `BuildChain()`, but the tests using `MinerTestingSetup::Block()` would still accept its previous active-tip template reward. Location: [`src/test/validation_block_tests.cpp:98`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/b7b762880e7583a06429f9eca525670a2ee18e5e/src/test/validation_block_tests.cpp#L98>) (head). **🔵 Suggestion · The `Block()` migration spans the subsidy and padding commits** The series temporarily rewrites `Block()`'s coinbase input script twice; migrating the caller after the padding change would make that migration independently reviewable without changing the final tree. Location: src/test/validation_block_tests.cpp:98 (commit). Review coverage was incomplete. <!-- Review tier: routine --> --- Reviewed: [`b7b762880e75`](<https://git.fish.foo/bitcoin/bitcoin/commit/b7b762880e7583a06429f9eca525670a2ee18e5e>) · [Review report](<https://review.fish.foo/report/36109-b7b762880e7583a06429f9eca525670a2ee18e5e-2789-5.html>) · [Previous reports](<https://review.fish.foo/traces/36109/>) [permalink](<https://review.fish.foo/report/36109-b7b762880e7583a06429f9eca525670a2ee18e5e-2789-5.html>)
Sjors (Migrated from github.com) reviewed 2026-11-12 11:16:41 +00:00
Sjors (Migrated from github.com) left a comment

Concept ACK

Code review 23a99695ef, mostly documentation feedback.

You may find the BlockAssembler::CreateCoinbaseTx helper in #36109 commit 902d836b75 useful. But I don't mind rebasing that PR.

Concept ACK Code review 23a99695efa659ee0a0a290d4e0aa78aff8ddef9, mostly documentation feedback. You may find the `BlockAssembler::CreateCoinbaseTx` helper in #36109 commit 902d836b75d402945ac60936f73ded056347fb57 useful. But I don't mind rebasing that PR.
Sjors (Migrated from github.com) commented 2026-11-12 10:59:26 +00:00

In 9312297e15 test: derive fork subsidy from parent: let's document the reason for this restriction, so anyone who needs to relax it will know what to pay attention to.

In 9312297e159c6b3aa5ff0526ef104a4006f8fe5c _test: derive fork subsidy from parent_: let's document the reason for this restriction, so anyone who needs to relax it will know what to pay attention to.
Sjors (Migrated from github.com) commented 2026-11-12 10:33:53 +00:00

In 4e5aeb3535 refactor: extract fork block reconstruction nit: SwitchBlockParent(..., uint32_t new_time) might be a better name. The caller's goal is to switch the parent and change the time. The description could then say that the block is rebuilt, and enumerate the side effects (in later commits), like modified subsidy.

In 4e5aeb3535106911f8ca4e0015e70a5ea9c74330 _refactor: extract fork block reconstruction_ nit: `SwitchBlockParent(..., uint32_t new_time)` might be a better name. The caller's goal is to switch the parent and change the time. The description could then say that the block is rebuilt, and enumerate the side effects (in later commits), like modified subsidy.
Sjors (Migrated from github.com) commented 2026-11-12 11:05:11 +00:00

In 9312297e15 test: derive fork subsidy from parent: this might be a good time to give MinerTestingSetup::Block a quick doc:

/**
 * Prepare a coinbase-only block extending prev_hash, which need not be the active tip.
 * The coinbase has a unique zero-value output and a reward output spendable with OP_TRUE.
 * Call FinalizeBlock() after any further edits to update commitments, mine the block,
 * and submit its header.
 */
In 9312297e159c6b3aa5ff0526ef104a4006f8fe5c _test: derive fork subsidy from parent_: this might be a good time to give `MinerTestingSetup::Block` a quick doc: ```cpp /** * Prepare a coinbase-only block extending prev_hash, which need not be the active tip. * The coinbase has a unique zero-value output and a reward output spendable with OP_TRUE. * Call FinalizeBlock() after any further edits to update commitments, mine the block, * and submit its header. */ ```
Sjors (Migrated from github.com) commented 2026-11-12 10:54:24 +00:00

In 4e5aeb3535 refactor: extract fork block reconstruction:

This relies on the 20-minute difficulty reset rule, which only exists on testnet3 and testnet4. Regtest doesn't have difficulty adjustment at all, but technically the same 20-minute reset rule exists. The test exploits this with a synthetic block with an nBits that's impossible in a "real" regtest chain.

In other words: please document this.

I'm also worried that it's a bit brittle to rely on, since we could remove the 20-minute reset rule on regtest, but I suppose we're never going to touch that consensus code.

In 4e5aeb3535106911f8ca4e0015e70a5ea9c74330 _refactor: extract fork block reconstruction_: This relies on the 20-minute difficulty reset rule, which only exists on testnet3 and testnet4. Regtest doesn't have difficulty adjustment at all, but technically the same 20-minute reset rule exists. The test exploits this with a synthetic block with an `nBits` that's impossible in a "real" regtest chain. In other words: please document this. I'm also worried that it's a bit brittle to rely on, since we could remove the 20-minute reset rule on regtest, but I suppose we're never going to touch that consensus code.
l0rinc (Migrated from github.com) reviewed 2026-11-12 14:02:27 +00:00
l0rinc (Migrated from github.com) commented 2026-11-12 14:03:02 +00:00

Done, thanks

Done, thanks
l0rinc (Migrated from github.com) commented 2026-11-12 14:02:27 +00:00

Renamed, added description, thanks

Renamed, added description, thanks
l0rinc (Migrated from github.com) commented 2026-11-12 14:03:07 +00:00

Done

Done
l0rinc (Migrated from github.com) commented 2026-11-12 14:02:42 +00:00

Documented it, thanks

Documented it, thanks
Sjors commented 2026-11-12 14:47:21 +00:00 (Migrated from github.com)
ACK 27240dce14dc0ddde852cf191bba5a230713f1e5
jeanpablojp commented 2026-11-17 22:34:40 +00:00 (Migrated from github.com)

tACK 27240dce14

tACK 27240dce14dc0ddde852cf191bba5a230713f1e5
maflcko (Migrated from github.com) approved these changes 2026-11-18 08:57:59 +00:00
maflcko (Migrated from github.com) left a comment

Seems rare that a unit test needs the helpers to build such a chain, but this seems fine as a style-cleanup.

review ACK 27240dce14 🐁

Show signature

Signature:

untrusted comment: signature from minisign secret key on empty file; verify via: minisign -Vm "${path_to_any_empty_file}" -P RWTRmVTMeKV5noAMqVlsMugDDCyyTSbA3Re5AkUrhvLVln0tSaFWglOw -x "${path_to_this_whole_four_line_signature_blob}"
RUTRmVTMeKV5npGrKx1nqXCw5zeVHdtdYURB/KlyA/LMFgpNCs+SkW9a8N95d+U4AP1RJMi+krxU1A3Yux4bpwZNLvVBKy0wLgM=
trusted comment: review ACK 27240dce14dc0ddde852cf191bba5a230713f1e5 🐁
rDyUIRZ7S4ZFIQQOJ8CcWLslusVlHaANsiJzQulEb54zKZ9oiLbdXvrmlGHtXYoZ5VFP+d7R5B6McN2F0x41Cw==
Seems rare that a unit test needs the helpers to build such a chain, but this seems fine as a style-cleanup. review ACK 27240dce14dc0ddde852cf191bba5a230713f1e5 🐁 <details><summary>Show signature</summary> Signature: ``` untrusted comment: signature from minisign secret key on empty file; verify via: minisign -Vm "${path_to_any_empty_file}" -P RWTRmVTMeKV5noAMqVlsMugDDCyyTSbA3Re5AkUrhvLVln0tSaFWglOw -x "${path_to_this_whole_four_line_signature_blob}" RUTRmVTMeKV5npGrKx1nqXCw5zeVHdtdYURB/KlyA/LMFgpNCs+SkW9a8N95d+U4AP1RJMi+krxU1A3Yux4bpwZNLvVBKy0wLgM= trusted comment: review ACK 27240dce14dc0ddde852cf191bba5a230713f1e5 🐁 rDyUIRZ7S4ZFIQQOJ8CcWLslusVlHaANsiJzQulEb54zKZ9oiLbdXvrmlGHtXYoZ5VFP+d7R5B6McN2F0x41Cw== ``` </details>
maflcko (Migrated from github.com) commented 2026-11-18 08:45:57 +00:00

nit in the last commit: Any reason to reword the comment here? The prior comment was preferable, because it mentioned that in reality this is usually some extranonce space. Also, it had the exact error msg ID, so that a simple git grep can be used.

nit in the last commit: Any reason to reword the comment here? The prior comment was preferable, because it mentioned that in reality this is usually some extranonce space. Also, it had the exact error msg ID, so that a simple `git grep` can be used.
maflcko (Migrated from github.com) commented 2026-11-18 08:11:27 +00:00

nit: Use the shorter /// doxygen for new comments? The /** is inconsistent with the one above and below.

nit: Use the shorter `///` doxygen for new comments? The `/**` is inconsistent with the one above and below.
maflcko (Migrated from github.com) commented 2026-11-18 08:51:32 +00:00

nit in 7bb37739db: It seems a bit confusing to phrase this what it doesn't need to be, and then have the reader ask if it must not be the active tip and what else it can be. It would be better and shorter to just say what it can be: ..., which may refer to any known prior header. Alternatively, the comment suffix can be removed, because accepting a prev_hash should already clarify that the dev can pass any prev hash here.

Also, use /// doxygen comment?

nit in 7bb37739db34cba73b375a4a47aaebbeb5f49387: It seems a bit confusing to phrase this what it doesn't need to be, and then have the reader ask if it must not be the active tip and what else it can be. It would be better and shorter to just say what it can be: `..., which may refer to any known prior header.` Alternatively, the comment suffix can be removed, because accepting a prev_hash should already clarify that the dev can pass any prev hash here. Also, use `///` doxygen comment?
maflcko (Migrated from github.com) commented 2026-11-18 08:35:31 +00:00

second-to-last commit nit: the global Params() would be good to avoid

second-to-last commit nit: the global `Params()` would be good to avoid
maflcko (Migrated from github.com) commented 2026-11-18 08:09:53 +00:00

nit in the first commit: Please try to avoid the globals. There is a chainman.GetConsensus()

nit in the first commit: Please try to avoid the globals. There is a `chainman.GetConsensus()`
maflcko (Migrated from github.com) commented 2026-11-18 08:13:41 +00:00

same here wrt globals: c.f. fa1b76aeb0

same here wrt globals: c.f. fa1b76aeb064b315a3767a8f59836ca18aeb117e
fanquake (Migrated from github.com) reviewed 2026-11-18 10:03:23 +00:00
fanquake (Migrated from github.com) commented 2026-11-18 10:03:23 +00:00

Could also just drop the declaration and make the definition static, if the intention is not for this to be re-used elsewhere.

Could also just drop the declaration and make the definition static, if the intention is not for this to be re-used elsewhere.
maflcko (Migrated from github.com) approved these changes 2026-11-18 12:16:10 +00:00
maflcko (Migrated from github.com) left a comment

lgtm e07fdd2a11 😼

Show signature

Signature:

untrusted comment: signature from minisign secret key on empty file; verify via: minisign -Vm "${path_to_any_empty_file}" -P RWTRmVTMeKV5noAMqVlsMugDDCyyTSbA3Re5AkUrhvLVln0tSaFWglOw -x "${path_to_this_whole_four_line_signature_blob}"
RUTRmVTMeKV5npGrKx1nqXCw5zeVHdtdYURB/KlyA/LMFgpNCs+SkW9a8N95d+U4AP1RJMi+krxU1A3Yux4bpwZNLvVBKy0wLgM=
trusted comment: lgtm e07fdd2a11 😼
h6tOltp2lhIhuW7iBerbqk6IjIUSRFjNcTTTJff+T1iLy+0hFplznURJcP9M4vqX5aX2XyCQvoOCuzzJmw5sBw==
lgtm e07fdd2a11 😼 <details><summary>Show signature</summary> Signature: ``` untrusted comment: signature from minisign secret key on empty file; verify via: minisign -Vm "${path_to_any_empty_file}" -P RWTRmVTMeKV5noAMqVlsMugDDCyyTSbA3Re5AkUrhvLVln0tSaFWglOw -x "${path_to_this_whole_four_line_signature_blob}" RUTRmVTMeKV5npGrKx1nqXCw5zeVHdtdYURB/KlyA/LMFgpNCs+SkW9a8N95d+U4AP1RJMi+krxU1A3Yux4bpwZNLvVBKy0wLgM= trusted comment: lgtm e07fdd2a11 😼 h6tOltp2lhIhuW7iBerbqk6IjIUSRFjNcTTTJff+T1iLy+0hFplznURJcP9M4vqX5aX2XyCQvoOCuzzJmw5sBw== ``` </details>
maflcko (Migrated from github.com) commented 2026-11-18 12:14:50 +00:00

5c4209eecb: Two line hunk in the wrong commit?

5c4209eecb19c5031be7a2ff8ddc99f2f113f367: Two line hunk in the wrong commit?
maflcko (Migrated from github.com) commented 2026-11-18 12:15:14 +00:00

nit in 096875f8f3: Add and use a chainman reference?

nit in 096875f8f31360ddb805af1442c4e63809a46caa: Add and use a chainman reference?
l0rinc (Migrated from github.com) reviewed 2026-11-18 12:40:30 +00:00
l0rinc (Migrated from github.com) commented 2026-11-18 12:40:30 +00:00

Thanks, switched to ///. The helper is already used from another test file.

Thanks, switched to ///. The helper is already used from another test file.
maflcko commented 2026-11-18 12:41:17 +00:00 (Migrated from github.com)

review ACK b7b762880e 🐡

Show signature

Signature:

untrusted comment: signature from minisign secret key on empty file; verify via: minisign -Vm "${path_to_any_empty_file}" -P RWTRmVTMeKV5noAMqVlsMugDDCyyTSbA3Re5AkUrhvLVln0tSaFWglOw -x "${path_to_this_whole_four_line_signature_blob}"
RUTRmVTMeKV5npGrKx1nqXCw5zeVHdtdYURB/KlyA/LMFgpNCs+SkW9a8N95d+U4AP1RJMi+krxU1A3Yux4bpwZNLvVBKy0wLgM=
trusted comment: review ACK b7b762880e7583a06429f9eca525670a2ee18e5e 🐡
0Zw3K7cJBpNcydZZLKGB1255qgUAAZQATeTIqqLZHAqCJZMnAN7TZ70oV8LUSXKjz/KBfmwumCD2l4P+NjdECg==
review ACK b7b762880e7583a06429f9eca525670a2ee18e5e 🐡 <details><summary>Show signature</summary> Signature: ``` untrusted comment: signature from minisign secret key on empty file; verify via: minisign -Vm "${path_to_any_empty_file}" -P RWTRmVTMeKV5noAMqVlsMugDDCyyTSbA3Re5AkUrhvLVln0tSaFWglOw -x "${path_to_this_whole_four_line_signature_blob}" RUTRmVTMeKV5npGrKx1nqXCw5zeVHdtdYURB/KlyA/LMFgpNCs+SkW9a8N95d+U4AP1RJMi+krxU1A3Yux4bpwZNLvVBKy0wLgM= trusted comment: review ACK b7b762880e7583a06429f9eca525670a2ee18e5e 🐡 0Zw3K7cJBpNcydZZLKGB1255qgUAAZQATeTIqqLZHAqCJZMnAN7TZ70oV8LUSXKjz/KBfmwumCD2l4P+NjdECg== ``` </details>
jeanpablojp commented 2026-11-18 14:01:27 +00:00 (Migrated from github.com)
ACK b7b762880e7583a06429f9eca525670a2ee18e5e
Sjors commented 2026-11-19 10:10:29 +00:00 (Migrated from github.com)

re-ACK b7b762880e

re-ACK b7b762880e7583a06429f9eca525670a2ee18e5e
achow101 commented 2026-11-24 22:37:30 +00:00 (Migrated from github.com)
ACK b7b762880e7583a06429f9eca525670a2ee18e5e
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!36109
No description provided.