From 16e95bda86302af20cfb314a2c0252256d01f750 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Tue, 13 Aug 2024 15:58:39 +0000 Subject: [PATCH] Move maximum timewarp attack threshold back to 600s from 7200s In 6bfa26048dbafb91e9ca63ea8d3960271e798098 the testnet4 timewarp attack fix block time variation was increased from the Great Consensus Cleanup value of 600s to 7200s on the thesis that this allows miners to always create blocks with the current time. Sadly, doing so does allow for some nonzero inflation, even if not a huge amount. While it could be that some hardware ignores the timestamp provided to it over Stratum and forces the block header timestamp to the current time, I'm not aware of any such hardware, and it would also likely suffer from random invalid blocks due to relying on NTP anyway, making its existence highly unlikely. This leaves the only concern being pools, but most of those rely on work generated by Bitcoin Core (in one way or another, though when spy mining possibly not), and it seems likely that they will also not suffer any lost work. While its possible that a pool does generate invalid work due to spy mining or otherwise custom logic, it seems unlikely that a substantial portion of hashrate would do so, making the difference somewhat academic (any pool that screws this up will only do so once and the network would come out just fine). Further, while we may end up deciding these assumptions were invalid and we should instead use 7200s, it seems prudent to try with the value we "want" on testnet4, giving us the ability to learn if the compatibility concerns are an issue before we go to mainnet. --- src/validation.cpp | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/validation.cpp b/src/validation.cpp index 25da81ae8ab57..bf2b4b315e614 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -112,15 +112,7 @@ static constexpr int PRUNE_LOCK_BUFFER{10}; * block of a difficulty adjustment period is allowed to * be earlier than the last block of the previous period (BIP94). */ -static constexpr int64_t MAX_TIMEWARP{MAX_FUTURE_BLOCK_TIME}; - -/** - * If the timestamp of the last block in a difficulty period is set - * MAX_FUTURE_BLOCK_TIME seconds in the future, an honest miner should - * be able to mine the first block using the current time. This is not - * a consensus rule, but changing MAX_TIMEWARP should be done with caution. - */ -static_assert(MAX_FUTURE_BLOCK_TIME <= MAX_TIMEWARP); +static constexpr int64_t MAX_TIMEWARP = 600; GlobalMutex g_best_block_mutex; std::condition_variable g_best_block_cv;