Skip to content

Accept legacy Dogecoin-style AuxPoW payloads at the mining RPC boundary #17

Closed

Description

@kiwidream

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:70 serializes qbit CAuxPow as:
      • coinbase_tx
      • coinbase_merkle_branch
      • coinbase_branch_index
      • chain_merkle_branch
      • chain_index
      • parent_block
    • test/functional/test_framework/auxpow.py:125 mirrors that qbit-specific layout.
    • src/rpc/mining.cpp:1244 decodes auxpow_hex directly into qbit CAuxPow.
    • src/rpc/mining.cpp:1396 attaches that decoded payload to the cached candidate block.
    • src/primitives/block.h:33 serializes auxpow inside CBlockHeader when the AuxPoW version bit is set.
    • doc/integration/mining-pool-quickstart.md:145 documents submitauxblock "$AUX_HASH" "$AUXPOW_HEX" without a field table.
  • Background refs:
    • Dogecoin src/auxpow.h: CAuxPow derives from and serializes CMerkleTx, then chain merkle branch, chain index, and parent block.
    • Bitcoin Wiki merged mining specification.
  • Tests / fuzz refs:
    • auxpow_tests
    • auxpow_tests_validation
    • feature_auxpow.py
    • feature_auxpow_commitment_activation.py
    • auxpow fuzz target

Failure Path

  1. A pool calls createauxblock and receives the qbit aux block hash, chain ID, bits, and target.

  2. The pool constructs a parent-chain coinbase containing the merged-mining commitment.

  3. The pool uses an existing Dogecoin/Namecoin-style AuxPoW serializer.

  4. The serialized payload contains:

    coinbase_tx_without_witness
    legacy_hashBlock
    coinbase_merkle_branch
    coinbase_branch_index
    chain_merkle_branch
    chain_index
    parent_block_header
    
  5. submitauxblock passes this hex to DecodeHexAuxPow.

  6. qbit tries to parse legacy_hashBlock as the start of coinbase_merkle_branch.

  7. The payload fails deserialization or later AuxPoW validation.

Reproduction

  1. Build or use a valid qbit AuxPoW payload from the existing functional helper.
  2. Insert 32 bytes after the serialized parent coinbase transaction, representing the legacy CMerkleTx.hashBlock field.
  3. Submit the modified payload through submitauxblock.
  4. 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:

  1. Try the current canonical qbit CAuxPow decode first.

  2. 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
    
  3. Convert the legacy representation into qbit CAuxPow by dropping legacy_hashBlock.

  4. Optionally reject legacy payloads where legacy_hashBlock is non-null and does not equal parent_block.GetHash(). If compatibility with unset legacy hashBlock values is needed, permit null/unset values but document the behavior.

  5. Return the normalized qbit CAuxPow object to the existing submitauxblock path.

Do not change:

  • CAuxPow::SERIALIZE_METHODS in src/auxpow.h
  • CBlockHeader serialization in src/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_hex layout;
  • submitauxblock also 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_hashBlock mismatches parent_block.GetHash(), if the implementation chooses to enforce that consistency check.
  • Add or update functional coverage in feature_auxpow.py for submitauxblock using 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.py

Also manually confirm that an accepted legacy-format RPC submission is stored and relayed in qbit's canonical AuxPoW layout, not in the legacy layout.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions