mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-02-11 17:52:48 +01:00
headerssync: Make HeadersSyncState more flexible and move constants
Move calculated constants from the top of src/headerssync.cpp into src/kernel/chainparams.cpp. Instead of being hardcoded to mainnet parameters, HeadersSyncState can now vary depending on chain or test. (This means we can reset TARGET_BLOCKS back to the nice round number of 15'000). Signet and testnets got new HeadersSyncParams constants through temporarily altering headerssync-params.py with corresponding GENESIS_TIME and MINCHAINWORK_HEADERS (based off defaultAssumeValid block height comments, corresponding to nMinimumChainWork). Regtest doesn't have a default assume valid block height, so the values are copied from Testnet 4. Since the constants only affect memory usage, and have very low impact unless dealing with a largely malicious chain, it's not that critical to keep updating them for non-mainnet chains. GENESIS_TIMEs (UTC): Testnet3: 1296688602 = datetime(2011, 2, 2) Testnet4: 1714777860 = datetime(2024, 5, 3) Signet: 1598918400 = datetime(2020, 9, 1)
This commit is contained in:
@@ -195,6 +195,12 @@ public:
|
||||
.tx_count = 1235299397,
|
||||
.dTxRate = 5.456290459519495,
|
||||
};
|
||||
|
||||
// Generated by headerssync-params.py on 2025-09-01.
|
||||
m_headers_sync_params = HeadersSyncParams{
|
||||
.commitment_period = 632,
|
||||
.redownload_buffer_size = 15009, // 15009/632 = ~23.7 commitments
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
@@ -292,6 +298,12 @@ public:
|
||||
.tx_count = 508468699,
|
||||
.dTxRate = 7.172978845985714,
|
||||
};
|
||||
|
||||
// Generated by headerssync-params.py on 2025-09-03.
|
||||
m_headers_sync_params = HeadersSyncParams{
|
||||
.commitment_period = 628,
|
||||
.redownload_buffer_size = 13460, // 13460/628 = ~21.4 commitments
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
@@ -393,6 +405,12 @@ public:
|
||||
.tx_count = 11414302,
|
||||
.dTxRate = 0.2842619757327476,
|
||||
};
|
||||
|
||||
// Generated by headerssync-params.py on 2025-09-03.
|
||||
m_headers_sync_params = HeadersSyncParams{
|
||||
.commitment_period = 275,
|
||||
.redownload_buffer_size = 7017, // 7017/275 = ~25.5 commitments
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
@@ -506,6 +524,12 @@ public:
|
||||
|
||||
fDefaultConsistencyChecks = false;
|
||||
m_is_mockable_chain = false;
|
||||
|
||||
// Generated by headerssync-params.py on 2025-09-03.
|
||||
m_headers_sync_params = HeadersSyncParams{
|
||||
.commitment_period = 390,
|
||||
.redownload_buffer_size = 9584, // 9584/390 = ~24.6 commitments
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
@@ -636,6 +660,12 @@ public:
|
||||
base58Prefixes[EXT_SECRET_KEY] = {0x04, 0x35, 0x83, 0x94};
|
||||
|
||||
bech32_hrp = "bcrt";
|
||||
|
||||
// Copied from Testnet4.
|
||||
m_headers_sync_params = HeadersSyncParams{
|
||||
.commitment_period = 275,
|
||||
.redownload_buffer_size = 7017, // 7017/275 = ~25.5 commitments
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user