Repository navigation
Description
Summary
submitauxblock currently accepts only qbit's canonical CAuxPow payload layout. That layout is valid internally, but it is not binary-compatible with Dogecoin/Namecoin-style CAuxPow serializers because qbit omits the legacy CMerkleTx.hashBlock field after the parent coinbase transaction.
Add an RPC-side compatibility decoder so external merged-mining coordinators can submit legacy Dogecoin-style AuxPoW hex without changing qbit's canonical block/header serialization.
Impact
Pool/coordinator operators may reasonably reuse Dogecoin/Namecoin AuxPoW serialization code and pass the result to:
qbit-cli submitauxblock "$AUX_HASH" "$AUXPOW_HEX"That payload has a different binary layout from qbit's canonical CAuxPow. A legacy serializer places a 32-byte hashBlock field after the parent coinbase transaction, while qbit expects the next bytes to be the compact-size length for coinbase_merkle_branch.
The result is an integration failure: valid merged-mining work can be submitted in a format qbit rejects or mis-parses, even though the parent coinbase commitment and branch data are otherwise standard.
This does not require a hard fork if the fix is kept at the RPC boundary. qbit's canonical block/header serialization should remain unchanged.
Evidence
- Code refs:
src/auxpow.h:70serializes qbitCAuxPowas:coinbase_txcoinbase_merkle_branchcoinbase_branch_indexchain_merkle_branchchain_indexparent_block
test/functional/test_framework/auxpow.py:125mirrors that qbit-specific layout.src/rpc/mining.cpp:1244decodesauxpow_hexdirectly into qbitCAuxPow.src/rpc/mining.cpp:1396attaches that decoded payload to the cached candidate block.src/primitives/block.h:33serializesauxpowinsideCBlockHeaderwhen the AuxPoW version bit is set.doc/integration/mining-pool-quickstart.md:145documentssubmitauxblock "$AUX_HASH" "$AUXPOW_HEX"without a field table.
- Background refs:
- Dogecoin
src/auxpow.h:CAuxPowderives from and serializesCMerkleTx, then chain merkle branch, chain index, and parent block. - Bitcoin Wiki merged mining specification.
- Dogecoin
- Tests / fuzz refs:
auxpow_testsauxpow_tests_validationfeature_auxpow.pyfeature_auxpow_commitment_activation.pyauxpowfuzz target
Failure Path
-
A pool calls
createauxblockand receives the qbit aux block hash, chain ID, bits, and target. -
The pool constructs a parent-chain coinbase containing the merged-mining commitment.
-
The pool uses an existing Dogecoin/Namecoin-style AuxPoW serializer.
-
The serialized payload contains:
coinbase_tx_without_witness legacy_hashBlock coinbase_merkle_branch coinbase_branch_index chain_merkle_branch chain_index parent_block_header -
submitauxblockpasses this hex toDecodeHexAuxPow. -
qbit tries to parse
legacy_hashBlockas the start ofcoinbase_merkle_branch. -
The payload fails deserialization or later AuxPoW validation.
Reproduction
- Build or use a valid qbit AuxPoW payload from the existing functional helper.
- Insert 32 bytes after the serialized parent coinbase transaction, representing the legacy
CMerkleTx.hashBlockfield. - Submit the modified payload through
submitauxblock. - Observe that qbit does not decode it as a legacy-compatible payload.
Expected after the fix:
- Canonical qbit payloads continue to decode and validate exactly as today.
- Legacy Dogecoin-style payloads decode at the RPC boundary, are normalized into qbit's internal
CAuxPow, and then use the existing validation path. - Malformed legacy payloads still fail deterministically.
Suggested Fix
Keep qbit's canonical CAuxPow block/header serialization unchanged.
Update DecodeHexAuxPow in src/rpc/mining.cpp to support a two-step decode:
-
Try the current canonical qbit
CAuxPowdecode first. -
If canonical decode fails, try a legacy AuxPoW decode shape:
coinbase_tx_without_witness legacy_hashBlock coinbase_merkle_branch coinbase_branch_index chain_merkle_branch chain_index parent_block_header -
Convert the legacy representation into qbit
CAuxPowby droppinglegacy_hashBlock. -
Optionally reject legacy payloads where
legacy_hashBlockis non-null and does not equalparent_block.GetHash(). If compatibility with unset legacyhashBlockvalues is needed, permit null/unset values but document the behavior. -
Return the normalized qbit
CAuxPowobject to the existingsubmitauxblockpath.
Do not change:
CAuxPow::SERIALIZE_METHODSinsrc/auxpow.hCBlockHeaderserialization insrc/primitives/block.h- P2P block relay format
- disk block/index format
- AuxPoW consensus validation rules
Also update doc/integration/mining-pool-quickstart.md to state:
- qbit canonical
auxpow_hexlayout; submitauxblockalso accepts legacy Dogecoin-style AuxPoW payloads if the compatibility decoder is added;- internally qbit stores/relays its canonical format.
Acceptance Criteria
- Add unit coverage for canonical qbit AuxPoW payload decoding through
DecodeHexAuxPow. - Add unit coverage for legacy Dogecoin-style payload decoding and normalization.
- Add a negative test for malformed legacy payloads.
- Add a negative test for a legacy payload whose
legacy_hashBlockmismatchesparent_block.GetHash(), if the implementation chooses to enforce that consistency check. - Add or update functional coverage in
feature_auxpow.pyforsubmitauxblockusing both canonical and legacy-compatible payload hex. - Update mining integration docs with an explicit AuxPoW field table.
- Confirm no serialized qbit block/header golden vector changes.
Reverify Requirement
Run:
build/bin/test_qbit --run_test=auxpow_tests
build/bin/test_qbit --run_test=auxpow_tests_validation
build/test/functional/test_runner.py feature_auxpow.py feature_auxpow_commitment_activation.pyAlso manually confirm that an accepted legacy-format RPC submission is stored and relayed in qbit's canonical AuxPoW layout, not in the legacy layout.
Activity
Squashed 'src/libbitcoinpqc/' changes from ac72d1ffa0..1965d0da1e
subtree: import libbitcoinpqc v0.3.2 signer stack scrub (#268)
subtree: import libbitcoinpqc v0.3.2 signer stack scrub (#268)