Skip to content

Commit bdf8153

Browse files
committed
btc: G0/G1 bake golden share-format fixture + parity KAT
Bake the BTC share-format baseline now that the fork pin is resolved to p2pool-btc-jtoomim @ ece15b03fc23. Emit the golden fixture via tools/conformance/extract_share_format.py (static extraction) and add a gtest KAT that asserts the c2pool BTC port against it. Bucket discipline (3-bucket rule): - Isolation primitives (IDENTIFIER/PREFIX/P2P_PORT/SEGWIT=33): byte-equal. - MINIMUM_PROTOCOL_VERSION: c2pool floor (3500) >= baseline (3301), an intentional forward-compatible raise, not a parity break. - share-versions additive-v36: boundary pinned by BTC_version_gate KAT. Rides the existing allowlisted btc_share_test exe (no new target, no build.yml change). btc_share_test 14/14 green; fixture re-emit MATCH 9/9.
1 parent f649af7 commit bdf8153

3 files changed

Lines changed: 91 additions & 1 deletion

File tree

src/impl/btc/test/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
if (BUILD_TESTING AND GTest_FOUND)
22
# btc twin of ltc share_test — uniquely named to avoid the CMP0002 target
33
# collision with src/impl/ltc/test (both subdirs build in the same tree).
4-
add_executable(btc_share_test share_test.cpp f11_donation_invariance_test.cpp f10b_version_punish_removal_test.cpp)
4+
add_executable(btc_share_test share_test.cpp f11_donation_invariance_test.cpp f10b_version_punish_removal_test.cpp g01_share_format_parity_test.cpp)
55
target_link_libraries(btc_share_test PRIVATE
66
GTest::gtest_main GTest::gtest
77
core btc
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#include <gtest/gtest.h>
2+
3+
#include <string>
4+
5+
#include <impl/btc/config_pool.hpp>
6+
7+
// G0/G1 — BTC share-format byte-parity against the BAKED p2pool baseline.
8+
//
9+
// Golden fixture: tools/conformance/fixtures/btc.g01.golden.json
10+
// provenance: p2pool-btc-jtoomim @ ece15b03fc23 (the canonical BTC fork pin),
11+
// emitted by tools/conformance/extract_share_format.py (static extraction).
12+
//
13+
// The fixture is the SSOT; the literals below are transcribed from it so the
14+
// C++ port asserts byte-identity at run time. If the fixture is re-baked (a
15+
// fork re-pin => a different --tree), update both in lockstep; the python
16+
// `compare` subcommand guards the fixture against silent baseline drift.
17+
//
18+
// Bucket discipline (operator 3-bucket rule):
19+
// * ISOLATION PRIMITIVES (IDENTIFIER / PREFIX / P2P_PORT) — must be
20+
// byte-identical to the live sharechain or peers reject us. EQUALITY.
21+
// * Intentional / v36-native deltas — NOT asserted equal here:
22+
// - MINIMUM_PROTOCOL_VERSION: c2pool raises the floor (3500) above the
23+
// baseline (3301) to admit jtoomim-master/SPB and exclude forrestv-era
24+
// v17/v32. A floor RAISE is forward-compatible => assert >=, not ==.
25+
// - share-versions: c2pool is additive-v36 over the baseline [0..35]; the
26+
// v36 activation boundary is pinned separately by
27+
// BTC_version_gate.V36ActivationBoundary. Not re-asserted here.
28+
29+
namespace {
30+
31+
// --- transcribed from btc.g01.golden.json @ ece15b03fc23 ---------------------
32+
constexpr const char* GOLDEN_IDENTIFIER = "fc70035c7a81bc6f";
33+
constexpr const char* GOLDEN_PREFIX = "2472ef181efcd37b";
34+
constexpr uint16_t GOLDEN_P2P_PORT = 9333;
35+
constexpr uint32_t GOLDEN_SEGWIT_ACTIVATION_VERSION = 33;
36+
constexpr uint32_t GOLDEN_MINIMUM_PROTOCOL_VERSION = 3301;
37+
38+
} // namespace
39+
40+
// Isolation primitives: byte-identical or we are off-network.
41+
TEST(BTC_g01_share_format, IsolationPrimitivesMatchBaseline)
42+
{
43+
EXPECT_EQ(btc::PoolConfig::DEFAULT_IDENTIFIER_HEX, std::string(GOLDEN_IDENTIFIER));
44+
EXPECT_EQ(btc::PoolConfig::DEFAULT_PREFIX_HEX, std::string(GOLDEN_PREFIX));
45+
EXPECT_EQ(btc::PoolConfig::P2P_PORT, GOLDEN_P2P_PORT);
46+
// Testnet shares the mainnet transport identity in this phase (config_pool).
47+
EXPECT_EQ(btc::PoolConfig::TESTNET_IDENTIFIER_HEX, std::string(GOLDEN_IDENTIFIER));
48+
EXPECT_EQ(btc::PoolConfig::TESTNET_PREFIX_HEX, std::string(GOLDEN_PREFIX));
49+
}
50+
51+
// Segwit activation version is a consensus byte — must match the baseline.
52+
TEST(BTC_g01_share_format, SegwitActivationMatchesBaseline)
53+
{
54+
EXPECT_EQ(btc::PoolConfig::SEGWIT_ACTIVATION_VERSION, GOLDEN_SEGWIT_ACTIVATION_VERSION);
55+
}
56+
57+
// Protocol floor is an INTENTIONAL raise, not a parity break: forward-compatible.
58+
TEST(BTC_g01_share_format, ProtocolFloorIsForwardCompatibleRaise)
59+
{
60+
EXPECT_GE(btc::PoolConfig::MINIMUM_PROTOCOL_VERSION, GOLDEN_MINIMUM_PROTOCOL_VERSION)
61+
<< "c2pool floor must not drop below the p2pool baseline";
62+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"coin": "bitcoin",
3+
"constants": {
4+
"DONATION_SCRIPT": "4104ffd03de44a6e11b9917f3a29f9443283d9871c9d743ef30d5eddcd37094b64d1b3d8090496b53256786bf5c82932ec23c3b74d9f05a6f95a8b5529352656664bac",
5+
"IDENTIFIER": "fc70035c7a81bc6f",
6+
"MINIMUM_PROTOCOL_VERSION": 3301,
7+
"P2P_PORT": 9333,
8+
"PREFIX": "2472ef181efcd37b",
9+
"SEGWIT_ACTIVATION_VERSION": 33,
10+
"gentx_before_refhash_expr": "pack.VarStrType().pack(DONATION_SCRIPT) + pack.IntType(64).pack(0) + pack.VarStrType().pack('\\x6a\\x28' + pack.IntType(256).pack(0) + pack.IntType(64).pack(0))[:3]",
11+
"gentx_layout_sig": "5193e3e6ee1a562e23a5a36be01c7d072306a1743bd0998abaa1d7874372c62f",
12+
"share_versions": [
13+
0,
14+
17,
15+
32,
16+
33,
17+
34,
18+
35
19+
]
20+
},
21+
"provenance": {
22+
"data_source": "p2pool/data.py",
23+
"git_rev": "ece15b03fc23",
24+
"network_source": "p2pool/networks/bitcoin.py",
25+
"tree": "/home/ubuntu/Github/p2pool-btc-jtoomim"
26+
},
27+
"schema": "c2pool.g01.share-format/v1"
28+
}

0 commit comments

Comments
 (0)