0
0
Fork 0
mirror of https://github.com/bitcoin/bitcoin.git synced 2025-02-09 10:43:19 -05:00

consensus/params: set default values for BIP9Deployment

While chainparams should explicilty set values for each possible
entry in vDeployments, in the past that has been missed resulting
in potential undefined behaviour due to accessing unitinitialized
data. Reduce the severity of future bugs of that nature by providing
benign default values. Adds a unit test to alert if the default value
is not overwritten for the real chains (NEVER_ACTIVE/NEVER_ACTIVE rather
than NEVER_ACTIVE/NO_TIMEOUT).
This commit is contained in:
Anthony Towns 2022-03-11 19:26:49 +10:00
parent 47bac475f0
commit c4c5b9ca6e
2 changed files with 4 additions and 3 deletions

View file

@ -40,11 +40,11 @@ constexpr bool ValidDeployment(DeploymentPos dep) { return dep < MAX_VERSION_BIT
*/
struct BIP9Deployment {
/** Bit position to select the particular bit in nVersion. */
int bit;
int bit{28};
/** Start MedianTime for version bits miner confirmation. Can be a date in the past */
int64_t nStartTime;
int64_t nStartTime{NEVER_ACTIVE};
/** Timeout/expiry MedianTime for the deployment attempt. */
int64_t nTimeout;
int64_t nTimeout{NEVER_ACTIVE};
/** If lock in occurs, delay activation until at least this block
* height. Note that activation will only occur on a retarget
* boundary.

View file

@ -275,6 +275,7 @@ static void check_computeblockversion(const Consensus::Params& params, Consensus
nStartTime == Consensus::BIP9Deployment::NEVER_ACTIVE)
{
BOOST_CHECK_EQUAL(min_activation_height, 0);
BOOST_CHECK_EQUAL(nTimeout, Consensus::BIP9Deployment::NO_TIMEOUT);
return;
}