Skip to content

Commit

Permalink
Merge bitcoin#24032: Add defaults to vDeployments to avoid uninitiali…
Browse files Browse the repository at this point in the history
…zed variables

c4c5b9c consensus/params: set default values for BIP9Deployment (Anthony Towns)

Pull request description:

  Adds default values for `vDeployments` in `consensus/params.h` so that undefined behaviour is avoided if a deployment is not initialized. Also adds a check in the unit tests to alert if this is happening, since even if it doesn't invoke undefined behaviour it's probably a mistake.

ACKs for top commit:
  laanwj:
    Code review ACK c4c5b9c

Tree-SHA512: 22d7ff86a817d9e9e67c47301fc3b7e9d5821c13565d7706711f113dea220eea29b413a7c8d029691009159cebc85a108d77cb52418734091c196bafb2b12423
  • Loading branch information
laanwj authored and PastaPastaPasta committed Jul 24, 2024
1 parent 1d991ae commit 2afbf25
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/consensus/params.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ constexpr bool ValidDeployment(DeploymentPos dep) { return DEPLOYMENT_TESTDUMMY
*/
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.
Expand Down
1 change: 1 addition & 0 deletions src/test/versionbits_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,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;
}

Expand Down

0 comments on commit 2afbf25

Please sign in to comment.