Skip to content

Commit 5a56fb2

Browse files
committed
test(dash): G1 difficulty/vardiff parity KAT vs p2pool-dash oracle
Adds test_dash_g1_difficulty_parity: fenced, non-circular byte-parity KAT pinning the DASH sharechain difficulty target and net.PARENT coin-level fields against values transcribed from the oracle networks/dash.py (_DIFF1_TARGET = 0xFFFF*2**208; ADDRESS/SCRIPT versions; DUST 0.001e8). SANE_TARGET_RANGE structural pins; IDENTIFIER/PREFIX pinned as a labeled bucket-1 regression guard, not oracle-conformance. Registered in test/CMakeLists.txt and the build.yml --target allowlist (no NOT_BUILT). No production code touched.
1 parent 1bdef6b commit 5a56fb2

3 files changed

Lines changed: 108 additions & 1 deletion

File tree

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ jobs:
102102
core_test sharechain_test share_test btc_share_test \
103103
test_threading test_weights \
104104
test_header_chain test_mempool test_template_builder \
105-
test_doge_chain test_compact_blocks test_dash_x11_kat \
105+
test_doge_chain test_compact_blocks test_dash_x11_kat test_dash_g1_difficulty_parity \
106106
test_dash_header_chain test_dash_block_replay test_dash_conformance test_dash_subsidy test_dash_mempool test_dash_simplifiedmns test_dash_quorum test_dash_quorum_root test_dash_mn_state test_dash_embedded_gbt test_dash_smldiff test_dash_p2p_messages test_dash_p2p_connection test_dash_p2p_node test_dash_node_interface test_dash_config test_dash_broadcaster test_dash_broadcaster_full test_dash_share_hash_link test_dash_block_relay test_dash_rpc_request test_dash_rpc_conf test_dash_block_producer test_dash_embedded_relay_e2e test_dash_block_relay_plan test_dash_version_activation_latch test_dash_block_relay_binding test_dash_block_relay_dual_arm test_dash_coinbase_parity test_dash_donation_combined test_dash_g3_assembled test_dash_work_target test_dash_work_job_targets test_dash_cb_payee test_dash_stratum_notify_roundtrip test_dash_poolnode_messages test_dash_peer test_dash_share_tracker test_dash_node test_dash_share_messages test_dash_stratum_extranonce_split \
107107
test_multiaddress_pplns test_pplns_stress \
108108
test_hash_link test_decay_pplns \

test/CMakeLists.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,19 @@ if (BUILD_TESTING AND GTest_FOUND)
221221
target_link_libraries(test_dash_x11_kat PRIVATE c2pool_payout c2pool_hashrate c2pool_merged_mining) # OBJECT-lib SCC direct-naming (#22/#39): core stratum/web_server TUs
222222
gtest_add_tests(test_dash_x11_kat "" AUTO)
223223

