Skip to content

Commit a2eb89e

Browse files
authored
Merge pull request #734 from frstrtr/feat/dash-share-producer
dash(share-producer): prospective share_info assembly, ref_hash/hash_link producers, retarget + KATs (mint campaign 1/3)
2 parents 429afb4 + b473cd8 commit a2eb89e

6 files changed

Lines changed: 1816 additions & 29 deletions

File tree

src/impl/dash/share.hpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,11 @@ struct DashShare : chain::BaseShare<uint256, 16>
5454
uint64_t m_last_txout_nonce{0};
5555
HashLinkType m_hash_link;
5656
MerkleLink m_merkle_link;
57-
BaseScript m_coinbase_payload_outer; // PossiblyNone('', VarStr) — outer coinbase_payload
57+
// Outer coinbase_payload — PossiblyNone('', VarStr) on the wire. The VALUE
58+
// is the oracle's coinbase_payload_data = VarStrType().pack(raw_payload)
59+
// (data.py:277-289), i.e. m_data holds [compactsize(len raw)][raw], NOT the
60+
// bare payload; Share.__init__ appends it verbatim to the hash_link data.
61+
BaseScript m_coinbase_payload_outer;
5862

5963
// Identity hash (computed, not serialized)
6064
uint256 m_hash;

src/impl/dash/share_check.hpp

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -276,23 +276,26 @@ inline uint256 share_init_verify(const DashShare& share,
276276
hash_link_data.insert(hash_link_data.end(), p, p + 4);
277277
}
278278
// Append outer coinbase_payload (coinbase_payload_data in Python).
279-
// Oracle data.py:278,346-348: coinbase_payload_data = pack.VarStrType().pack(payload)
280-
// = [compactsize(len)][payload]; check_hash_link appends THAT (or b"" when None).
281-
// BaseScript C2POOL_SERIALIZE_METHODS does READWRITE(m_data) over a byte vector,
282-
// which strips one VarStr layer on read (so m_data holds the RAW payload) and
283-
// re-adds the compactsize prefix on write. Serialize via the stream rather than
284-
// appending m_data raw — the raw append dropped the prefix, diverging gentx_hash
285-
// from the oracle on any non-empty (DIP4 CbTx) payload. PRESERVE the empty branch:
286-
// the oracle appends nothing (b"") when the payload is None/empty, NOT a 0x00.
279+
// Oracle data.py:277-289: the outer contents['coinbase_payload'] VALUE is
280+
// coinbase_payload_data = pack.VarStrType().pack(raw_payload) — i.e. the
281+
// VarStr-PACKED payload ([compactsize(len)][payload]) — and Share.__init__
282+
// (data.py:346-348) appends that value VERBATIM to the check_hash_link
283+
// data (b"" when None). On the wire the PossiblyNone(b'', VarStr) outer
284+
// layer adds one MORE compactsize prefix around the value, so
285+
// DashFormatter's single READWRITE(m_data) strip leaves m_data holding
286+
// exactly the oracle field value: [compactsize(len raw)][raw]. Append it
287+
// RAW. (#412 correctly established that the compactsize prefix belongs in
288+
// this data — but re-serializing m_data as a VarStr added a SECOND prefix
289+
// on top of the one m_data already carries, diverging gentx_hash from the
290+
// oracle on every real DIP4 CbTx share. The share-producer slice pins the
291+
// corrected framing: producer KATs in test_dash_share_producer.cpp,
292+
// updated oracle anchors in test_dash_share_hash_link.cpp.)
293+
// PRESERVE the empty branch: the oracle appends nothing (b"") when the
294+
// payload is None/empty, NOT a 0x00.
287295
{
288296
auto& cpd = share.m_coinbase_payload_outer.m_data;
289297
if (!cpd.empty())
290-
{
291-
PackStream cpd_stream;
292-
cpd_stream << share.m_coinbase_payload_outer; // VarStr-pack: [compactsize][payload]
293-
auto* cp = reinterpret_cast<const unsigned char*>(cpd_stream.data());
294-
hash_link_data.insert(hash_link_data.end(), cp, cp + cpd_stream.size());
295-
}
298+
hash_link_data.insert(hash_link_data.end(), cpd.begin(), cpd.end());
296299
}
297300

298301
auto gentx_before_refhash = compute_gentx_before_refhash();

0 commit comments

Comments
 (0)