Skip to content

Prevent getblocktemplate from returning AuxPoW-signalling permissionless templates #18

Closed

Description

@kiwidream

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:140 computes the normal permissionless BIP9 version.
    • src/node/miner.cpp:142 repacks ordinary templates with chain_id=0, auxpow=false, and only low deployment bits.
    • src/node/miner.cpp:143-146 then applies raw -blockversion on regtest.
    • src/rpc/mining.cpp:1086-1093 canonicalizes any BIP9-shaped template version through MakeVersion(...), preserving whether the version signals AuxPoW and rewriting the configured AuxPoW chain ID.
    • src/rpc/mining.cpp:1095-1101 returns that version and derives the permissionless version rolling mask from it.
    • src/primitives/block.h:33-38 serializes/deserializes an AuxPoW payload whenever SignalsAuxpow() is true, and throws if an AuxPoW-signalling version has no payload on write.
  • Existing related tests:
    • test/functional/mining_basic.py:83-87 covers a benign BIP9-shaped -blockversion override.
    • test/functional/mining_version_field.py:161-166 covers a non-BIP9 override disabling version rolling.
    • Current coverage does not exercise a BIP9-shaped override with the AuxPoW flag bit set.

Failure Path

  1. A regtest node is started with a BIP9-shaped -blockversion override that sets qbit's AuxPoW flag bit, for example 0x20000100.
  2. BlockAssembler::CreateNewBlock() builds an ordinary permissionless template and then applies the raw override.
  3. getblocktemplate sees a BIP9-shaped version, preserves the AuxPoW flag, fills in the configured AuxPoW chain ID, and returns that version to the caller.
  4. The returned template still has no AuxPoW payload because it was not built by createauxblock.
  5. A miner or test constructs a normal block from the GBT result and submits it through submitblock or proposal mode.
  6. The serialized block version signals AuxPoW, so qbit's block/header deserializer expects an AuxPoW payload between the header and transactions.
  7. The block fails decode before reaching ordinary block/header validation.

Reproduction

  1. Start a regtest node with an AuxPoW-signalling BIP9-shaped block version override:

    qbitd -regtest -blockversion=536871168

    536871168 is 0x20000100: BIP9 top bits plus qbit's AuxPoW flag bit.

  2. Call getblocktemplate.

  3. Observe that the returned version signals AuxPoW even though this is the permissionless GBT path.

  4. Build a normal block from the GBT response without an AuxPoW payload and submit it through submitblock or proposal mode.

  5. Observe decode failure rather than a submittable permissionless test template.

Expected after the fix:

  • Permissionless getblocktemplate never returns an AuxPoW-signalling version.
  • Explicit AuxPoW block construction remains available through createauxblock.
  • Non-AuxPoW regtest -blockversion override tests continue to work.

Suggested Fix

Reject or sanitize AuxPoW-signalling -blockversion values on the permissionless GBT path.

Reasonable options:

  1. Reject the override early on regtest when -blockversion has BIP9 top bits and BLOCK_VERSION_AUXPOW set, returning a clear RPC error from getblocktemplate.
  2. Clear the AuxPoW flag before returning permissionless GBT templates, while preserving valid low versionbits and any intended permissionless version-rolling behavior.
  3. Refuse permissionless GBT for AuxPoW-signalling overrides and direct callers to createauxblock.

Avoid changing:

  • CBlockHeader serialization rules;
  • AuxPoW payload format;
  • P2P block relay format;
  • public-network version layout;
  • createauxblock / submitauxblock semantics.

Acceptance Criteria

  • Add a functional regression test that starts regtest with -blockversion=0x20000100 or decimal equivalent.
  • The test should assert that permissionless getblocktemplate does not return an AuxPoW-signalling version, or returns a clear RPC error.
  • The same test should assert that ordinary non-AuxPoW -blockversion override 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.py

Also manually confirm that createauxblock still emits a valid AuxPoW-signalling template and that permissionless getblocktemplate does not.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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