Skip to content

validation: reject height-invalid AuxPoW substitutions - #106

Merged
kiwidream merged 1 commit into
1.0.0from
reject-height-invalid-auxpow
Jul 12, 2026
Merged

kiwidream merged 1 commit into
1.0.0from
reject-height-invalid-auxpow

Conversation

@kiwidream

@kiwidream kiwidream commented Jul 11, 2026 •

Copy link
Copy Markdown
Member

Summary

Fixes #101.

  • Revalidate incoming AuxPoW payloads for already-known headers using the commitment order required at the indexed height.
  • Reject wrong-order full-block substitutions before relay or disk write without marking the legitimate indexed header invalid.
  • Continue accepting distinct AuxPoW proofs that satisfy the required commitment order.
  • Add regression coverage for headers-first and requested-block processing, index status safety, and strict indexed disk reads.

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:

  • Built the test_qbit target with CMake.
  • Passed auxpow_tests.
  • Passed auxpow_tests_validation, including auxpow_known_header_rejects_height_invalid_payload_substitution.
  • Passed git diff --check and git clang-format --diff.
  • Passed the Docker lint runner checks relevant to the change. The commit-only scripted_diff check was not run locally because this Conductor worktree cannot safely perform its checkout/reset workflow; this change contains no scripted diff.

Target Branch

  • This PR targets main or a maintainer-requested release branch such as 0.1.x. The requested target is 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 tightens full-block and duplicate-header acceptance to the height-specific AuxPoW commitment rule that is already enforced for new headers and indexed disk reads. It does not change activation heights or require a chain reset. Review should focus on duplicate-header semantics and ensuring alternate valid proofs remain accepted.

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: this enforces the existing consensus commitment-order schedule consistently and does not change operator or integration behavior.

libbitcoinpqc Subtree Checklist (if src/libbitcoinpqc changed)

  • 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.
  • test/lint/libbitcoinpqc-subtree-check.sh passes locally.
  • 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
Consensus validation change: duplicate-header acceptance now enforces AuxPoW commitment rules that were previously skippable, affecting P2P block relay and storage semantics.

Overview
Duplicate AuxPoW headers are no longer treated as equivalent without checking the payload. Because AuxPoW is excluded from the block hash, the same header could be re-received with a different merged-mining proof; AcceptBlockHeader now runs auxpow::Validate with CommitmentValidationForHeight on already-indexed headers before accepting the duplicate.

Wrong commitment order at that height is rejected with bad-auxpow-commitment without marking the indexed entry failed or writing bad block data. A different proof that still satisfies the height rule can be accepted and stored.

Tests extend MakeAuxpowPayload for DISPLAY vs INTERNAL commitments and add auxpow_known_header_rejects_height_invalid_payload_substitution for headers-first, force_processing full blocks, index status, and disk reads.

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

@kiwidream

Copy link
Copy Markdown
Member Author

PR Review

Findings

No blocking or actionable findings from this review pass.

Consensus Impact

Consensus-changing

src/validation.cpp:4721 changes duplicate-header acceptance by enforcing the indexed height’s AuxPoW commitment order. This directly affects block/header validity. Issue #101 explicitly authorizes this tightening, and the regression test covers both commitment orders and alternate valid proofs.

Review Scope

Reviewed issue #101, the PR body and commit, both changed files, surrounding AuxPoW validation and block-storage paths, all visible comments/reviews and review threads, and CI logs. There are currently no review comments or unresolved threads.

Deep Checks Performed

Traced duplicate headers through ProcessNewBlockHeaders, ProcessNewBlock, AcceptBlockHeader, AcceptBlock, block-index state updates, disk writes, and height-aware indexed reads. I also checked that rejection occurs before relay/storage, does not mark the legitimate index entry invalid, and does not require the incoming proof to match the originally indexed proof byte-for-byte.

Issue Fit

The patch satisfies issue #101’s acceptance criteria:

  • Height-invalid alternate payloads are rejected using CommitmentValidationForHeight(..., pindex->nHeight).
  • Rejection occurs before BLOCK_HAVE_DATA, relay, or disk write.
  • The indexed header remains valid and retains its original AuxPoW payload.
  • A distinct proof with the required commitment order remains acceptable and is successfully read through the strict indexed disk path.
  • The regression would fail on the old early-return behavior.

qbit-Specific Checks

Checked display/internal byte order, height-based commitment selection, parent proof-of-work validation, block-index invalidity flags, alternate-proof arrival order, and indexed block reads. The PR does not alter activation heights, AuxPoW serialization, chain IDs, difficulty rules, or commitment construction in production code.

Validation Reviewed

All required gates are green. CI logs show auxpow_tests_validation passing under MSan, ASan/LSan/UBSan/integer sanitizers, and Windows native testing. Docker lint ran against the PR commit and passed. The general “focused unit suites” job did not select the AuxPoW suites, but the full-validation jobs did execute them successfully. I also checked the diff with git diff --check.

Residual Risk

No independent local build or wire-level P2P functional reproduction was run during this review. The unit test exercises the relevant chainstate entry points, including the force_processing requested-block equivalent. The branch is currently behind the base by an unrelated Qt-only commit, so the required checks should rerun after any branch update.

@kiwidream
kiwidream merged commit f0f1a67 into 1.0.0 Jul 12, 2026
39 of 40 checks passed
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