diff --git a/doc/release-notes-v231-height.md b/doc/release-notes-v231-height.md new file mode 100644 index 000000000..50efd12eb --- /dev/null +++ b/doc/release-notes-v231-height.md @@ -0,0 +1,12 @@ +The v23.1 activation height over RPC +------------------------------------ + +- `getblockchaininfo` lists the v23.1 upgrade under `softforks` as `v231`, in + the form of a buried deployment: `height` is the activation height, and + `active` tells whether the next block is at or above it. The entry is there + only where the height is scheduled: on mainnet and testnet from the release + that sets it, on a devnet started with `-v231activationheight=`, and on a + regtest with `-testactivationheight=v231@`. A node whose + `help getblockchaininfo` describes `v231` and whose reply does not list it + carries no activation height. Earlier builds never list it, scheduled or + not. diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index 545b8dbaf..bcf0b3e76 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -65,6 +65,7 @@ #include #include +#include #include struct CUpdatedBlock @@ -1471,7 +1472,7 @@ RPCHelpMan getblockchaininfo() {RPCResult::Type::STR_HEX, "", "block hash"}, }}, }}, - {RPCResult::Type::OBJ, "softforks", "status of softforks in progress", + {RPCResult::Type::OBJ, "softforks", "status of softforks in progress. The v23.1 upgrade is listed as \"v231\", of type \"buried\", on a network that schedules its height, and is absent where it is unset", { {RPCResult::Type::STR, "type", "one of \"buried\", \"bip9\""}, {RPCResult::Type::OBJ, "bip9", "status of bip9 softforks (only for \"bip9\" type)", @@ -1591,6 +1592,19 @@ RPCHelpMan getblockchaininfo() Consensus::DEPLOYMENT_MN_RR }) { SoftForkDescPushBack(&tip, softforks, consensusParams, deploy); } + // The v23.1 bundle is one height, not a deployment of its own, so it is + // listed by hand in the shape of a buried one, and like one it is absent + // while the network has not scheduled it. That absence is how a build + // without the height is told from the release that carries it: both + // report the same version. + if (const int v231_height{consensusParams.nV231ActivationHeight}; v231_height != std::numeric_limits::max()) { + UniValue rv(UniValue::VOBJ); + rv.pushKV("type", "buried"); + // as for a buried deployment: active once the next block is at the height + rv.pushKV("active", height + 1 >= v231_height); + rv.pushKV("height", v231_height); + softforks.pushKV("v231", rv); + } for (auto ehf_deploy : { /* sorted by activation block */ Consensus::DEPLOYMENT_WITHDRAWALS, Consensus::DEPLOYMENT_TESTDUMMY }) { diff --git a/test/functional/rpc_blockchain.py b/test/functional/rpc_blockchain.py index a7e217409..d5c5f663c 100755 --- a/test/functional/rpc_blockchain.py +++ b/test/functional/rpc_blockchain.py @@ -91,6 +91,7 @@ def run_test(self): self._test_waitforblockheight() self._test_getblock() assert self.nodes[0].verifychain(4, 0) + self._test_v231_softfork() def mine_chain(self): self.log.info(f"Generate {HEIGHT} blocks after the genesis block in 156 sec") @@ -195,6 +196,27 @@ def _test_getblockchaininfo(self): 'active': False}, }) + def _test_v231_softfork(self): + self.log.info("Test that getblockchaininfo lists the v23.1 height only where it is scheduled") + node = self.nodes[0] + # unset, as in _test_getblockchaininfo and in every build before the release + assert 'v231' not in node.getblockchaininfo()['softforks'] + tip = node.getblockcount() + # The height names the retirement of superblocks with it, and cannot be + # scheduled together with mn_rr, which regtest turns on at 900. + for height, active in ((tip + 2, False), (tip + 1, True)): + self.restart_node(0, extra_args=[ + "-txindex=0", + f"-testactivationheight=v231@{height}", + f"-testactivationheight=superblocksretired@{height}", + f"-testactivationheight=mn_rr@{2**31 - 1}", + ]) + assert_equal(node.getblockcount(), tip) + assert_equal(node.getblockchaininfo()['softforks']['v231'], + {'type': 'buried', 'active': active, 'height': height}) + self.restart_node(0, extra_args=["-txindex=0"]) + assert 'v231' not in node.getblockchaininfo()['softforks'] + def _test_getchaintxstats(self): self.log.info("Test getchaintxstats")