|
| 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