@@ -1418,54 +1418,49 @@ static UniValue verifychain(const JSONRPCRequest& request)
14181418 ::ChainstateActive (), Params(), ::ChainstateActive().CoinsTip(), *node_context.evodb, check_level, check_depth);
14191419}
14201420
1421- /* * Implementation of IsSuperMajority with better feedback */
1422- static UniValue SoftForkMajorityDesc (int version, const CBlockIndex* pindex, const Consensus::Params& consensusParams)
1421+ static void BuriedForkDescPushBack (UniValue& softforks, const std::string &name, int height) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
14231422{
1424- UniValue rv (UniValue::VOBJ);
1425- bool activated = false ;
1426- switch (version)
1427- {
1428- case 2 :
1429- activated = pindex->nHeight >= consensusParams.BIP34Height ;
1430- break ;
1431- case 3 :
1432- activated = pindex->nHeight >= consensusParams.BIP66Height ;
1433- break ;
1434- case 4 :
1435- activated = pindex->nHeight >= consensusParams.BIP65Height ;
1436- break ;
1437- }
1438- rv.pushKV (" status" , activated);
1439- return rv;
1440- }
1423+ // For buried deployments.
1424+ // A buried deployment is one where the height of the activation has been hardcoded into
1425+ // the client implementation long after the consensus change has activated. See BIP 90.
1426+ // Buried deployments with activation height value of
1427+ // std::numeric_limits<int>::max() are disabled and thus hidden.
1428+ if (height == std::numeric_limits<int >::max ()) return ;
14411429
1442- static UniValue SoftForkDesc (const std::string &name, int version, const CBlockIndex* pindex, const Consensus::Params& consensusParams)
1443- {
14441430 UniValue rv (UniValue::VOBJ);
1445- rv.pushKV (" id" , name);
1446- rv.pushKV (" version" , version);
1447- rv.pushKV (" reject" , SoftForkMajorityDesc (version, pindex, consensusParams));
1448- return rv;
1431+ rv.pushKV (" type" , " buried" );
1432+ // getblockchaininfo reports the softfork as active from when the chain height is
1433+ // one below the activation height
1434+ rv.pushKV (" active" , ::ChainActive ().Tip ()->nHeight + 1 >= height);
1435+ rv.pushKV (" height" , height);
1436+ softforks.pushKV (name, rv);
14491437}
14501438
1451- static UniValue BIP9SoftForkDesc ( const Consensus::Params& consensusParams, Consensus::DeploymentPos id)
1439+ static void BIP9SoftForkDescPushBack (UniValue& softforks, const std::string &name, const Consensus::Params& consensusParams, Consensus::DeploymentPos id) EXCLUSIVE_LOCKS_REQUIRED(cs_main )
14521440{
1453- UniValue rv (UniValue::VOBJ);
1441+ // For BIP9 deployments.
1442+ // Deployments (e.g. testdummy) with timeout value before Jan 1, 2009 are hidden.
1443+ // A timeout value of 0 guarantees a softfork will never be activated.
1444+ // This is used when merging logic to implement a proposed softfork without a specified deployment schedule.
1445+ if (consensusParams.vDeployments [id].nTimeout <= 1230768000 ) return ;
1446+
1447+ UniValue bip9 (UniValue::VOBJ);
14541448 const ThresholdState thresholdState = VersionBitsState (::ChainActive ().Tip (), consensusParams, id, versionbitscache);
14551449 switch (thresholdState) {
1456- case ThresholdState::DEFINED: rv .pushKV (" status" , " defined" ); break ;
1457- case ThresholdState::STARTED: rv .pushKV (" status" , " started" ); break ;
1458- case ThresholdState::LOCKED_IN: rv .pushKV (" status" , " locked_in" ); break ;
1459- case ThresholdState::ACTIVE: rv .pushKV (" status" , " active" ); break ;
1460- case ThresholdState::FAILED: rv .pushKV (" status" , " failed" ); break ;
1450+ case ThresholdState::DEFINED: bip9 .pushKV (" status" , " defined" ); break ;
1451+ case ThresholdState::STARTED: bip9 .pushKV (" status" , " started" ); break ;
1452+ case ThresholdState::LOCKED_IN: bip9 .pushKV (" status" , " locked_in" ); break ;
1453+ case ThresholdState::ACTIVE: bip9 .pushKV (" status" , " active" ); break ;
1454+ case ThresholdState::FAILED: bip9 .pushKV (" status" , " failed" ); break ;
14611455 }
14621456 if (ThresholdState::STARTED == thresholdState)
14631457 {
1464- rv .pushKV (" bit" , consensusParams.vDeployments [id].bit );
1458+ bip9 .pushKV (" bit" , consensusParams.vDeployments [id].bit );
14651459 }
1466- rv.pushKV (" start_time" , consensusParams.vDeployments [id].nStartTime );
1467- rv.pushKV (" timeout" , consensusParams.vDeployments [id].nTimeout );
1468- rv.pushKV (" since" , VersionBitsStateSinceHeight (::ChainActive ().Tip (), consensusParams, id, versionbitscache));
1460+ bip9.pushKV (" start_time" , consensusParams.vDeployments [id].nStartTime );
1461+ bip9.pushKV (" timeout" , consensusParams.vDeployments [id].nTimeout );
1462+ int64_t since_height = VersionBitsStateSinceHeight (::ChainActive ().Tip (), consensusParams, id, versionbitscache);
1463+ bip9.pushKV (" since" , since_height);
14691464 if (ThresholdState::STARTED == thresholdState)
14701465 {
14711466 UniValue statsUV (UniValue::VOBJ);
@@ -1475,18 +1470,18 @@ static UniValue BIP9SoftForkDesc(const Consensus::Params& consensusParams, Conse
14751470 statsUV.pushKV (" elapsed" , statsStruct.elapsed );
14761471 statsUV.pushKV (" count" , statsStruct.count );
14771472 statsUV.pushKV (" possible" , statsStruct.possible );
1478- rv .pushKV (" statistics" , statsUV);
1473+ bip9 .pushKV (" statistics" , statsUV);
14791474 }
1480- return rv;
1481- }
14821475
1483- static void BIP9SoftForkDescPushBack (UniValue& bip9_softforks, const Consensus::Params& consensusParams, Consensus::DeploymentPos id)
1484- {
1485- // Deployments with timeout value of 0 are hidden.
1486- // A timeout value of 0 guarantees a softfork will never be activated.
1487- // This is used when softfork codes are merged without specifying the deployment schedule.
1488- if (consensusParams.vDeployments [id].nTimeout > 0 )
1489- bip9_softforks.pushKV (VersionBitsDeploymentInfo[id].name , BIP9SoftForkDesc (consensusParams, id));
1476+ UniValue rv (UniValue::VOBJ);
1477+ rv.pushKV (" type" , " bip9" );
1478+ rv.pushKV (" bip9" , bip9);
1479+ if (ThresholdState::ACTIVE == thresholdState) {
1480+ rv.pushKV (" height" , since_height);
1481+ }
1482+ rv.pushKV (" active" , ThresholdState::ACTIVE == thresholdState);
1483+
1484+ softforks.pushKV (name, rv);
14901485}
14911486
14921487UniValue getblockchaininfo (const JSONRPCRequest& request)
@@ -1512,28 +1507,17 @@ UniValue getblockchaininfo(const JSONRPCRequest& request)
15121507 {RPCResult::Type::NUM, " pruneheight" , " lowest-height complete block stored (only present if pruning is enabled)" },
15131508 {RPCResult::Type::BOOL, " automatic_pruning" , " whether automatic pruning is enabled (only present if pruning is enabled)" },
15141509 {RPCResult::Type::NUM, " prune_target_size" , " the target size used by pruning (only present if automatic pruning is enabled)" },
1515- {RPCResult::Type::ARR, " softforks" , " status of softforks in progress" ,
1516- {
1517- {RPCResult::Type::OBJ, " " , " " ,
1518- {
1519- {RPCResult::Type::STR, " xxxx" , " name of the softfork" },
1520- {RPCResult::Type::STR, " version" , " block version" },
1521- {RPCResult::Type::OBJ, " reject" , " progress toward rejecting pre-softfork blocks" ,
1522- {
1523- {RPCResult::Type::BOOL, " status" , " true if threshold reached" },
1524- }},
1525- }},
1526- }},
1527- {RPCResult::Type::OBJ_DYN, " bip9_softforks" , " status of BIP9 softforks in progress" ,
1510+ {RPCResult::Type::OBJ, " softforks" , " status of softforks in progress" ,
15281511 {
1529- {RPCResult::Type::OBJ, " xxxx" , " name of the softfork" ,
1512+ {RPCResult::Type::STR, " type" , " one of \" buried\" , \" bip9\" " },
1513+ {RPCResult::Type::OBJ, " bip9" , " status of bip9 softforks (only for \" bip9\" type)" ,
15301514 {
15311515 {RPCResult::Type::STR, " status" , " one of \" defined\" , \" started\" , \" locked_in\" , \" active\" , \" failed\" " },
15321516 {RPCResult::Type::NUM, " bit" , " the bit (0-28) in the block version field used to signal this softfork (only for \" started\" status)" },
15331517 {RPCResult::Type::NUM_TIME, " start_time" , " the minimum median time past of a block at which the bit gains its meaning" },
15341518 {RPCResult::Type::NUM_TIME, " timeout" , " the median time past of a block at which the deployment is considered failed if not yet locked in" },
15351519 {RPCResult::Type::NUM, " since" , " height of the first block to which the status applies" },
1536- {RPCResult::Type::OBJ, " statistics" , " numeric statistics about BIP9 signalling for a softfork (only for \" started \" status) " ,
1520+ {RPCResult::Type::OBJ, " statistics" , " numeric statistics about BIP9 signalling for a softfork" ,
15371521 {
15381522 {RPCResult::Type::NUM, " period" , " the length in blocks of the BIP9 signalling period" },
15391523 {RPCResult::Type::NUM, " threshold" , " the number of blocks with the version bit set required to activate the feature" },
@@ -1542,6 +1526,8 @@ UniValue getblockchaininfo(const JSONRPCRequest& request)
15421526 {RPCResult::Type::BOOL, " possible" , " returns false if there are not enough blocks left in this period to pass activation threshold" },
15431527 }},
15441528 }},
1529+ {RPCResult::Type::NUM, " height" , " height of the first block which the rules are or will be enforced (only for \" buried\" type, or \" bip9\" type with \" active\" status)" },
1530+ {RPCResult::Type::BOOL, " active" , " true if the rules are enforced for the mempool and the next block" },
15451531 }},
15461532 {RPCResult::Type::STR, " warnings" , " any network and blockchain warnings" },
15471533 }},
@@ -1586,17 +1572,17 @@ UniValue getblockchaininfo(const JSONRPCRequest& request)
15861572 }
15871573
15881574 const Consensus::Params& consensusParams = Params ().GetConsensus ();
1589- UniValue softforks (UniValue::VARR);
1590- UniValue bip9_softforks (UniValue::VOBJ);
1575+ UniValue softforks (UniValue::VOBJ);
15911576 // sorted by activation block
1592- softforks.push_back (SoftForkDesc (" bip34" , 2 , tip, consensusParams));
1593- softforks.push_back (SoftForkDesc (" bip66" , 3 , tip, consensusParams));
1594- softforks.push_back (SoftForkDesc (" bip65" , 4 , tip, consensusParams));
1595- for (int pos = Consensus::DEPLOYMENT_CSV; pos != Consensus::MAX_VERSION_BITS_DEPLOYMENTS; ++pos) {
1596- BIP9SoftForkDescPushBack (bip9_softforks, consensusParams, static_cast <Consensus::DeploymentPos>(pos));
1597- }
1577+ BuriedForkDescPushBack (softforks," bip34" , consensusParams.BIP34Height );
1578+ BuriedForkDescPushBack (softforks," bip66" , consensusParams.BIP66Height );
1579+ BuriedForkDescPushBack (softforks," bip65" , consensusParams.BIP65Height );
1580+ BuriedForkDescPushBack (softforks, " csv" , consensusParams.CSVHeight );
1581+ for (int pos = Consensus::DEPLOYMENT_TESTDUMMY + 1 ; pos != Consensus::MAX_VERSION_BITS_DEPLOYMENTS; ++pos) {
1582+ BIP9SoftForkDescPushBack (softforks, VersionBitsDeploymentInfo[pos].name , consensusParams, static_cast <Consensus::DeploymentPos>(pos));
1583+ }
1584+ BIP9SoftForkDescPushBack (softforks, " testdummy" , consensusParams, Consensus::DEPLOYMENT_TESTDUMMY);
15981585 obj.pushKV (" softforks" , softforks);
1599- obj.pushKV (" bip9_softforks" , bip9_softforks);
16001586
16011587 obj.pushKV (" warnings" , GetWarnings (false ));
16021588 return obj;
0 commit comments