Skip to content

Commit bace615

Browse files
committed
Merge bitcoin/bitcoin#24565: Remove LOCKTIME_MEDIAN_TIME_PAST constant
fa1fe2e Remove LOCKTIME_MEDIAN_TIME_PAST constant (MarcoFalke) Pull request description: The constant is exposed in policy code, which doesn't make sense: * Wallet and mempool need to assume the flag to be always active to function properly. * Setting (or unsetting) the flag has no effect on policy code. The constant is only used in `ContextualCheckBlock` (consensus code) to set a flag and then read the flag again. I think this can be better achieved by using a `bool`. If there is a need to use a flag in the future, it will be trivial to do so then. (The previous use for the constant was removed in df562d6) ACKs for top commit: Sjors: utACK fa1fe2e glozow: code review ACK fa1fe2e, AFAICT this is safe and makes sense as `SequenceLocks` doesn't use it, wallet/ATMP no longer need it since #24080, and `ContextualCheckBlock` effectively uses it as a roundabout boolean. instagibbs: utACK fa1fe2e Tree-SHA512: de1972498c545d608a09630d77d8c7e38ed50a6ec40d6c0d720310a1647ed5b48b4ace0078c80db10e7f97aacc552fffae251fe3256e9a19a908b933ba2dc552
2 parents 5bf65ec + fa1fe2e commit bace615

File tree

4 files changed

+8
-11
lines changed

4 files changed

+8
-11
lines changed

src/consensus/consensus.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,5 @@ static const size_t MIN_SERIALIZABLE_TRANSACTION_WEIGHT = WITNESS_SCALE_FACTOR *
2626
/** Flags for nSequence and nLockTime locks */
2727
/** Interpret sequence numbers as relative lock-time constraints. */
2828
static constexpr unsigned int LOCKTIME_VERIFY_SEQUENCE = (1 << 0);
29-
/** Use GetMedianTimePast() instead of nTime for end point timestamp. */
30-
static constexpr unsigned int LOCKTIME_MEDIAN_TIME_PAST = (1 << 1);
3129

3230
#endif // BITCOIN_CONSENSUS_CONSENSUS_H

src/policy/policy.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,7 @@ static constexpr unsigned int STANDARD_SCRIPT_VERIFY_FLAGS{MANDATORY_SCRIPT_VERI
101101
static constexpr unsigned int STANDARD_NOT_MANDATORY_VERIFY_FLAGS{STANDARD_SCRIPT_VERIFY_FLAGS & ~MANDATORY_SCRIPT_VERIFY_FLAGS};
102102

103103
/** Used as the flags parameter to sequence and nLocktime checks in non-consensus code. */
104-
static constexpr unsigned int STANDARD_LOCKTIME_VERIFY_FLAGS{LOCKTIME_VERIFY_SEQUENCE |
105-
LOCKTIME_MEDIAN_TIME_PAST};
104+
static constexpr unsigned int STANDARD_LOCKTIME_VERIFY_FLAGS{LOCKTIME_VERIFY_SEQUENCE};
106105

107106
CAmount GetDustThreshold(const CTxOut& txout, const CFeeRate& dustRelayFee);
108107

src/test/miner_tests.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -369,8 +369,8 @@ void MinerTestingSetup::TestBasicMining(const CChainParams& chainparams, const C
369369
}
370370

371371
// non-final txs in mempool
372-
SetMockTime(m_node.chainman->ActiveChain().Tip()->GetMedianTimePast()+1);
373-
const int flags{LOCKTIME_VERIFY_SEQUENCE | LOCKTIME_MEDIAN_TIME_PAST};
372+
SetMockTime(m_node.chainman->ActiveChain().Tip()->GetMedianTimePast() + 1);
373+
const int flags{LOCKTIME_VERIFY_SEQUENCE};
374374
// height map
375375
std::vector<int> prevheights;
376376

src/validation.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3491,15 +3491,15 @@ static bool ContextualCheckBlock(const CBlock& block, BlockValidationState& stat
34913491
const int nHeight = pindexPrev == nullptr ? 0 : pindexPrev->nHeight + 1;
34923492

34933493
// Enforce BIP113 (Median Time Past).
3494-
int nLockTimeFlags = 0;
3494+
bool enforce_locktime_median_time_past{false};
34953495
if (DeploymentActiveAfter(pindexPrev, chainman, Consensus::DEPLOYMENT_CSV)) {
34963496
assert(pindexPrev != nullptr);
3497-
nLockTimeFlags |= LOCKTIME_MEDIAN_TIME_PAST;
3497+
enforce_locktime_median_time_past = true;
34983498
}
34993499

3500-
int64_t nLockTimeCutoff = (nLockTimeFlags & LOCKTIME_MEDIAN_TIME_PAST)
3501-
? pindexPrev->GetMedianTimePast()
3502-
: block.GetBlockTime();
3500+
const int64_t nLockTimeCutoff{enforce_locktime_median_time_past ?
3501+
pindexPrev->GetMedianTimePast() :
3502+
block.GetBlockTime()};
35033503

35043504
// Check that all transactions are finalized
35053505
for (const auto& tx : block.vtx) {

0 commit comments

Comments
 (0)