diff options
author | fanquake <fanquake@gmail.com> | 2022-06-28 18:08:10 +0100 |
---|---|---|
committer | fanquake <fanquake@gmail.com> | 2022-06-28 18:16:53 +0100 |
commit | bace615ba31cedec50afa4f296934a186b9afae6 (patch) | |
tree | 5d1f030a57496f613b07bc1c9049edf2f5470ba0 | |
parent | 5bf65ec66e5986c9188e3f6234f1c5c0f8dc7f90 (diff) | |
parent | fa1fe2e5004a6bacded464ed9778ff196e05859c (diff) |
Merge bitcoin/bitcoin#24565: Remove LOCKTIME_MEDIAN_TIME_PAST constant
fa1fe2e5004a6bacded464ed9778ff196e05859c 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 df562d698a386166ef93d03326c0480ea9bc11fe)
ACKs for top commit:
Sjors:
utACK fa1fe2e5004a6bacded464ed9778ff196e05859c
glozow:
code review ACK fa1fe2e5004a6bacded464ed9778ff196e05859c, 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 fa1fe2e5004a6bacded464ed9778ff196e05859c
Tree-SHA512: de1972498c545d608a09630d77d8c7e38ed50a6ec40d6c0d720310a1647ed5b48b4ace0078c80db10e7f97aacc552fffae251fe3256e9a19a908b933ba2dc552
-rw-r--r-- | src/consensus/consensus.h | 2 | ||||
-rw-r--r-- | src/policy/policy.h | 3 | ||||
-rw-r--r-- | src/test/miner_tests.cpp | 4 | ||||
-rw-r--r-- | src/validation.cpp | 10 |
4 files changed, 8 insertions, 11 deletions
diff --git a/src/consensus/consensus.h b/src/consensus/consensus.h index 788fa4e55b..b2a31e3ba4 100644 --- a/src/consensus/consensus.h +++ b/src/consensus/consensus.h @@ -26,7 +26,5 @@ static const size_t MIN_SERIALIZABLE_TRANSACTION_WEIGHT = WITNESS_SCALE_FACTOR * /** Flags for nSequence and nLockTime locks */ /** Interpret sequence numbers as relative lock-time constraints. */ static constexpr unsigned int LOCKTIME_VERIFY_SEQUENCE = (1 << 0); -/** Use GetMedianTimePast() instead of nTime for end point timestamp. */ -static constexpr unsigned int LOCKTIME_MEDIAN_TIME_PAST = (1 << 1); #endif // BITCOIN_CONSENSUS_CONSENSUS_H diff --git a/src/policy/policy.h b/src/policy/policy.h index cd46652efc..742b19a444 100644 --- a/src/policy/policy.h +++ b/src/policy/policy.h @@ -101,8 +101,7 @@ static constexpr unsigned int STANDARD_SCRIPT_VERIFY_FLAGS{MANDATORY_SCRIPT_VERI static constexpr unsigned int STANDARD_NOT_MANDATORY_VERIFY_FLAGS{STANDARD_SCRIPT_VERIFY_FLAGS & ~MANDATORY_SCRIPT_VERIFY_FLAGS}; /** Used as the flags parameter to sequence and nLocktime checks in non-consensus code. */ -static constexpr unsigned int STANDARD_LOCKTIME_VERIFY_FLAGS{LOCKTIME_VERIFY_SEQUENCE | - LOCKTIME_MEDIAN_TIME_PAST}; +static constexpr unsigned int STANDARD_LOCKTIME_VERIFY_FLAGS{LOCKTIME_VERIFY_SEQUENCE}; CAmount GetDustThreshold(const CTxOut& txout, const CFeeRate& dustRelayFee); diff --git a/src/test/miner_tests.cpp b/src/test/miner_tests.cpp index eca4fbf15c..20d670c1e1 100644 --- a/src/test/miner_tests.cpp +++ b/src/test/miner_tests.cpp @@ -369,8 +369,8 @@ void MinerTestingSetup::TestBasicMining(const CChainParams& chainparams, const C } // non-final txs in mempool - SetMockTime(m_node.chainman->ActiveChain().Tip()->GetMedianTimePast()+1); - const int flags{LOCKTIME_VERIFY_SEQUENCE | LOCKTIME_MEDIAN_TIME_PAST}; + SetMockTime(m_node.chainman->ActiveChain().Tip()->GetMedianTimePast() + 1); + const int flags{LOCKTIME_VERIFY_SEQUENCE}; // height map std::vector<int> prevheights; diff --git a/src/validation.cpp b/src/validation.cpp index b775c85912..f0b97c6b70 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -3491,15 +3491,15 @@ static bool ContextualCheckBlock(const CBlock& block, BlockValidationState& stat const int nHeight = pindexPrev == nullptr ? 0 : pindexPrev->nHeight + 1; // Enforce BIP113 (Median Time Past). - int nLockTimeFlags = 0; + bool enforce_locktime_median_time_past{false}; if (DeploymentActiveAfter(pindexPrev, chainman, Consensus::DEPLOYMENT_CSV)) { assert(pindexPrev != nullptr); - nLockTimeFlags |= LOCKTIME_MEDIAN_TIME_PAST; + enforce_locktime_median_time_past = true; } - int64_t nLockTimeCutoff = (nLockTimeFlags & LOCKTIME_MEDIAN_TIME_PAST) - ? pindexPrev->GetMedianTimePast() - : block.GetBlockTime(); + const int64_t nLockTimeCutoff{enforce_locktime_median_time_past ? + pindexPrev->GetMedianTimePast() : + block.GetBlockTime()}; // Check that all transactions are finalized for (const auto& tx : block.vtx) { |