224+
# DASH G1 difficulty/vardiff parity KAT (byte-parity vs oracle networks/dash.py).
225+
# Links the same additive dash_x11 + core set as test_dash_x11_kat; pulls
226+
# impl/dash/params.hpp + config_pool.hpp (sharechain SSOT); no ltc/pool SCC dep.
227+
add_executable(test_dash_g1_difficulty_parity test_dash_g1_difficulty_parity.cpp)
228+
target_link_libraries(test_dash_g1_difficulty_parity PRIVATE
229+
GTest::gtest_main GTest::gtest
230+
dash_x11 core
231+
nlohmann_json::nlohmann_json
232+
${Boost_LIBRARIES}
233+
)
234+
target_link_libraries(test_dash_g1_difficulty_parity PRIVATE c2pool_payout c2pool_hashrate c2pool_merged_mining) # OBJECT-lib SCC direct-naming (#22/#39)
235+
gtest_add_tests(test_dash_g1_difficulty_parity "" AUTO)
236+
224237
# DASH consensus known-answer test (PR-0 foundation, S3 slice): SPV
225238
# HeaderChain + DarkGravityWave v3 retarget. header_chain.hpp pulls in the
226239
# additive dash_x11 primitive (hash_x11.hpp) + core (uint256/leveldb/pack/log);
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
// G1 difficulty/vardiff parity KAT — DASH sharechain target byte-parity vs the
2+
// DASH oracle frstrtr/p2pool-dash (networks/dash.py).
3+
//
4+
// FENCED conformance test (no production code touched). Test-form artifact of
5+
// greenlight gate G1 for the DASH difficulty/vardiff surface, mirroring the
6+
// dgb/bch g1_oracle_byte_parity KATs but scoped to the target math the DASH
7+
// migration plan calls out as independently-landable byte-parity groundwork
8+
// (integrator 2026-07-04: proceed on the G1 difficulty/vardiff parity KAT ahead
9+
// of the operator GO on the consensus-bearing flip).
10+
//
11+
// NON-CIRCULAR posture: the difficulty-target and coin-level (net.PARENT)
12+
// expected values below are typed from the oracle python source
13+
// (p2pool/dash/networks/dash.py), NOT re-read from the C++ SUT constant. A drift
14+
// in config_pool.hpp / params.hpp that silently diverges from the oracle fails
15+
// here even though sibling dash tests (which source the same SUT constant on both
16+
// sides) stay green.
17+
//
18+
// SCOPE LINE: the p2pool *sharechain* namespacing constants (IDENTIFIER/PREFIX)
19+
// are c2pool-chosen bucket-1 isolation primitives, ABSENT from the oracle PARENT.
20+
// They are pinned in IsolationPrimitivesRegressionGuard as a pure drift guard and
21+
// are explicitly NOT asserted as oracle-conformance.
22+
//
23+
// MUST appear in BOTH the ctest registration (test/CMakeLists.txt) AND the
24+
// build.yml --target allowlist, or it becomes a #143-style NOT_BUILT sentinel.
25+
26+
#include <impl/dash/params.hpp>
27+
#include <impl/dash/config_pool.hpp>
28+
29+
#include <core/coin_params.hpp>
30+
31+
#include <gtest/gtest.h>
32+
33+
namespace {
34+
35+
// Oracle networks/dash.py:31 _DIFF1_TARGET = 0xFFFF * 2**208 (standard bdiff
36+
// difficulty-1 target). 0xFFFF left-shifted 208 bits, big-endian 256-bit:
37+
// 8 hex zeros + "ffff" + 52 hex zeros. Derived from the oracle FORMULA, not the
38+
// SUT literal, so a hand-edit of config_pool.hpp max_target() fails this pin.
39+
uint256 oracle_diff1_target()
40+
{
41+
uint256 t;
42+
t.SetHex("00000000ffff0000000000000000000000000000000000000000000000000000");
43+
return t;
44+
}
45+
46+
// max_target parity: the sharechain SSOT max_target() AND the plumbed CoinParams
47+
// field both equal the oracle bdiff-1 target.
48+
TEST(DashG1DifficultyParity, MaxTargetIsBdiff1_OracleDash)
49+
{
50+
EXPECT_EQ(dash::SharechainConfig::max_target(), oracle_diff1_target());
51+
core::CoinParams p = dash::make_coin_params(/*testnet=*/false);
52+
EXPECT_EQ(p.max_target, oracle_diff1_target());
53+
}
54+
55+
// SANE_TARGET_RANGE = (_DIFF1_TARGET//10000, _DIFF1_TARGET) (oracle dash.py:33).
56+
// Non-circular structural pins: easiest sane == max_target (oracle SANE[1]),
57+
// hardest sane is non-zero and strictly tighter than the easiest.
58+
TEST(DashG1DifficultyParity, SaneTargetRangeMatchesOracle)
59+
{
60+
EXPECT_EQ(dash::SharechainConfig::sane_target_max(), dash::SharechainConfig::max_target());
61+
EXPECT_NE(dash::SharechainConfig::sane_target_min(), uint256());
62+
EXPECT_NE(dash::SharechainConfig::sane_target_min(), dash::SharechainConfig::max_target());
63+
}
64+
65+
// Coin-level net.PARENT parity (oracle networks/dash.py mainnet).
66+
TEST(DashG1DifficultyParity, CoinLevelParentParity)
67+
{
68+
core::CoinParams p = dash::make_coin_params(/*testnet=*/false);
69+
EXPECT_EQ(p.symbol, "DASH"); // dash.py:22 SYMBOL
70+
EXPECT_EQ(p.block_period, 150u); // dash.py:21 BLOCK_PERIOD
71+
EXPECT_EQ(p.address_version, 76u); // dash.py:12 ADDRESS_VERSION (X...)
72+
EXPECT_EQ(p.address_p2sh_version, 16u); // dash.py:13 SCRIPT_ADDRESS_VERSION (7...)
73+
EXPECT_EQ(p.dust_threshold, 100000u); // dash.py DUST_THRESHOLD = 0.001e8
74+
}
75+
76+
// Testnet address divergence (oracle networks/dash_testnet.py), isolation
77+
// primitives shared — but this KAT only asserts the address versions here.
78+
TEST(DashG1DifficultyParity, TestnetAddressDiverges)
79+
{
80+
core::CoinParams p = dash::make_coin_params(/*testnet=*/true);
81+
EXPECT_EQ(p.address_version, 140u); // testnet PUBKEY_ADDRESS (y...)
82+
EXPECT_EQ(p.address_p2sh_version, 19u); // testnet SCRIPT_ADDRESS
83+
}
84+
85+
// Bucket-1 isolation-primitive REGRESSION GUARD — NOT oracle-conformance.
86+
// IDENTIFIER/PREFIX are c2pool-chosen sharechain namespacing (absent from the
87+
// oracle PARENT); pinned purely to catch silent namespace drift.
88+
TEST(DashG1DifficultyParity, IsolationPrimitivesRegressionGuard)
89+
{
90+
EXPECT_EQ(dash::SharechainConfig::IDENTIFIER_HEX, "7242ef345e1bed6b");
91+
EXPECT_EQ(dash::SharechainConfig::PREFIX_HEX, "3b3e1286f446b891");
92+
}
93+
94+
} // namespace

0 commit comments

Comments
 (0)