Skip to content

Commit 59876b3

Browse files
committed
Merge bitcoin/bitcoin#31376: Miner: never create a template which exploits the timewarp bug
733fa0b miner: never create a template which exploits the timewarp bug (Antoine Poinsot) Pull request description: This check was introduced in #30681 but only enabled for testnet4. To avoid potentially creating an invalid block template if a soft fork to fix the timewarp attack were to activate in the future, we should have this check on all networks. It also seems wise for our miner to not support it whether or not a soft fork activates to fix it at the consensus level. ACKs for top commit: Sjors: ACK 733fa0b fjahr: utACK 733fa0b TheCharlatan: ACK 733fa0b Tree-SHA512: 9b3bc8b26a57f93425b17dda80bcfac4ecb750a3d26bc3eb8df619135634e369ac15982fac0c9770b1df207bd2e418ffe02a98f37968f024e55262d97715a4f5
2 parents 449a25b + 733fa0b commit 59876b3

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

src/node/miner.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,10 @@ int64_t UpdateTime(CBlockHeader* pblock, const Consensus::Params& consensusParam
3333
int64_t nOldTime = pblock->nTime;
3434
int64_t nNewTime{std::max<int64_t>(pindexPrev->GetMedianTimePast() + 1, TicksSinceEpoch<std::chrono::seconds>(NodeClock::now()))};
3535

36-
if (consensusParams.enforce_BIP94) {
37-
// Height of block to be mined.
38-
const int height{pindexPrev->nHeight + 1};
39-
if (height % consensusParams.DifficultyAdjustmentInterval() == 0) {
40-
nNewTime = std::max<int64_t>(nNewTime, pindexPrev->GetBlockTime() - MAX_TIMEWARP);
41-
}
36+
// Height of block to be mined.
37+
const int height{pindexPrev->nHeight + 1};
38+
if (height % consensusParams.DifficultyAdjustmentInterval() == 0) {
39+
nNewTime = std::max<int64_t>(nNewTime, pindexPrev->GetBlockTime() - MAX_TIMEWARP);
4240
}
4341

4442
if (nOldTime < nNewTime) {

0 commit comments

Comments
 (0)