Skip to content

Commit

Permalink
Merge bitcoin#21934: RPC/blockchain: getblockchaininfo: Include versi…
Browse files Browse the repository at this point in the history
…onbits signalling details during LOCKED_IN

2b19f34 RPC/blockchain: getblockchaininfo: Include versionbits signalling details during LOCKED_IN (Luke Dashjr)

Pull request description:

  While the signal has no effect during `LOCKED_IN`, the bit is still defined and recommended for measuring uptake. Makes sense to expose statistics too.

ACKs for top commit:
  prayank23:
    ACK bitcoin@2b19f34
  Sjors:
    tACK 2b19f34
  theStack:
    Tested ACK 2b19f34
  MarcoFalke:
    review-only ACK 2b19f34

Tree-SHA512: a9bb5adb21992586119cbb5f87e5348eabcab11d5a3bf769b00b69e466589a669846e503f8384fa8927fd77da0c2d64a54f13a7a55a62980046d70f8255ddf47
  • Loading branch information
MarcoFalke authored and vijaydasmp committed Nov 7, 2023
1 parent 8f7f08c commit dfb4694
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/rpc/blockchain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1607,24 +1607,25 @@ static void BIP9SoftForkDescPushBack(const CBlockIndex* active_chain_tip, UniVal
case ThresholdState::ACTIVE: bip9.pushKV("status", "active"); break;
case ThresholdState::FAILED: bip9.pushKV("status", "failed"); break;
}
if (ThresholdState::STARTED == thresholdState)
{
const bool has_signal = (ThresholdState::STARTED == thresholdState || ThresholdState::LOCKED_IN == thresholdState);
if (has_signal) {
bip9.pushKV("bit", consensusParams.vDeployments[id].bit);
}
bip9.pushKV("start_time", consensusParams.vDeployments[id].nStartTime);
bip9.pushKV("timeout", consensusParams.vDeployments[id].nTimeout);
bip9.pushKV("ehf", consensusParams.vDeployments[id].nMNActivationHeight);
int64_t since_height = VersionBitsStateSinceHeight(active_chain_tip, consensusParams, id, versionbitscache);
bip9.pushKV("since", since_height);
if (ThresholdState::STARTED == thresholdState)
{
if (has_signal) {
UniValue statsUV(UniValue::VOBJ);
BIP9Stats statsStruct = VersionBitsStatistics(active_chain_tip, consensusParams, id, versionbitscache);
statsUV.pushKV("period", statsStruct.period);
statsUV.pushKV("threshold", statsStruct.threshold);
statsUV.pushKV("elapsed", statsStruct.elapsed);
statsUV.pushKV("count", statsStruct.count);
statsUV.pushKV("possible", statsStruct.possible);
if (ThresholdState::LOCKED_IN != thresholdState) {
statsUV.pushKV("threshold", statsStruct.threshold);
statsUV.pushKV("possible", statsStruct.possible);
}
bip9.pushKV("statistics", statsUV);
}
else if (ThresholdState::LOCKED_IN == thresholdState) {
Expand Down Expand Up @@ -1671,7 +1672,7 @@ UniValue getblockchaininfo(const JSONRPCRequest& request)
{RPCResult::Type::OBJ, "bip9", "status of bip9 softforks (only for \"bip9\" type)",
{
{RPCResult::Type::STR, "status", "one of \"defined\", \"started\", \"locked_in\", \"active\", \"failed\""},
{RPCResult::Type::NUM, "bit", "the bit (0-28) in the block version field used to signal this softfork (only for \"started\" status)"},
{RPCResult::Type::NUM, "bit", "the bit (0-28) in the block version field used to signal this softfork (only for \"started\" and \"locked_in\" status)"},
{RPCResult::Type::NUM_TIME, "start_time", "the minimum median time past of a block at which the bit gains its meaning"},
{RPCResult::Type::NUM_TIME, "timeout", "the median time past of a block at which the deployment is considered failed if not yet locked in"},
{RPCResult::Type::NUM, "ehf", "the minimum height when miner's signals for the deployment can be accepted (special values: \"-1\" - any, \"0\" - none)"},
Expand Down

0 comments on commit dfb4694

Please sign in to comment.