Repository navigation
Description
Summary
On regtest, -blockversion can override the version field used by ordinary permissionless block templates. If the override uses the BIP9 top-bit shape and sets qbit's AuxPoW flag bit, getblocktemplate can return an AuxPoW-signalling version even though the template was built through the permissionless path and does not include an AuxPoW payload.
That makes the returned template unsubmittable through the normal submitblock / proposal flow: qbit's block/header deserializer requires an AuxPoW payload whenever the version signals AuxPoW.
Keep AuxPoW-signalling versions out of permissionless getblocktemplate results. The dedicated createauxblock / submitauxblock flow should remain the way to build and submit AuxPoW blocks.
Impact
This is limited to explicit regtest/debug usage of -blockversion, so it does not affect public-network consensus parameters or normal mining templates.
It is still a useful correctness fix because regtest templates should not hand test authors or integration tooling a version value that the same node cannot accept through the corresponding permissionless submission path. This can produce confusing Block decode failed behavior before the block reaches contextual header validation.
No hard fork is required. The fix should only constrain or sanitize a debug-only template override path.
Evidence
- Code refs:
src/node/miner.cpp:140computes the normal permissionless BIP9 version.src/node/miner.cpp:142repacks ordinary templates withchain_id=0,auxpow=false, and only low deployment bits.src/node/miner.cpp:143-146then applies raw-blockversionon regtest.src/rpc/mining.cpp:1086-1093canonicalizes any BIP9-shaped template version throughMakeVersion(...), preserving whether the version signals AuxPoW and rewriting the configured AuxPoW chain ID.src/rpc/mining.cpp:1095-1101returns that version and derives the permissionless version rolling mask from it.src/primitives/block.h:33-38serializes/deserializes an AuxPoW payload wheneverSignalsAuxpow()is true, and throws if an AuxPoW-signalling version has no payload on write.
- Existing related tests:
test/functional/mining_basic.py:83-87covers a benign BIP9-shaped-blockversionoverride.test/functional/mining_version_field.py:161-166covers a non-BIP9 override disabling version rolling.- Current coverage does not exercise a BIP9-shaped override with the AuxPoW flag bit set.
Failure Path
- A regtest node is started with a BIP9-shaped
-blockversionoverride that sets qbit's AuxPoW flag bit, for example0x20000100. BlockAssembler::CreateNewBlock()builds an ordinary permissionless template and then applies the raw override.getblocktemplatesees a BIP9-shaped version, preserves the AuxPoW flag, fills in the configured AuxPoW chain ID, and returns that version to the caller.- The returned template still has no AuxPoW payload because it was not built by
createauxblock. - A miner or test constructs a normal block from the GBT result and submits it through
submitblockor proposal mode. - The serialized block version signals AuxPoW, so qbit's block/header deserializer expects an AuxPoW payload between the header and transactions.
- The block fails decode before reaching ordinary block/header validation.
Reproduction
-
Start a regtest node with an AuxPoW-signalling BIP9-shaped block version override:
qbitd -regtest -blockversion=536871168
536871168is0x20000100: BIP9 top bits plus qbit's AuxPoW flag bit. -
Call
getblocktemplate. -
Observe that the returned
versionsignals AuxPoW even though this is the permissionless GBT path. -
Build a normal block from the GBT response without an AuxPoW payload and submit it through
submitblockor proposal mode. -
Observe decode failure rather than a submittable permissionless test template.
Expected after the fix:
- Permissionless
getblocktemplatenever returns an AuxPoW-signalling version. - Explicit AuxPoW block construction remains available through
createauxblock. - Non-AuxPoW regtest
-blockversionoverride tests continue to work.
Suggested Fix
Reject or sanitize AuxPoW-signalling -blockversion values on the permissionless GBT path.
Reasonable options:
- Reject the override early on regtest when
-blockversionhas BIP9 top bits andBLOCK_VERSION_AUXPOWset, returning a clear RPC error fromgetblocktemplate. - Clear the AuxPoW flag before returning permissionless GBT templates, while preserving valid low versionbits and any intended permissionless version-rolling behavior.
- Refuse permissionless GBT for AuxPoW-signalling overrides and direct callers to
createauxblock.
Avoid changing:
CBlockHeaderserialization rules;- AuxPoW payload format;
- P2P block relay format;
- public-network version layout;
createauxblock/submitauxblocksemantics.
Acceptance Criteria
- Add a functional regression test that starts regtest with
-blockversion=0x20000100or decimal equivalent. - The test should assert that permissionless
getblocktemplatedoes not return an AuxPoW-signalling version, or returns a clear RPC error. - The same test should assert that ordinary non-AuxPoW
-blockversionoverride coverage still works. - Existing AuxPoW mining tests should continue to pass through
createauxblock/submitauxblock. - Existing permissionless version-rolling mask behavior should remain unchanged for normal templates.
Reverify Requirement
Run:
build/bin/test_qbit --run_test=blockversion_tests
build/bin/test_qbit --run_test=cadence_tests
build/bin/test_qbit --run_test=testnet4_miner_tests
build/test/functional/test_runner.py mining_version_field.py feature_cadence_activation.py mining_basic.pyAlso manually confirm that createauxblock still emits a valid AuxPoW-signalling template and that permissionless getblocktemplate does not.
Activity