bch: G1 share-serialization byte-parity KAT vs jtoomim oracle wire - #654
Merged
Conversation
…k guard Flip the create-version selection to V36 (three sites in pool_entrypoint.hpp: ref_hash genesis version, ref-param default, create_ver) so the BCH v36-native sharechain is authored uniformly at V36. BCH v36 is a brand-new sharechain with no legacy V35 shares, so share_ver==parent_version on every share and the 60%-by-work upgrade accept-gate never fires -- closing the deferred ratchet slice the create-block comment flagged as follow-up. Harden prefix_to_hash_link_v35: throw when the V35 FixedStrType(0) hash_link would silently drop non-empty extra_data (partial SHA-256 block exceeds the const_ending tail), which would make check_hash_link recompute a different coinbase txid than the author committed. Refuse to forge an unrepresentable V35 hash_link instead of emitting a mismatching preimage. Fenced to src/impl/bch/ only (no src/core / bitcoin_family). Regtest grind: shares now author ver=36 (was 35), 13/13 accepted, zero create-share throws, guard dormant (correctly never fires at V36). NOTE: verify-preimage recompute residual persists version-independently -- rerooted to the generate_share_transaction rebuild path, tracked separately.
… 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.
…#652/#653) BCH is a crossing coin, not greenfield: point the six hardcoded author sites (donation, ref_hash share/desired, RefHashParams, create_ver) at one named crossing-floor SSOT constant instead of scattered 35/36 literals. CROSSING_FLOOR_VERSION (=35, the version the live jtoomim-BCH sharechain currently mints) is the cold-start/empty-chain author floor; author, ref_hash and the served donation all feed from it so the miner template and the verify-side gentx rebuild read ONE version -- closing the byte-offset-104 recompute/GENTX divergence without forking off the live net. desired_version votes toward V36_ACTIVATION_VERSION; the 60%-by-work auto-ratchet advances the tip past the floor to 36.
Pin the on-the-wire SHARE serialization byte layout of the c2pool-bch SUT
against the wire format transcribed from the BCH crossing oracle
p2pool-merged-v36 p2pool/data.py:
- share_type wrapper = VarInt(type) || VarStr(contents) (data.py:98)
- hash_link_type v35 = FixedStr(32) state || VarInt(length) (data.py:32)
- v36_hash_link_type = FixedStr(32) state || VarStr(extra_data)
|| VarInt(length) (data.py:41)
Non-circular: the expected side is literal wire bytes typed from the oracle
ComposedType field order + VarIntType(==CompactSize)/VarStrType/FixedStrType(N)
semantics, NOT a second read of the SUT serializer. A field-order or encoding
drift in share_types.hpp / RawShare fails here while every other bch share
test (same SUT serializer on both sides) stays green.
Also pins CROSSING_FLOOR_VERSION == 35 read from the config_pool.hpp SSOT (the
version the live jtoomim BCH net mints today / accept-both floor until the
60%-by-work auto-ratchet flips) -- guards a silent crossing-floor bump that
would fork the live sharechain. Reads the constant, not a scattered literal.
Wired into the CMakeLists pure-test loop and BOTH build.yml COIN_BCH --target
allowlists so it cannot land as a NOT_BUILT sentinel. Stacks on the #652/#653
crossing-floor SSOT rework (source of CROSSING_FLOOR_VERSION). Fenced: no
production code touched.
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.
Fenced G1 greenlight KAT (no production code touched). Pins the c2pool-bch on-the-wire SHARE serialization byte layout against the wire format transcribed from the BCH crossing oracle p2pool-merged-v36 p2pool/data.py:
Non-circular: expected side is literal wire bytes typed from the oracle ComposedType field order + VarIntType(==CompactSize)/VarStrType/FixedStrType(N) semantics, not a second read of the SUT serializer. A field-order or encoding drift in share_types.hpp / RawShare fails here while every other bch share test (same serializer both sides) stays green.
Also pins CROSSING_FLOOR_VERSION == 35 read from the config_pool.hpp SSOT (version the live jtoomim BCH net mints today / accept-both floor until the 60%-by-work auto-ratchet flips) -- guards a silent crossing-floor bump that would fork the live sharechain. Reads the constant, not a scattered literal.
Wired into the CMakeLists pure-test loop and BOTH build.yml COIN_BCH --target allowlists (no NOT_BUILT sentinel). Stacks on the crossing-floor SSOT rework branch (source of CROSSING_FLOOR_VERSION); merge order after that lands. Not self-merged.