bch(M5): ASERT DAA known-answer test vs BCHN gold properties - #215
Merged
Conversation
Closes the unverified-DAA gap in the M5 embedded body. asert.hpp claims CalculateASERT() is a 1:1 BCHN src/pow.cpp port validated against gold vectors, but no test exercised it: every getwork/template test stays below the ASERT anchor (height 100k << 661647) to skip the retarget, so the synced-state bits/target branch shipped unverified. asert_kat_test pins CalculateASERT() and the anchor-formulated get_next_work_required_asert() against the canonical gold PROPERTIES of BCHN asert_difficulty_test (src/test/pow_tests.cpp) and the real mainnet anchor constants (src/chainparams.cpp:169-172), both BCHN tag v29.0.0 @89a591f: on-schedule -> unchanged, +2-day -> target doubles, -2-day -> halves, +2 halflives -> x4, huge exponent -> clamp to powLimit, testnet allow-min-difficulty rule. Exact uint256 identities (integer halflife multiples -> pure power-of-two shifts), not float tolerances. Oracle note: p2poolBCH @6603b79 carries NO ASERT (defers DAA to bitcoind getblocktemplate); the embedded daemon replaces that bitcoind, so the ASERT oracle is BCHN itself. Zero p2pool-merged-v36 surface: ASERT governs only header-accept target, not PoW hash/share/coinbase/ PPLNS. Fenced to src/impl/bch/test/; registered in BCH_ABLA_TESTS (COIN_BCH leg). Verified: g++ -std=c++20 compile+run = ALL PASS.
The ASERT KAT registers with ctest at configure time (BCH_ABLA_TESTS foreach) but bch_asert_kat_test was absent from the explicit --target allowlist in the Build BCH test targets step (Linux Release + ASan). Under ctest -R ^bch_ that yields the documented NOT_BUILT false-green failure mode (build.yml:228-234). Add the target to both legs so the binary is built and the KAT actually runs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds
asert_kat_test— a known-answer test pinning BCH ASERT (aserti3-2d, CHIP-2020-05) against BCHN gold properties. Closes the unverified-DAA gap in the M5 embedded body.Why
asert.hppdocumentsCalculateASERT()as a 1:1 BCHNsrc/pow.cppport validated against gold vectors, but no test exercised it: every getwork/template test deliberately stays below the ASERT anchor (height 100k << 661647) to skip the retarget, so the synced-statebits/target branch shipped unverified. After IBD the synced-state work template emits ASERT-computedbitsat heights >= anchor — this is the headline BCH-specific consensus divergence from BTC Core (M1 §4).Conformance (pinned refs)
src/test/pow_tests.cppasert_difficulty_test: on-schedule→unchanged, +2-day→target doubles, −2-day→halves, +2 halflives→×4, huge exponent→clamp to powLimit, testnet allow-min-difficulty rule.src/chainparams.cpp:169-172: {661647, 0x1804dafe, 1605447844}, halflife 2 days.Oracle note
p2poolBCH @6603b79 carries NO ASERT — it defers DAA to bitcoind getblocktemplate. The embedded daemon replaces that bitcoind, so the ASERT oracle is BCHN itself, not p2poolBCH.
Scope / isolation
src/impl/bch/test/only (test + CMake registration in BCH_ABLA_TESTS, COIN_BCH leg).g++ -std=c++20compile + run = ALL PASS.Merge operator-gated (I author + push; integrator merges on operator push-approval).
CI-wiring follow-up @ac72d68f6
Per integrator review: the KAT registered with ctest (
bch_asert_kat_test, via theBCH_ABLA_TESTSforeach) but was absent from the explicit--targetallowlist in.github/workflows/build.yml"Build BCH test targets" (both Linux Release + ASan legs). Underctest -R "^bch_"that reproduces the documented NOT_BUILT false-green mode (build.yml:228-234) — the binary never builds, ctest finds no executable.Fix
ac72d68f6addsbch_asert_kat_testto both COIN_BCH allowlist legs. This is a COIN_BCH-scoped, additive CI-config change outside thesrc/impl/bch/fence — noting it explicitly so the scope label stays honest. No consensus-value change; the diff is nowsrc/impl/bch/test/{CMakeLists.txt,asert_kat_test.cpp}+.github/workflows/build.yml(BCH allowlist only).