Skip to content

Commit dbaf58d

Browse files
committed
feat(bch): BCH_DEMO_SHARE_BITS env knob for CPU-provable G2 accumulation
Symmetric to BCH_DEMO_BLOCK_BITS. The cold-start share-floor seed hardcoded PoolConfig::max_target() (~diff-1 / 0x1d00ffff), which a CPU grinder cannot clear at a useful rate, so the sharechain STORED counter never advanced independently of block-founds even after the cold-start deadlock fix (f8a1263). BCH_DEMO_SHARE_BITS pins the cold-start share floor to a CPU-clearable compact target on an isolated net so a grinder promotes real STORED shares while BCH_DEMO_BLOCK_BITS keeps block-founds rare -- proving 0->N accumulation without ASIC hashrate. Env-gated, off by default, never active on normal or mainnet runs. BCH-local.
1 parent f8a1263 commit dbaf58d

1 file changed

Lines changed: 17 additions & 2 deletions

File tree

src/impl/bch/stratum/work_source.cpp

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,8 +237,23 @@ BCHWorkSource::cached_template() const
237237
// Idempotent (fires only while unseeded); uses the exact floor
238238
// compute_share_target's genesis branch emits for max_bits.
239239
if (share_bits_.load(std::memory_order_relaxed) == 0) {
240-
const uint32_t floor_bits =
241-
chain::target_to_bits_upper_bound(bch::PoolConfig::max_target());
240+
// [ISOLATED-NET DEMO / G2] Symmetric to BCH_DEMO_BLOCK_BITS above: on a
241+
// genesis-difficulty isolated net PoolConfig::max_target() (the p2pool
242+
// network share floor, ~diff-1 / 0x1d00ffff) is far too hard for a CPU
243+
// grinder to clear at a useful rate, so the sharechain STORED counter
244+
// never advances independently of block-founds even after the
245+
// cold-start deadlock fix. BCH_DEMO_SHARE_BITS pins this cold-start
246+
// share floor to a CPU-clearable compact target (e.g. regtest powLimit
247+
// 0x207fffff) so a grinder promotes real STORED shares while
248+
// BCH_DEMO_BLOCK_BITS keeps block-founds rare -- proving 0->N sharechain
249+
// accumulation without ASIC hashrate. OFF unless set; never active on
250+
// normal or mainnet runs. BCH-local (no shared-core edit).
251+
uint32_t floor_bits;
252+
if (const char* e = std::getenv("BCH_DEMO_SHARE_BITS"); e && *e)
253+
floor_bits = static_cast<uint32_t>(std::strtoul(e, nullptr, 16));
254+
else
255+
floor_bits =
256+
chain::target_to_bits_upper_bound(bch::PoolConfig::max_target());
242257
share_bits_.store(floor_bits, std::memory_order_relaxed);
243258
share_max_bits_.store(floor_bits, std::memory_order_relaxed);
244259
}

0 commit comments

Comments
 (0)