Skip to content

Use aggregate work rate for assumevalid burial - #88

Merged
kiwidream merged 1 commit into
1.0.0from
stabilize-assumevalid-work-rate
Jul 10, 2026
Merged

kiwidream merged 1 commit into
1.0.0from
stabilize-assumevalid-work-rate

Conversation

@kiwidream

@kiwidream kiwidream commented Jul 10, 2026 •

Copy link
Copy Markdown
Member

Summary

  • replace assumevalid's single-tip-proof burial estimate with aggregate chainwork over a 120-block MTP window
  • compare work duration with exact quotient/remainder arithmetic so large chainwork values cannot overflow
  • fail closed for incomplete, stale, malformed, or non-increasing samples while preserving witness-pruned behavior
  • add mixed-lane proof-skew, strict-boundary, overflow-scale, and unusable-sample regression coverage

Closes #83

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/checks:

  • cmake --build build --target test_bitcoin qbitd qbit-cli
  • build/bin/test_qbit --run_test=validation_chainstatemanager_tests
  • build/bin/test_qbit --run_test=pow_tests
  • build/bin/test_qbit --run_test=validation_tests
  • build/test/functional/test_runner.py feature_assumevalid.py --jobs=1
  • repository lint suite in the documented Docker image
  • 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 changes the policy that decides when assumevalid may skip historical script checks. It does not change block validity, chainwork accumulation, fork choice, difficulty adjustment, serialization, or the generic equivalent-time helper. Invalid recent-work samples retain script verification.

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 is a correctness fix for an existing internal validation-policy calculation with no interface or configuration changes.

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
This changes when assumevalid may skip historical script verification—a validation-policy path tied to consensus-adjacent security; behavior shifts even though block validity rules themselves are unchanged.

Overview
Assumevalid burial no longer uses GetBlockProofEquivalentTime on the best header alone. ChainstateManager::CanSkipScriptChecks now calls HasAssumeValidBurial, which samples 120 blocks of chainwork and median-time-past, compares cumulative work since the assumed-valid ancestor against recent work over that window, and requires the ratio to exceed the existing two-week threshold.

The comparison goes through WorkDurationExceeds, which uses quotient/remainder arithmetic so large arith_uint256 chainwork values do not overflow. Incomplete history, flat or decreasing work, and bad MTP windows fail closed (no script skip).

Unit tests extend InsertTestBlockIndex with times and auxpow, lengthen the existing burial gate scenario for MTP sampling, and add cases for mixed permissionless/auxpow lanes, unusable samples, and strict boundary / max-work overflow behavior.

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

@kiwidream
kiwidream merged commit 2762d56 into 1.0.0 Jul 10, 2026
34 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