Skip to content

Commit ccd86b3

Browse files
committed
Bootstrap full safety depth: MIN_BLOCKS_TO_KEEP (288 LTC / 1440 DOGE)
Change bootstrap block request depth from coinbase_maturity (100/240) to MIN_BLOCKS_TO_KEEP (288/1440), matching pruned daemon safety depth. LTC: 288 blocks (litecoin/src/validation.h MIN_BLOCKS_TO_KEEP) DOGE: 1440 blocks (dogecoin/src/validation.h MIN_BLOCKS_TO_KEEP) Maturity gate (100/240) remains as the mining readiness check. Bootstrap downloads the full safety window for reorg protection. Anchor checkpoints (--header-checkpoint) are now optional speedups, not required — header sync works from genesis with PoW skip.
1 parent 1ac307b commit ccd86b3

1 file changed

Lines changed: 21 additions & 15 deletions

File tree

src/c2pool/c2pool_refactored.cpp

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1452,7 +1452,9 @@ int main(int argc, char* argv[]) {
14521452
}
14531453
});
14541454

1455-
// Wire peer height callback for fast-sync: skip scrypt on old headers
1455+
// Wire peer height callback for fast-sync: skip scrypt PoW on old headers.
1456+
// No anchor checkpoint needed — header sync is fast (headers are 80 bytes,
1457+
// old ones skip scrypt PoW). Use --header-checkpoint as optional speedup.
14561458
embedded_broadcaster->set_on_peer_height(
14571459
[chain = embedded_chain.get()](uint32_t h) {
14581460
chain->set_peer_tip_height(h);
@@ -1768,15 +1770,17 @@ int main(int argc, char* argv[]) {
17681770
LOG_INFO << "[EMB-LTC] UTXO ready — enabled BIP 35 mempool sync";
17691771
}
17701772

1771-
// Bootstrap: seed UTXO with coinbase_maturity (100) blocks.
1772-
// Reference: litecoin/src/consensus/consensus.h COINBASE_MATURITY = 100
1773+
// Bootstrap: seed UTXO with MIN_BLOCKS_TO_KEEP (288) blocks.
1774+
// Matches litecoind pruned node safety depth.
1775+
// Reference: litecoin/src/validation.h MIN_BLOCKS_TO_KEEP = 288
17731776
// Only fire once, and only when header chain has synced
1774-
// (height > maturity ensures we're at tip, not genesis).
1777+
// (height > keep_depth ensures we're at tip, not genesis).
17751778
static bool ltc_bootstrap_done = false;
1776-
if (!ltc_bootstrap_done && chain && bcaster && height > coinbase_maturity) {
1779+
constexpr uint32_t LTC_KEEP = core::coin::LTC_MIN_BLOCKS_TO_KEEP;
1780+
if (!ltc_bootstrap_done && chain && bcaster && height > LTC_KEEP) {
17771781
ltc_bootstrap_done = true;
17781782
int requested = 0;
1779-
for (uint32_t bi = 1; bi <= coinbase_maturity && bi <= height; ++bi) {
1783+
for (uint32_t bi = 1; bi <= LTC_KEEP && bi <= height; ++bi) {
17801784
auto entry = chain->get_header_by_height(height - bi);
17811785
if (entry) {
17821786
bcaster->request_full_block(entry->block_hash);
@@ -1785,8 +1789,8 @@ int main(int argc, char* argv[]) {
17851789
}
17861790
if (requested > 0)
17871791
LOG_INFO << "[EMB-LTC] Bootstrap: requested " << requested
1788-
<< " historical blocks to seed UTXO (maturity="
1789-
<< coinbase_maturity << ")";
1792+
<< " historical blocks (MIN_BLOCKS_TO_KEEP="
1793+
<< LTC_KEEP << ")";
17901794
}
17911795
}
17921796

@@ -3792,22 +3796,24 @@ int main(int argc, char* argv[]) {
37923796
LOG_INFO << "[EMB-DOGE] UTXO ready — mempool tx relay active (inv/tx, no BIP 35)";
37933797
}
37943798

3795-
// Bootstrap: seed UTXO with coinbase_maturity (240) blocks.
3796-
// Reference: dogecoin/src/chainparams.cpp digishieldConsensus.nCoinbaseMaturity = 240
3799+
// Bootstrap: seed UTXO with MIN_BLOCKS_TO_KEEP (1440) blocks.
3800+
// Matches dogecoind pruned node safety depth.
3801+
// Reference: dogecoin/src/validation.h MIN_BLOCKS_TO_KEEP = 1440
37973802
// Only fire once, and only when header chain has synced
3798-
// (height > 0 from header lookup, not genesis fallback).
3803+
// (height > keep_depth ensures we're at tip, not genesis).
37993804
static bool doge_bootstrap_done = false;
3800-
if (!doge_bootstrap_done && chain && height > coinbase_maturity) {
3805+
constexpr uint32_t DOGE_KEEP = core::coin::DOGE_MIN_BLOCKS_TO_KEEP;
3806+
if (!doge_bootstrap_done && chain && height > DOGE_KEEP) {
38013807
doge_bootstrap_done = true;
38023808
int req = 0;
3803-
for (uint32_t bi = 1; bi <= coinbase_maturity && bi <= height; ++bi) {
3809+
for (uint32_t bi = 1; bi <= DOGE_KEEP && bi <= height; ++bi) {
38043810
auto e = chain->get_header_by_height(height - bi);
38053811
if (e) { bcaster_ptr->request_full_block(e->block_hash); ++req; }
38063812
}
38073813
if (req > 0)
38083814
LOG_INFO << "[EMB-DOGE] Bootstrap: requested " << req
3809-
<< " historical blocks to seed UTXO (maturity="
3810-
<< coinbase_maturity << ")";
3815+
<< " historical blocks (MIN_BLOCKS_TO_KEEP="
3816+
<< DOGE_KEEP << ")";
38113817
}
38123818
}
38133819
if (pool) {

0 commit comments

Comments
 (0)