From f049bd7e029803895ad18806f831e36cd661fcfa Mon Sep 17 00:00:00 2001 From: frstrtr Date: Thu, 9 Jul 2026 10:11:42 +0000 Subject: [PATCH] bch: gate work-source donation script on v36 (P2SH) to match authored version Shares are authored v36-native (pool_entrypoint result.share_version=36), and generate_share_transaction rebuilds the coinbase donation with get_donation_script(36) -> 23-byte COMBINED P2SH. The work source still served get_donation_script(35) -> 67-byte forrestv P2PK, so the miner-hashed template coinbase and the verify-side rebuild diverged at the donation output (first diverging byte offset 104: script-len 0x43 P2PK vs 0x17 P2SH) on every non-genesis share -> 100 percent recompute/GENTX mismatch. Gate the work-source donation on 36 to match. Regtest grind 12/12 accepted, GENTX-MISMATCH 10->0, chain==verified 12/12, author coinbase now byte-matches verify rebuild. --- src/impl/bch/pool_entrypoint.hpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/impl/bch/pool_entrypoint.hpp b/src/impl/bch/pool_entrypoint.hpp index 85832574f..4b2b8b607 100644 --- a/src/impl/bch/pool_entrypoint.hpp +++ b/src/impl/bch/pool_entrypoint.hpp @@ -164,10 +164,16 @@ inline void standup_pool_run(boost::asio::io_context& ioc, work_source->set_best_share_hash_fn( [&node]() -> uint256 { return node.best_share_hash(); }); - // Initial donation matches the cold-start create version (35 -> P2PK). A - // ratchet-driven refresh to the COMBINED P2SH on v36 activation is the same - // follow-up slice as pplns_fn/ref_hash_fn. - work_source->set_donation_script(PoolConfig::get_donation_script(35)); + // Work-source donation MUST match the authored share version. Shares are + // authored v36-native (result.share_version = 36 above, verify-preimage + // fix), and generate_share_transaction rebuilds the coinbase donation with + // get_donation_script(36) -> COMBINED P2SH. Serving the v35 P2PK here made + // the miner-hashed template coinbase carry a 67-byte P2PK donation while + // verify rebuilt a 23-byte P2SH donation -> the donation output diverged at + // byte offset 104 on every non-genesis share -> 100% recompute/GENTX + // mismatch. Gate on 36 to match. (Dynamic ratchet-tracking generalises this + // once the staged v35+v36 dual-pool migration lands.) + work_source->set_donation_script(PoolConfig::get_donation_script(36)); // -- ref_hash_fn: peer-verifiable share commitment (G2 conform) -------- // Without this the local-author coinbase carries NO p2pool OP_RETURN