Skip to content

build: prohibit PQC runtime test controls in qbit - #107

Merged
kiwidream merged 4 commits into
1.0.0from
prohibit-pqc-runtime-knobs
Jul 13, 2026
Merged

kiwidream merged 4 commits into
1.0.0from
prohibit-pqc-runtime-knobs

Conversation

@kiwidream

@kiwidream kiwidream commented Jul 11, 2026 •

Copy link
Copy Markdown
Member

Summary

  • reject SPX_ENABLE_TEST_BENCH_ENV_KNOBS=ON in integrated qbit builds
  • pin the effective bitcoinpqc target and Guix artifacts to SPX_PRODUCTION_BUILD=1
  • add fail-closed CMake regression coverage and Core Checks compile-definition evidence
  • document the downstream backend policy and the distinct WOTS+C signing cap

Closes #104.

Related upstream test-evidence work: Qbit-Org/qbit-libbitcoinpqc#3.

Testing

  • Built locally.
  • Ran focused unit or functional tests for the changed area.
  • Ran lint or formatting checks relevant to this change.
  • Not run. Reason:

Commands and checks:

  • python3 ci/checks/test_libbitcoinpqc_build_policy.py
  • python3 contrib/guix/test_build_config.py
  • configured and built bitcoinpqc and test_bitcoin with CMake/Ninja
  • ran all 35 pqc_tests, including the bounded30 known-answer vector
  • verified the effective compile command defines SPX_PRODUCTION_BUILD=1 and omits the runtime-control macro
  • verified an unsafe top-level qbit configuration fails with the policy error
  • ran the full repository lint suite in Docker
  • git diff --check

Target Branch

  • This PR targets main or a maintainer-requested release branch such as 0.1.x.

Target: 1.0.0.

Risk / Review Notes

  • Consensus, script, crypto, wallet, P2P, release, CI, or security-sensitive behavior changed.
  • No consensus, script, crypto, wallet, P2P, release, CI, or security-sensitive behavior changed.

Notes:

This is release-build hardening for consensus-reachable PQC code. Normal qbit builds retain the existing scalar production backend and object behavior. Only configurations that request test/benchmark runtime controls now fail. Compiler-flag injection is covered by forcing the production macro and relying on the existing upstream mutual-exclusion compile error.

Docs / Process Impact

Choose exactly one:

  • I updated public docs because this PR changes user-visible behavior, integration guidance, release/process guidance, or expected validation.
  • No public docs update needed. Reason:

The subtree runbook now documents qbit's downstream production policy, standalone backend experimentation, and the WOTS+C signing-cap/verifier-bound distinction.

libbitcoinpqc Subtree Checklist (if src/libbitcoinpqc changed)

Not applicable: this PR deliberately leaves src/libbitcoinpqc unchanged and implements the downstream policy in qbit-owned integration, CI, release, and documentation files.

  • Source commit is reachable from an immutable release tag in Qbit-Org/qbit-libbitcoinpqc.
  • qbit imports the tagged upstream tree directly without pruning or a curated subtree branch.
  • Subtree import/update was performed with contrib/devtools/update-libbitcoinpqc-subtree.sh.
  • Any default tag change in contrib/devtools/update-libbitcoinpqc-subtree.sh is intentional and matches doc/subtrees/libbitcoinpqc.md.

View with Codesmith Autofix with Codesmith
Need help on this PR? Tag /codesmith with what you need. Autofix is disabled.


Note

High Risk
Touches consensus-reachable PQC compile policy and release build configuration; misconfiguration could change verifier behavior, though the change hardens toward production-only builds.

Overview
Integrated qbit builds now fail closed on PQC test/benchmark runtime knobs and always compile the bitcoinpqc target in production mode.

cmake/libbitcoinpqc.cmake rejects SPX_ENABLE_TEST_BENCH_ENV_KNOBS=ON, forces that cache option off for integrated builds, and pins SPX_PRODUCTION_BUILD=1 on the bitcoinpqc target (including compile options so flag injection cannot bypass it). Guix release CONFIGFLAGS explicitly pass -DSPX_ENABLE_TEST_BENCH_ENV_KNOBS=OFF.

New regression coverage includes ci/checks/test_libbitcoinpqc_build_policy.py (normal production build, explicit ON, stale cache, compiler-flag injection) plus Core Checks steps that run that script and grep the verbose bitcoinpqc build for the expected macros. contrib/guix/test_build_config.py asserts the Guix flag. doc/subtrees/libbitcoinpqc.md documents the downstream production policy, standalone experimentation, and WOTS+C signing-cap vs verifier bounds.

A small CI base-install fix removes existing IWYU paths before re-cloning when RUN_TIDY is enabled.

Reviewed by Cursor Bugbot for commit 564697f. Bugbot is set up for automated code reviews on this repo. Configure here.

@kiwidream

Copy link
Copy Markdown
Member Author

PR Review

