Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions doc/release-notes-v231-height.md
Original file line number Diff line number Diff line change
@@ -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=<n>`, and on a
regtest with `-testactivationheight=v231@<n>`. 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.
16 changes: 15 additions & 1 deletion src/rpc/blockchain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@

#include <atomic>
#include <condition_variable>
#include <limits>
#include <mutex>

struct CUpdatedBlock
Expand Down Expand Up @@ -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)",
Expand Down Expand Up @@ -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<int>::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 }) {
Expand Down
22 changes: 22 additions & 0 deletions test/functional/rpc_blockchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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")

Expand Down
Loading