Skip to content

Commit 03c28f4

Browse files
committed
bch(kat): coinbase DGB<->BCH pairing slice 1 -- gated-segwit-OFF predicate pin
Pins the one real DGB<->BCH coinbase divergence: BCH gates the SegWit commitment vout on is_segwit_activated(version), which the p2poolBCH oracle derives from getattr(net,"SEGWIT_ACTIVATION_VERSION",0) -> 0 -> false for every share version. Asserts the predicate is OFF across v17..v36 (and the sentinel stays disabled), so a regression re-introducing a non-zero SEGWIT_ACTIVATION_VERSION (the old stray-17 port -> sharechain fork) fails CI. Wired into BCH_ABLA_TESTS (pure, header-only over share_types.hpp). Byte-vector half (full coinbase vs oracle ground-truth) is the follow slice. Separate BCH-lane PR per per-coin isolation; #171 stays DGB-tree only. p2pool-merged-v36 surface: none.
1 parent bf16f21 commit 03c28f4

2 files changed

Lines changed: 65 additions & 0 deletions

File tree

src/impl/bch/test/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ if(BUILD_TESTING)
1818
block_download_test # M5: windowed headers-first block download (pure)
1919
genesis_conformance_test # M5: genesis-hash pin vs BCHN v29.0.0 chainparams (pure)
2020
abla_growth_soak_test # M5: dynamic ABLA budget-GROWTH proof above 32 MB floor (pure)
21+
coinbase_kat_segwit_predicate_test # KAT: DGB<->BCH coinbase pairing -- gated-segwit-OFF predicate pin (pure)
2122
)
2223
foreach(t IN LISTS BCH_ABLA_TESTS)
2324
add_executable(bch_${t} ${t}.cpp)
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
// ---------------------------------------------------------------------------
2+
// bch coinbase KAT -- gated-segwit predicate pin (DGB<->BCH pairing, slice 1).
3+
//
4+
// The DGB<->BCH coinbase-byte KAT pairing (integrator PR #171 DGB side; this is
5+
// the SEPARATE BCH-lane PR per the per-coin isolation invariant) has ONE real
6+
// divergence between the two SHA256d coinbases: the SegWit-commitment output
7+
// the builder gates on `is_segwit_activated(version)` at serialize time.
8+
//
9+
// - DGB (SegWit active): the gate is TRUE for share versions >= its
10+
// SEGWIT_ACTIVATION_VERSION, so the coinbase carries the witness-commitment
11+
// vout (OP_RETURN 0x6a24aa21a9ed || commitment).
12+
// - BCH (SegWit rejected at the 2017 fork): the oracle p2poolBCH derives the
13+
// gate from getattr(net,"SEGWIT_ACTIVATION_VERSION",0) (data.py:63-66); the
14+
// bitcoincash[_testnet].py nets define NO such attribute -> default 0 ->
15+
// the gate is FALSE for EVERY version -> NO witness-commitment vout is ever
16+
// emitted, and segwit_data is never present in a BCH share.
17+
//
18+
// This slice pins exactly that predicate: across the full v17..v36 share-version
19+
// range, bch::is_segwit_activated MUST be false, matching the oracle's
20+
// default-0 guard. A regression that re-introduces a non-zero
21+
// SEGWIT_ACTIVATION_VERSION (the old stray-17 BTC/LTC port that forced
22+
// segwit_data on for v17..v35 -> sharechain fork; see share_types.hpp) fails
23+
// here. The byte-vector half of the KAT (full coinbase vs oracle ground-truth
24+
// from p2poolBCH util/pack) is the follow sub-slice.
25+
//
26+
// p2pool-merged-v36 surface: NONE (pins a conformance invariant, adds no wire
27+
// field). per-coin isolation: src/impl/bch/ only. Header-only over
28+
// share_types.hpp -- no peer, socket, or coin lib.
29+
// ---------------------------------------------------------------------------
30+
31+
#include <cassert>
32+
#include <iostream>
33+
34+
#include "../share_types.hpp"
35+
36+
int main()
37+
{
38+
// The sentinel itself must stay disabled (== 0), reproducing the oracle
39+
// getattr(net,"SEGWIT_ACTIVATION_VERSION",0) default for the BCH nets.
40+
assert(bch::SEGWIT_ACTIVATION_VERSION == 0
41+
&& "BCH must keep SEGWIT_ACTIVATION_VERSION disabled (oracle default 0)");
42+
43+
// The predicate must be FALSE for every share version BCH ships -- the full
44+
// v17..v36 span and a few sentinels around the boundaries. There is no
45+
// version at which a BCH coinbase emits the witness-commitment vout.
46+
for (uint64_t ver = 0; ver <= 64; ++ver)
47+
{
48+
assert(!bch::is_segwit_activated(ver)
49+
&& "BCH gated-segwit predicate must be OFF at every share version");
50+
}
51+
52+
// Spot-check the versions that actually matter on the sharechain: the
53+
// legacy floor (17), the field-order transition versions, and v36.
54+
for (uint64_t ver : {uint64_t(17), uint64_t(33), uint64_t(34),
55+
uint64_t(35), uint64_t(36)})
56+
{
57+
assert(!bch::is_segwit_activated(ver));
58+
}
59+
60+
std::cout << "bch coinbase-KAT segwit-predicate pin: OK "
61+
<< "(is_segwit_activated == false for all versions; "
62+
<< "no witness-commitment vout on any BCH coinbase)\n";
63+
return 0;
64+
}

0 commit comments

Comments
 (0)