Findings

  • [blocking] cmake/libbitcoinpqc.cmake:57 — Compiler flags can cancel the production definition and re-enable runtime controls. Against the PR head, configuring with -DCMAKE_C_FLAGS="-USPX_PRODUCTION_BUILD -DSPX_ENABLE_TEST_BENCH_ENV_KNOBS=1" configured and built successfully. Compile commands place the target’s -DSPX_PRODUCTION_BUILD=1 before the injected flags, so -U removes it and the mutual-exclusion error never fires. The resulting archive retained getenv references, confirming runtime-control code was compiled. Enforce production mode after user-supplied flags or reject conflicting -D/-U combinations, and add this paired undefine/define case to the regression test.

  • [high] .github/workflows/core-checks.yml:209 — The accelerated-backend acceptance criterion from Prevent release builds from enabling PQC test backend controls #104 remains unproven. The 35-case integrated pqc_tests suite runs with the newly forced scalar mode. The vendored upstream workflow is not qbit CI, and the open upstream issue Qbit-Org/qbit-libbitcoinpqc#3 documents that its existing differential tests can silently fall back to scalar. Either provide/import evidence that every supported accelerator actually executed the known-answer and cross-verification tests, or stop closing Prevent release builds from enabling PQC test backend controls #104 until that criterion is completed or explicitly split.

  • [high] ci/checks/test_libbitcoinpqc_build_policy.py:1 — The new shebang-bearing script is committed as mode 0644. Repository lint requires 0755 or removal of the shebang, so lint, Full Validation Gate, and Required Merge Gate are currently failing. Fix the mode or remove the shebang and rerun the required gates.

Consensus Impact

Consensus-adjacent

cmake/libbitcoinpqc.cmake and contrib/guix/libexec/build.sh determine the compile-time mode used by consensus-reachable SLH-DSA signing and verification. That mode controls the unchanged opt_flags.h and sha2.c backend-dispatch paths. The PR does not change signature validity, serialization, or cryptographic algorithms directly, and #104 explicitly authorizes release hardening of this surface; however, the fail-closed and backend-vector evidence is required because an incorrect build can expand the runtime cryptographic surface.

Review Scope

Reviewed #104 as the backing contract, the related upstream issue, the PR body and sole commit, all six changed files, surrounding qbit/subtree CMake integration, SHA backend selection, WOTS+C cap behavior, Guix configuration, documentation, CI checks and relevant logs. There are no prior reviews, comments, or review threads. The PR is currently behind the 1.0.0 base.

Deep Checks Performed

Traced cache-option handling through the effective target definitions and SHA dispatcher; checked direct ON, stale-cache, normal-production, and raw compiler-injection paths; inspected actual verbose compiler ordering; and confirmed the bypass in the built archive. Also mapped issue acceptance criteria to qbit CI, the inactive vendored upstream workflow, and upstream issue #3.

Issue Fit

The direct CMake option and stale-cache cases correctly fail closed, and normal builds receive the intended production definition. The compiler-flag bypass means the main release-hardening guarantee is not yet satisfied. Effective accelerator evidence is also still outstanding. The WOTS+C documentation correctly distinguishes the statistics-active signer cap from the verifier’s full 16-bit range.

qbit-Specific Checks

Reviewed the consensus-reachable PQC backend-selection path and confirmed the patch does not alter P2MR layouts, signature hashing, serialization, wallet behavior, or provider APIs. The strongest risk is build-policy enforcement, not a direct consensus-rule change.

Validation Reviewed

CI’s build smoke passed the four new policy tests and showed production definitions on the ordinary Linux target. The focused job passed all 35 pqc_tests, including the bounded30 known-answer case, and the platform/sanitizer build matrix was otherwise green. Locally, the four policy tests and two Guix configuration tests passed, as did git diff --check; the adversarial compiler-flag case configured and built when it should have failed. Repository lint is red because of the file mode.

Residual Risk

The actual Guix release artifact’s effective compile command was not inspected by PR CI; its test only checks configuration text. The bypass reproduction was performed with AppleClang/CMake/Ninja, not MSVC. The PR should be updated onto the current base and have the full required matrix rerun after fixes.

@kiwidream
kiwidream force-pushed the prohibit-pqc-runtime-knobs branch from 7e6e406 to 6c474c6 Compare July 12, 2026 20:43
@kiwidream
kiwidream merged commit 715843d into 1.0.0 Jul 13, 2026
34 checks passed
kiwidream added a commit that referenced this pull request Jul 15, 2026
* build: prohibit PQC runtime test controls

* build: prevent PQC production mode cancellation

* ci: make PQC build policy check executable

