Skip to content

Commit e8011fc

Browse files
committed
btc: adopt oracle FLOOR for v36 version-gate tail accept (SSOT step-2)
Replace the inline tail-guard CEIL form (target*100 >= total*60) with the p2pool data.py FLOOR form (target >= floor(total*60/100)) in AutoRatchet::get_share_version. At a non-integral boundary (total*60 % 100 != 0) the cross-multiplied CEIL latched up to one work-unit later than the network oracle; FLOOR makes our 60%-by-work accept gate byte-identical to every peer, removing the c2pool-only late-latch divergence. Updates the test replica inline_tail_ok to the same FLOOR form and closes the SSOT2 standardization seam: the boundary KAT now pins the CONVERGED state (inline==oracle at total=101) instead of the proven divergence. All 7 AutoRatchet KATs + full btc_share_test (39/39) green; sibling C3 accept-gate / mint-cannot-outrun-accept / monotonic gates unaffected (integral or far-from-boundary). Consensus surface now equals the p2pool oracle exactly. Held off btc/version-gate-ssot-step2-floor-kat; pairs with the step-2 evidence pair (KAT 291fafa + prod-vote-safety 1579dc4). Operator-tap gated via the version_gate SSOT decision card.
1 parent d0343b7 commit e8011fc

2 files changed

Lines changed: 31 additions & 21 deletions

File tree

src/impl/btc/auto_ratchet.hpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,16 @@ class AutoRatchet
166166
if (static_cast<int64_t>(ver) >= target_version_)
167167
tail_target = tail_target + w;
168168
}
169-
// Canonical: counts.get(VERSION,0) < sum(counts)*60//100
170-
bool tail_ok = !(tail_target * uint32_t(100) < tail_total * uint32_t(SWITCH_THRESHOLD));
169+
// Canonical FLOOR (p2pool data.py share-acceptance):
170+
// valid iff target >= floor(total * SWITCH_THRESHOLD / 100)
171+
// i.e. counts.get(VERSION,0) >= sum(counts)*60//100.
172+
// The prior cross-multiplied form (target*100 >= total*60) is the
173+
// algebraic CEIL: at a non-integral boundary (total*60 % 100 != 0)
174+
// it latched up to one work-unit LATER than the network oracle.
175+
// Adopting FLOOR removes that c2pool-only late-latch divergence so
176+
// our accept gate is byte-identical to every p2pool peer's.
177+
bool tail_ok = !(tail_target <
178+
(tail_total * uint32_t(SWITCH_THRESHOLD)) / uint32_t(100));
171179

172180
if (!tail_ok) {
173181
static int tail_log = 0;

src/impl/btc/test/auto_ratchet_sim_test.cpp

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,15 @@ using btc::RatchetState;
3434
namespace {
3535

3636
// Verbatim replica of the LIVE inline tail-guard in
37-
// AutoRatchet::get_share_version: tail_ok = !(target*100 < total*SWITCH).
37+
// AutoRatchet::get_share_version: tail_ok = !(target < total*SWITCH/100).
3838
// Localises the 60%-by-WORK accept gate so C3 pins it WITHOUT driving the
39-
// consensus path or importing a lifted SSOT.
39+
// consensus path or importing a lifted SSOT. FLOOR form, tracking the SSOT
40+
// step-2 adoption (was the algebraic CEIL target*100 < total*SWITCH).
4041
bool inline_tail_ok(const uint288& target, const uint288& total,
4142
int thr = AutoRatchet::SWITCH_THRESHOLD)
4243
{
43-
return !((target * static_cast<uint32_t>(100)) <
44-
(total * static_cast<uint32_t>(thr)));
44+
return !(target < (total * static_cast<uint32_t>(thr))
45+
/ static_cast<uint32_t>(100));
4546
}
4647

4748
// 95%-by-COUNT activation predicate (flat head-count), mirroring the VOTING ->
@@ -199,19 +200,20 @@ TEST(BTC_AutoRatchetSim, C4_StatePersistsAcrossRestart)
199200
//
200201
// p2pool oracle (data.py share-acceptance) valid threshold is the FLOOR form:
201202
// counts.get(VERSION,0) >= sum(counts)*60//100 # floor
202-
// The BTC inline tail-guard (auto_ratchet.hpp:169, replicated as
203-
// inline_tail_ok above) is the algebraic CEIL form at the boundary:
204-
// target*100 >= total*60 <=> target >= ceil(total*60/100).
205-
// When (total*60) % 100 != 0, floor < ceil, so the ORACLE latches up to one
206-
// share EARLIER than our form. This KAT PINS that divergence at a non-integral
207-
// boundary (total=101 => total*60 = 6060, 6060 % 100 = 60 != 0):
208-
// floor(6060/100) = 60 (oracle: target=60 PASSES)
209-
// ceil (6060/100) = 61 (inline: target=60 HOLDS)
210-
// The EXPECT_FALSE on the inline form is the STANDARDIZATION SEAM: it flips to
211-
// PASS only when the core-SSOT floor adoption lands (EXCEPTIONAL/operator-tap
212-
// gated). Until then it locks the gap as PROVEN, not asserted. The integral
213-
// control (total=100) shows the two forms AGREE when the boundary is exact, so
214-
// the divergence is the %100 remainder alone. Consensus surface UNCHANGED.
203+
// The BTC inline tail-guard (auto_ratchet.hpp, replicated as inline_tail_ok
204+
// above) has ADOPTED that FLOOR form. Previously it was the algebraic CEIL
205+
// target*100 >= total*60 <=> target >= ceil(total*60/100),
206+
// which at a non-integral boundary (total*60 % 100 != 0) latched up to one
207+
// share LATER than the oracle. This KAT now PINS the CONVERGED state: at the
208+
// same non-integral boundary (total=101 => total*60 = 6060, 6060 % 100 != 0)
209+
// floor(6060/100) = 60 (oracle : target=60 PASSES)
210+
// inline (FLOOR) = 60 (adopted : target=60 PASSES) <-- seam CLOSED
211+
// Pre-adoption this line read EXPECT_FALSE on the inline form (CEIL held until
212+
// 61); the SSOT floor adoption (operator-tap gated) flips it to EXPECT_TRUE.
213+
// The integral control (total=100) still shows both forms AGREE on the exact
214+
// boundary, so the only behavioural change is the %100 remainder share, now
215+
// accepted one unit earlier in lock-step with the network. Consensus surface
216+
// equals the p2pool oracle EXACTLY.
215217
// ---------------------------------------------------------------------------
216218
TEST(BTC_AutoRatchetSim, SSOT2_OracleFloorVsInlineCeilBoundary)
217219
{
@@ -227,8 +229,8 @@ TEST(BTC_AutoRatchetSim, SSOT2_OracleFloorVsInlineCeilBoundary)
227229

228230
const uint288 total(101); // 101*60 = 6060, %100 = 60
229231
EXPECT_TRUE (oracle_floor_ok(uint288(60), total)); // oracle: latches at 60
230-
EXPECT_FALSE(inline_tail_ok (uint288(60), total)); // inline: holds until 61
231-
// One share later the two forms re-converge.
232+
EXPECT_TRUE (inline_tail_ok (uint288(60), total)); // inline FLOOR: latches at 60 too
233+
// Forms are now identical at every point (boundary and beyond).
232234
EXPECT_TRUE (oracle_floor_ok(uint288(61), total));
233235
EXPECT_TRUE (inline_tail_ok (uint288(61), total));
234236
}

0 commit comments

Comments
 (0)