Repository navigation
Description
Summary
BlockTemplate::submitSolution (the IPC mining interface) replaces the template's coinbase and recomputes the merkle root. It does not reset the block's cached check flags.
CreateNewBlock already validated the template with TestBlockValidity, which leaves m_checked_witness_commitment = true. So when the solved block reaches ProcessNewBlock, ContextualCheckBlock skips the witness commitment and unexpected-witness checks for the coinbase the client supplied. The node can then accept a block as its tip that its peers reject.
This code is inherited unchanged from Bitcoin Core v30.2. Upstream fixed it in bitcoin/bitcoin#33745 ("mining: check witness commitment in submitBlock", merged to master on 2025-11-12). That fix is not in 1.x.x.
Affected code (1.x.x @ e374ba2)
submitSolutioncallsAddMerkleRootAndCoinbaseand thenProcessNewBlockon the mutated template block:Lines 931 to 935 in e374ba2
bool submitSolution(uint32_t version, uint32_t timestamp, uint32_t nonce, CTransactionRef coinbase) override { AddMerkleRootAndCoinbase(m_block_template->block, std::move(coinbase), version, timestamp, nonce); return chainman().ProcessNewBlock(std::make_shared<const CBlock>(m_block_template->block), /*force_processing=*/true, /*min_pow_checked=*/true, /*new_block=*/nullptr); } AddMerkleRootAndCoinbaseswaps the coinbase and recomputes the merkle root without resettingfChecked,m_checked_merkle_rootorm_checked_witness_commitment:Lines 451 to 461 in e374ba2
void AddMerkleRootAndCoinbase(CBlock& block, CTransactionRef coinbase, uint32_t version, uint32_t timestamp, uint32_t nonce) { if (block.vtx.size() == 0) { block.vtx.emplace_back(coinbase); } else { block.vtx[0] = coinbase; } block.nVersion = version; block.nTime = timestamp; block.nNonce = nonce; block.hashMerkleRoot = BlockMerkleRoot(block); - The template's
TestBlockValiditycall sets the witness-commitment flag:→Lines 189 to 193 in e374ba2
if (m_options.test_block_validity) { if (BlockValidationState state{TestBlockValidity(m_chainstate, *pblock, /*check_pow=*/false, /*check_merkle_root=*/false)}; !state.IsValid()) { throw std::runtime_error(strprintf("TestBlockValidity failed: %s", state.ToString())); } } Line 4423 in e374ba2
block.m_checked_witness_commitment = true; CheckWitnessMalleationreturns early when the flag is set:Lines 4390 to 4392 in e374ba2
{ if (expect_witness_commitment) { if (block.m_checked_witness_commitment) return true;
Impact
Only a local client of the IPC mining interface (qbit-node -ipcbind) can trigger this. ENABLE_IPC defaults to on for non-Windows builds. The RPC submission paths decode a fresh block, so they are not affected.
A client that submits a coinbase without the witness reserved value, or with a commitment that does not match the block's transactions, gets the block accepted as the local tip. Peers reject the block as mutated, so nothing is cached as invalid on other nodes. The miner, however, ends up on a block the network does not follow.
Fix
Backport bitcoin/bitcoin#33745:
- Reset
m_checked_witness_commitment,m_checked_merkle_rootandfCheckedat the end ofAddMerkleRootAndCoinbase. - Bring over the
test/functional/interface_ipc.pycoverage: submitting a coinbase without its witness must be rejected, and resubmitting with the witness must succeed. - Bring over the doc updates in
src/interfaces/mining.handsrc/validation.h.
Activity
mining: reset cached block checks in IPC submitSolution (backport bit…
kiwidream commentedon Nov 4, 2026
Fixed on
1.x.xby #289 (merged as 21fee6e).AddMerkleRootAndCoinbasenow resetsm_checked_witness_commitment,m_checked_merkle_rootandfChecked.interface_ipc.pychecks that a coinbase submitted without its witness is rejected and that resubmitting it with the witness succeeds.maingets the fix when1.x.xis integrated. The AuxPoW-version abort found while reviewing the backport stays open as #291.mining: reset cached block checks in IPC submitSolution (backport bit…