* ci: reset cached IWYU sources before tidy setup
kiwidream added a commit that referenced this pull request Jul 15, 2026
* ci: enable validation on 1.0.0 (#73)

* Fix scanner high findings (#72)

* Resolve scanner medium findings (#74)

* Reject malformed P2MR leaf versions in Qt (#82)

* Bind builder attestations to signed-tag source (#84)

* Bind builder attestations to release source

* Fix builder workflow source environment

* Restore verified release tag after checkout

* qt: avoid wallet shutdown deadlock during model adoption (#87)

* Use aggregate work rate for assumevalid burial (#88)

* p2p: use recent chainwork for anti-DoS thresholds (#89)

* qt: bind P2MR proofs to expected signer (#85)

* Complete restricted-output fundrawtransaction edge coverage (#86)

* test: extend restricted-output raw funding coverage

* test: use documented raw funding fee option

* Prevent closing wallet progress dialogs (#97)

* qt: minimize P2MR proof exports (#95)

* Fix Qt wallet shutdown lifetime (#90)

* Fix Qt wallet shutdown lifetime

* Fix Qt shutdown CI coverage

* Test active wallet shutdown during transaction preparation

* Use portable thread in Qt shutdown test

* validation: reject height-invalid AuxPoW substitutions (#106)

* Bound qbit-qt P2MR proof parsing (#96)

* Bound Qt P2MR proof parsing

* Fix GCC range-loop warning

* qt: bind proof limit to minimal export

* rpc: default to portable P2MR proofs

* test: update PQC usage RPC expectations

* doc: qualify legacy P2MR proof compatibility

* Cache Cadence lane predecessors (#108)

* build: prohibit PQC runtime test controls in qbit (#107)

* build: prohibit PQC runtime test controls

* build: prevent PQC production mode cancellation

* ci: make PQC build policy check executable

* ci: reset cached IWYU sources before tidy setup

* docs: show qbit version and full logo in RPC sidebar (#119)

* doc: update RPC docs branding

* test: handle missing MkDocs in RPC docs suite

* Activate P2MR validation weight v2 on testnet4 at height 60,000 (#109)

* Activate P2MR validation weight v2 at height 60,000

* test: cover P2MR weight in getblockchaininfo

* validation: pre-enforce forthcoming P2MR weight rule

* doc: bound block-wide P2MR verification work

* test: cover P2MR validation-weight boundaries

* test: avoid mixed enum flag expressions

* Make resumed release draft notes deterministic (#116)

* release: make draft notes deterministic

* release: harden draft validation edge cases

* P2MR v1 conformance and release framework (#118)

* doc: define the qbit P2MR v1 consensus profile

* test: add the qbit P2MR v1 conformance corpus

* ci: gate qbit P2MR v1 conformance with an independent oracle

* release: gate qbit P2MR v1 conformance and integration signoff

* ci: execute P2MR CHECKSIGADD and release validator tests

* build: preserve P2MR corpus line endings

* test: hard-fail invalid P2MR oracle signatures

* ci: initialize P2MR target directory at runtime

* ci: test p2mr release gate in release-only profile

* test: make p2mr v1 corpus fully reproducible

* test: execute p2mr data signature opcodes

* test: type p2mr generator mutation fixtures

* release: sync p2mr support matrix digest

* test: require CHECKSIGADD boundary fixtures

* test: fix rebased P2MR conformance checks

* test: close P2MR conformance review gaps

* test: align P2MR conformance with weight v2

* Harden P2MR corpus and oracle conformance evidence (#127)

* test: prove P2MR corpus mutation resistance

* test: cover P2MR signature opcode underflow

* release: sync hardened P2MR evidence digest

* qt: preserve PQC usage after signing failures (#128)

* qt: preserve PQC usage after signing failures

* docs: align release note with PR 128

* Enforce immutable local release publication (#117)

* release: enforce immutable local publication

* release: preserve resumed draft metadata

* release: fail closed on remote verification

* release: discover resumable drafts safely

* release: re-pin immutable publication tags (#130)

* Establish mainnet 3-of-5 release-key policy (#134)

* release: establish mainnet 3-of-5 signer policy

* ci: always verify operator policy approvals

* ci: use merge queue base for policy history

* Stage v1.0.0 mainnet launch; placeholder genesis and AuxPoW chain ID (#131)

* Stage v1.0.0 mainnet launch configuration

* test: derive subversion expectation from release version

* ci: enforce staged mainnet publication posture

* release: lock staged mainnet launch difficulty

* ci: test chain ID finalization contract

* release: separate staged and final genesis targets

* ci: require live chain ID assertion

* Activate future block time v2 at testnet4 height 60,000 (#133)

* Activate future block time v2 on testnet4

* Fix future-time v2 CI regressions

* test: isolate mempool limit synthetic chain

* test: preserve legacy timestamp scenarios

* test: derive nulldummy block time from tip

* test: keep sequence-lock blocks within time limit

* ci: retrigger validation after release rebase

* test: isolate pruning timestamps from future-time v2

* docs: publish v1.0.0 mainnet guidance

* consensus: pin mainnet genesis and ASERT anchor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant