Skip to content

Commit 389cf32

Browse files
committed
Merge bitcoin/bitcoin#30604: doc, chainparams: 29775 release notes and follow-ups
92c1d7d validation: Use MAX_TIMEWARP constant as testnet4 timewarp defense delta (Fabian Jahr) 4b2fad5 doc: Add release notes for 29775 (Fabian Jahr) f7cc973 doc: Align deprecation warnings (Fabian Jahr) 1163b08 chainparams: Add initial minimum chain work for Testnet4 (Fabian Jahr) Pull request description: This completes follow-ups left open in #29775. - Adds release notes - Addresses the [misalignment](bitcoin/bitcoin#29775 (comment)) in deprecation warnings and hints at the intention to remove support for Testnet3. - Adds initial minimum chainwork for Testnet4. - Use the `MAX_TIMEWARP` constant as the timewarp defense delta, equal to `MAX_FUTURE_BLOCK_TIME`. ACKs for top commit: Sjors: ACK 92c1d7d achow101: ACK 92c1d7d tdb3: re ACK 92c1d7d Tree-SHA512: 7ebdac7809f96231f75ca62706af59cd1ed27f713a4c7be5e2ad69fae95832b146b3ea23c712fb03b412da1deda7e8a5dae55bb2bbd2dcfd9f926e85c2a72666
2 parents bacab13 + 92c1d7d commit 389cf32

File tree

4 files changed

+28
-3
lines changed

4 files changed

+28
-3
lines changed

doc/release-notes-29775.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Testnet4/BIP94 support
2+
-----
3+
4+
Support for Testnet4 as specified in [BIP94](https://github.com/bitcoin/bips/blob/master/bip-0094.mediawiki)
5+
has been added. The network can be selected with the `-testnet4` option and
6+
the section header is also named `[testnet4]`.
7+
8+
While the intention is to phase out support for Testnet3 in an upcoming
9+
version, support for it is still available via the known options in this
10+
release.

src/chainparamsbase.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ void SetupChainParamsBaseOptions(ArgsManager& argsman)
1717
argsman.AddArg("-regtest", "Enter regression test mode, which uses a special chain in which blocks can be solved instantly. "
1818
"This is intended for regression testing tools and app development. Equivalent to -chain=regtest.", ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::CHAINPARAMS);
1919
argsman.AddArg("-testactivationheight=name@height.", "Set the activation height of 'name' (segwit, bip34, dersig, cltv, csv). (regtest-only)", ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::DEBUG_TEST);
20-
argsman.AddArg("-testnet", "Use the testnet3 chain. Equivalent to -chain=test. Support for testnet3 is deprecated and will be removed with the next release. Consider moving to testnet4 now by using -testnet4.", ArgsManager::ALLOW_ANY, OptionsCategory::CHAINPARAMS);
20+
argsman.AddArg("-testnet", "Use the testnet3 chain. Equivalent to -chain=test. Support for testnet3 is deprecated and will be removed in an upcoming release. Consider moving to testnet4 now by using -testnet4.", ArgsManager::ALLOW_ANY, OptionsCategory::CHAINPARAMS);
2121
argsman.AddArg("-testnet4", "Use the testnet4 chain. Equivalent to -chain=testnet4.", ArgsManager::ALLOW_ANY, OptionsCategory::CHAINPARAMS);
2222
argsman.AddArg("-vbparams=deployment:start:end[:min_activation_height]", "Use given start/end times and min_activation_height for specified version bits deployment (regtest-only)", ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::CHAINPARAMS);
2323
argsman.AddArg("-signet", "Use the signet chain. Equivalent to -chain=signet. Note that the network is defined by the -signetchallenge parameter", ArgsManager::ALLOW_ANY, OptionsCategory::CHAINPARAMS);

src/kernel/chainparams.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ class CTestNet4Params : public CChainParams {
334334
consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT;
335335
consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].min_activation_height = 0; // No activation delay
336336

337-
consensus.nMinimumChainWork = uint256{};
337+
consensus.nMinimumChainWork = uint256{"000000000000000000000000000000000000000000000056faca98a0cd9bdf5f"};
338338
consensus.defaultAssumeValid = uint256{};
339339

340340
pchMessageStart[0] = 0x1c;

src/validation.cpp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,21 @@ const std::vector<std::string> CHECKLEVEL_DOC {
107107
* */
108108
static constexpr int PRUNE_LOCK_BUFFER{10};
109109

110+
/**
111+
* Maximum number of seconds that the timestamp of the first
112+
* block of a difficulty adjustment period is allowed to
113+
* be earlier than the last block of the previous period (BIP94).
114+
*/
115+
static constexpr int64_t MAX_TIMEWARP{MAX_FUTURE_BLOCK_TIME};
116+
117+
/**
118+
* If the timestamp of the last block in a difficulty period is set
119+
* MAX_FUTURE_BLOCK_TIME seconds in the future, an honest miner should
120+
* be able to mine the first block using the current time. This is not
121+
* a consensus rule, but changing MAX_TIMEWARP should be done with caution.
122+
*/
123+
static_assert(MAX_FUTURE_BLOCK_TIME <= MAX_TIMEWARP);
124+
110125
GlobalMutex g_best_block_mutex;
111126
std::condition_variable g_best_block_cv;
112127
uint256 g_best_block;
@@ -4188,7 +4203,7 @@ static bool ContextualCheckBlockHeader(const CBlockHeader& block, BlockValidatio
41884203
// Check timestamp for the first block of each difficulty adjustment
41894204
// interval, except the genesis block.
41904205
if (nHeight % consensusParams.DifficultyAdjustmentInterval() == 0) {
4191-
if (block.GetBlockTime() < pindexPrev->GetBlockTime() - 60 * 60 * 2) {
4206+
if (block.GetBlockTime() < pindexPrev->GetBlockTime() - MAX_TIMEWARP) {
41924207
return state.Invalid(BlockValidationResult::BLOCK_INVALID_HEADER, "time-timewarp-attack", "block's timestamp is too early on diff adjustment block");
41934208
}
41944209
}

0 commit comments

Comments
 (0)