Commit Graph

17 Commits

Author SHA1 Message Date
Hodlinator
cc5dda1de3 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)
2025-09-12 22:28:41 +02:00
Hodlinator
e984618d0b refactor(headerssync): Process spans of headers
More lightweight than vectors which needed to be copied in tests. Also good to get rid of headers_batch-vector before breaking up test.
2025-09-12 22:28:41 +02:00
fanquake
943de66b50 kernel: update headersync params 2025-09-02 11:59:48 +01:00
marcofleon
9c24cda72e refactor: Convert remaining instances from uint256 to Txid
These remaining miscellaneous changes were identified by commenting out
the `operator const uint256&` conversion and the `Compare(const uint256&)`
method from `transaction_identifier.h`.
2025-08-11 16:47:43 +01:00
glozow
11a2d3a63e [headerssync] update headerssync config for v29 2025-03-04 14:23:18 -05:00
MarcoFalke
3333415890 scripted-diff: LogPrint -> LogDebug
-BEGIN VERIFY SCRIPT-
 sed -i 's/\<LogPrint\>/LogDebug/g' $( git grep -l '\<LogPrint\>'  -- ./contrib/ ./src/ ./test/ ':(exclude)src/logging.h' )
-END VERIFY SCRIPT-
2024-08-29 13:49:57 +02:00
Ava Chow
221809b81c headerssync: Update headerssync configuration 2024-08-16 11:23:23 -04:00
Pieter Wuille
ddc184d999 random: get rid of GetRand by inlining 2024-07-01 12:39:53 -04:00
MarcoFalke
fad0fafd5a refactor: Fix timedata includes 2024-02-01 13:52:05 +01:00
dergoegge
ff9039f6ea Remove GetAdjustedTime 2024-01-05 17:16:38 +00:00
MarcoFalke
fa05a726c2 tidy: modernize-use-emplace 2023-10-12 11:27:19 +02:00
fanquake
b2ede22395 headerssync: update params for 26.x 2023-10-05 11:36:03 +01:00
Pieter Wuille
53d7d35b58 Update parameters in headerssync.cpp 2023-09-28 12:07:54 -04:00
Pieter Wuille
3fcd7fc7ff Do not use std::vector = {} to release memory 2023-09-13 07:20:36 -04:00
dergoegge
53552affca [headerssync] Make m_commit_offset protected 2022-12-12 21:06:04 +00:00
Suhas Daftuar
132ed7eaaa Move headerssync logging to BCLog::NET 2022-08-30 12:09:04 -04:00
Suhas Daftuar
551a8d957c Utilize anti-DoS headers download strategy
Avoid permanently storing headers from a peer, unless the headers are part of a
chain with sufficiently high work. This prevents memory attacks using low-work
headers.

Designed and co-authored with Pieter Wuille.
2022-08-29 08:10:35 -04:00