Skip to content

Commit e45baef

Browse files
authored
dgb: wire AutoRatchet mint baseline base_version=35 (oracle-resolved) (#293)
The DGB VOTING-state baseline share version was a [decision-needed] held on PR #292. Resolved against the canonical oracle frstrtr/p2pool-dgb-scrypt @22761e7 (2026-06-17): data.py:636 Share.VERSION=35, VOTING_VERSION=35, SUCCESSOR=None, share_versions={35:Share}; networks/digibyte.py:26 SEGWIT_ACTIVATION_VERSION=35. SUCCESSOR=None means 35 is the format the live node currently mints, so base_version=35 is unambiguous. The "older than LTC" divergence is the P2P PROTOCOL version (p2p.py VERSION=3501 vs LTC 3503), not the share version. New fenced header auto_ratchet_wire.hpp is the single production location of the baseline constant: make_dgb_ratchet() constructs AutoRatchet(target=36, base=35) and dgb_select_mint_versions() is the run-loop selector. The work-weighted tail guard already inside get_share_version keeps mint activation subordinate to the 60%-by-work accept gate (#249/#289) -- this seam adds no new policy. base_version stays an explicit constructor param so the v37 unified shape is clean. De-staled the [decision-needed] notes in auto_ratchet.hpp and share_test.cpp. +2 KATs pin the wired constant and bootstrap mint=35/vote=36; dgb_share_test 22/22 green. Surface-for-tap (consensus-bearing version-gate flip), HOLD. Co-authored-by: frstrtr <frstrtr@users.noreply.github.com>
1 parent 3004e58 commit e45baef

3 files changed

Lines changed: 103 additions & 9 deletions

File tree

src/impl/dgb/auto_ratchet.hpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,16 @@
2424
// Port of p2pool-v36 data.py AutoRatchet (lines 2109-2344), mirroring
2525
// src/impl/ltc/auto_ratchet.hpp.
2626
//
27-
// DGB DIVERGENCE FROM LTC (per operator 2026-06-17 re-scope): DGB's live
28-
// pre-v36 baseline is NOT necessarily V35 — it conforms to the DGB oracle
29-
// frstrtr/p2pool-dgb-scrypt, which runs an OLDER share version than LTC's
30-
// v35. The VOTING-state output version is therefore a CONSTRUCTOR PARAMETER
31-
// (base_version_), NOT the ltc hardcode `target_version_ - 1`. The exact live
32-
// value is a [decision-needed] for the wiring step; the default below keeps
33-
// the module compilable and KAT-exercisable but MUST be overridden at the
34-
// run-loop wire-in once confirmed against the oracle. Until then this module
35-
// is surface-for-tap (unwired).
27+
// DGB DIVERGENCE FROM LTC (per operator 2026-06-17 re-scope): DGB's
28+
// VOTING-state output version is a CONSTRUCTOR PARAMETER (base_version_), NOT
29+
// the ltc hardcode `target_version_ - 1`. The "older than LTC" axis is the P2P
30+
// PROTOCOL version (p2p.py VERSION=3501 vs LTC 3503), not the share version.
31+
// BASELINE RESOLVED 2026-06-21: oracle frstrtr/p2pool-dgb-scrypt @22761e7
32+
// mints share VERSION=35 (data.py:636, SUCCESSOR=None) => base_version=35.
33+
// The production wire-in pins this constant in auto_ratchet_wire.hpp
34+
// (make_dgb_ratchet); this module keeps the parameter explicit so the v37
35+
// unified shape stays clean. The compile default (target-1) only applies to
36+
// bare AutoRatchet(...) construction in tests.
3637

3738
#include "config_pool.hpp"
3839
#include "share_tracker.hpp"

src/impl/dgb/auto_ratchet_wire.hpp

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#pragma once
2+
3+
// auto_ratchet_wire.hpp — DGB production wire-in for the AutoRatchet mint-side
4+
// share-version ratchet.
5+
//
6+
// This is the run-loop seam that turns the (otherwise compile-default)
7+
// AutoRatchet into a node that mints the CORRECT DGB baseline share version
8+
// while voting for the V36 target. It exists as a separate translation unit
9+
// from auto_ratchet.hpp so the consensus-bearing baseline constant lives in
10+
// exactly one production location and can be tap-reviewed on its own.
11+
//
12+
// BASELINE RESOLVED (was a [decision-needed]; closed 2026-06-21):
13+
// Oracle = frstrtr/p2pool-dgb-scrypt @ 22761e7 (2026-06-17).
14+
// data.py:636 Share.VERSION = 35, VOTING_VERSION = 35,
15+
// SUCCESSOR = None, share_versions = {35: Share}
16+
// networks/digibyte.py:26 SEGWIT_ACTIVATION_VERSION = 35
17+
// SUCCESSOR=None => 35 is the format the live node currently mints, so the
18+
// VOTING-state output (base_version) is unambiguously 35. DGB's "older than
19+
// LTC" axis is the P2P PROTOCOL version (p2p.py VERSION = 3501 vs LTC 3503),
20+
// NOT the share version — both share versions are 35. base_version=35
21+
// therefore coincides with LTC's target-1, but stays an explicit constant
22+
// here because the v37 unified shape wants it explicit and the protocol-gap
23+
// is real elsewhere.
24+
//
25+
// Bucket-2 (v36-native shared structure): the ratchet SHAPE is standardized
26+
// cross-coin toward the v37 unified form; only the per-coin baseline constant
27+
// below is DGB-specific. The work-weighted tail guard inside
28+
// AutoRatchet::get_share_version keeps mint activation subordinate to the
29+
// 60%-by-work accept gate (#249/#289) — this seam adds no new policy, it only
30+
// pins the constants and hands callers the {mint, vote} version pair.
31+
32+
#include "auto_ratchet.hpp"
33+
34+
namespace dgb
35+
{
36+
37+
// DGB live-baseline share version minted while VOTING (oracle 22761e7).
38+
inline constexpr int64_t DGB_BASE_VERSION = 35;
39+
// V36 crossing target.
40+
inline constexpr int64_t DGB_TARGET_VERSION = 36;
41+
42+
// Production factory: construct the DGB AutoRatchet with the oracle-confirmed
43+
// baseline. state_file_path persists VOTING/ACTIVATED/CONFIRMED across restarts
44+
// so a crossed node never regresses. This is THE place base_version=35 enters
45+
// production code.
46+
inline AutoRatchet make_dgb_ratchet(const std::string& state_file_path = "")
47+
{
48+
return AutoRatchet(state_file_path, DGB_TARGET_VERSION, DGB_BASE_VERSION);
49+
}
50+
51+
// Run-loop selector: given the live tracker + current best share, return the
52+
// {share_version_to_mint, desired_version_to_vote} pair the node should stamp
53+
// onto the share it is about to create. Thin pass-through over the state
54+
// machine so the run-loop never re-implements the gate; centralizes the call
55+
// the eventual create_local_share() caller binds to.
56+
inline std::pair<int64_t, int64_t> dgb_select_mint_versions(
57+
AutoRatchet& ratchet, ShareTracker& tracker, const uint256& best_share_hash)
58+
{
59+
return ratchet.get_share_version(tracker, best_share_hash);
60+
}
61+
62+
} // namespace dgb

src/impl/dgb/test/share_test.cpp

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <impl/dgb/params.hpp> // make_coin_params — assembled CoinParams SSOT
2222
#include <impl/dgb/coin/rpc_conf.hpp> // #82 external-daemon RPC creds (digibyte.conf)
2323
#include <impl/dgb/auto_ratchet.hpp> // Phase B: mint-side share-version ratchet
24+
#include <impl/dgb/auto_ratchet_wire.hpp> // Phase B: production wire-in (base_version=35)
2425
#include <unistd.h> // getpid (AutoRatchet KAT temp state file)
2526

2627
#include <cstdio>
@@ -434,3 +435,33 @@ TEST(DGB_share_test, AutoRatchetStatePersistsAcrossRestart)
434435
EXPECT_EQ(vote, 36);
435436
std::remove(path.c_str());
436437
}
438+
439+
// ----------------------------------------------------------------------------
440+
// Production wire-in (auto_ratchet_wire.hpp). The DGB baseline [decision-needed]
441+
// is RESOLVED: oracle frstrtr/p2pool-dgb-scrypt @22761e7 mints share VERSION=35
442+
// (SUCCESSOR=None), so base_version=35. These KATs pin that constant where it
443+
// enters production code, so a future edit that regresses it to the ltc
444+
// hardcode fails loudly.
445+
// ----------------------------------------------------------------------------
446+
TEST(DGB_share_test, AutoRatchetWireBaselineConstantsFromOracle)
447+
{
448+
EXPECT_EQ(dgb::DGB_BASE_VERSION, 35);
449+
EXPECT_EQ(dgb::DGB_TARGET_VERSION, 36);
450+
451+
auto ar = dgb::make_dgb_ratchet();
452+
EXPECT_EQ(ar.base_version(), 35); // oracle 22761e7, NOT a hardcode coincidence
453+
EXPECT_EQ(ar.target_version(), 36);
454+
EXPECT_EQ(ar.state(), dgb::RatchetState::VOTING);
455+
}
456+
457+
// A freshly-started production node votes V36 but MINTS the V35 baseline — it
458+
// must not skip ahead of the network on an empty tracker.
459+
TEST(DGB_share_test, AutoRatchetWireBootstrapMints35Votes36)
460+
{
461+
auto ar = dgb::make_dgb_ratchet();
462+
dgb::ShareTracker tracker;
463+
auto [mint, vote] = dgb::dgb_select_mint_versions(ar, tracker, uint256{});
464+
EXPECT_EQ(mint, 35); // baseline share version (oracle)
465+
EXPECT_EQ(vote, 36); // always vote target
466+
EXPECT_EQ(ar.state(), dgb::RatchetState::VOTING);
467+
}

0 commit comments

Comments
 (0)