mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-11 06:28:31 +01:00
Merge bitcoin/bitcoin#23508: Add getdeploymentinfo RPC
a380922891Release notes for getdeploymentinfo rpc (Anthony Towns)240cad09barpc: getdeploymentinfo: include signalling info (Anthony Towns)376c0c6daerpc: getdeploymentinfo: include block hash/height (Anthony Towns)a7469bcd35rpc: getdeploymentinfo: change stats to always refer to current period (Anthony Towns)7f15c1841brpc: getdeploymentinfo: allow specifying a blockhash other than tip (Anthony Towns)fd826130a0rpc: move softfork info from getblockchaininfo to getdeploymentinfo (Anthony Towns) Pull request description: The aim of this PR is to improve the ability to monitor soft fork status. It first moves the softfork section from getblockchaininfo into a new RPC named getdeploymentinfo, which is then also able to query the status of forks at an arbitrary block rather than only at the tip. In addition, bip9 status is changed to indicate the status of the given block, rather than just for the next block, and an additional field is included to indicate whether each block in the signalling period signaled. ACKs for top commit: laanwj: Code review and lightly tested ACKa380922891Sjors: tACKa380922891fjahr: tACKa380922891Tree-SHA512: 7417d733b47629f229c5128586569909250481a3e94356c52fe67a03fd42cd81745246e384b98c4115fb61587714c879e4bc3e5f5c74407d9f8f6773472a33cb
This commit is contained in:
@@ -92,7 +92,7 @@ class BIP65Test(BitcoinTestFramework):
|
||||
self.rpc_timeout = 480
|
||||
|
||||
def test_cltv_info(self, *, is_active):
|
||||
assert_equal(self.nodes[0].getblockchaininfo()['softforks']['bip65'], {
|
||||
assert_equal(self.nodes[0].getdeploymentinfo()['deployments']['bip65'], {
|
||||
"active": is_active,
|
||||
"height": CLTV_HEIGHT,
|
||||
"type": "buried",
|
||||
|
||||
@@ -60,7 +60,7 @@ class BIP66Test(BitcoinTestFramework):
|
||||
return self.miniwallet.create_self_transfer(utxo_to_spend=utxo_to_spend)['tx']
|
||||
|
||||
def test_dersig_info(self, *, is_active):
|
||||
assert_equal(self.nodes[0].getblockchaininfo()['softforks']['bip66'],
|
||||
assert_equal(self.nodes[0].getdeploymentinfo()['deployments']['bip66'],
|
||||
{
|
||||
"active": is_active,
|
||||
"height": DERSIG_HEIGHT,
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
Test the following RPCs:
|
||||
- getblockchaininfo
|
||||
- getdeploymentinfo
|
||||
- getchaintxstats
|
||||
- gettxoutsetinfo
|
||||
- getblockheader
|
||||
@@ -79,6 +80,7 @@ class BlockchainTest(BitcoinTestFramework):
|
||||
self._test_stopatheight()
|
||||
self._test_waitforblockheight()
|
||||
self._test_getblock()
|
||||
self._test_getdeploymentinfo()
|
||||
assert self.nodes[0].verifychain(4, 0)
|
||||
|
||||
def mine_chain(self):
|
||||
@@ -115,7 +117,6 @@ class BlockchainTest(BitcoinTestFramework):
|
||||
'mediantime',
|
||||
'pruned',
|
||||
'size_on_disk',
|
||||
'softforks',
|
||||
'time',
|
||||
'verificationprogress',
|
||||
'warnings',
|
||||
@@ -159,11 +160,6 @@ class BlockchainTest(BitcoinTestFramework):
|
||||
self.start_node(0, extra_args=[
|
||||
'-stopatheight=207',
|
||||
'-prune=550',
|
||||
'-testactivationheight=bip34@2',
|
||||
'-testactivationheight=dersig@3',
|
||||
'-testactivationheight=cltv@4',
|
||||
'-testactivationheight=csv@5',
|
||||
'-testactivationheight=segwit@6',
|
||||
])
|
||||
|
||||
res = self.nodes[0].getblockchaininfo()
|
||||
@@ -177,7 +173,13 @@ class BlockchainTest(BitcoinTestFramework):
|
||||
assert_equal(res['prune_target_size'], 576716800)
|
||||
assert_greater_than(res['size_on_disk'], 0)
|
||||
|
||||
assert_equal(res['softforks'], {
|
||||
def check_signalling_deploymentinfo_result(self, gdi_result, height, blockhash, status_next):
|
||||
assert height >= 144 and height <= 287
|
||||
|
||||
assert_equal(gdi_result, {
|
||||
"hash": blockhash,
|
||||
"height": height,
|
||||
"deployments": {
|
||||
'bip34': {'type': 'buried', 'active': True, 'height': 2},
|
||||
'bip66': {'type': 'buried', 'active': True, 'height': 3},
|
||||
'bip65': {'type': 'buried', 'active': True, 'height': 4},
|
||||
@@ -186,36 +188,65 @@ class BlockchainTest(BitcoinTestFramework):
|
||||
'testdummy': {
|
||||
'type': 'bip9',
|
||||
'bip9': {
|
||||
'status': 'started',
|
||||
'bit': 28,
|
||||
'start_time': 0,
|
||||
'timeout': 0x7fffffffffffffff, # testdummy does not have a timeout so is set to the max int64 value
|
||||
'min_activation_height': 0,
|
||||
'status': 'started',
|
||||
'status-next': status_next,
|
||||
'since': 144,
|
||||
'statistics': {
|
||||
'period': 144,
|
||||
'threshold': 108,
|
||||
'elapsed': HEIGHT - 143,
|
||||
'count': HEIGHT - 143,
|
||||
'elapsed': height - 143,
|
||||
'count': height - 143,
|
||||
'possible': True,
|
||||
},
|
||||
'min_activation_height': 0,
|
||||
'signalling': '#'*(height-143),
|
||||
},
|
||||
'active': False
|
||||
},
|
||||
'taproot': {
|
||||
'type': 'bip9',
|
||||
'bip9': {
|
||||
'status': 'active',
|
||||
'start_time': -1,
|
||||
'timeout': 9223372036854775807,
|
||||
'since': 0,
|
||||
'min_activation_height': 0,
|
||||
'status': 'active',
|
||||
'status-next': 'active',
|
||||
'since': 0,
|
||||
},
|
||||
'height': 0,
|
||||
'active': True
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
def _test_getdeploymentinfo(self):
|
||||
# Note: continues past -stopatheight height, so must be invoked
|
||||
# after _test_stopatheight
|
||||
|
||||
self.log.info("Test getdeploymentinfo")
|
||||
self.stop_node(0)
|
||||
self.start_node(0, extra_args=[
|
||||
'-testactivationheight=bip34@2',
|
||||
'-testactivationheight=dersig@3',
|
||||
'-testactivationheight=cltv@4',
|
||||
'-testactivationheight=csv@5',
|
||||
'-testactivationheight=segwit@6',
|
||||
])
|
||||
|
||||
gbci207 = self.nodes[0].getblockchaininfo()
|
||||
self.check_signalling_deploymentinfo_result(self.nodes[0].getdeploymentinfo(), gbci207["blocks"], gbci207["bestblockhash"], "started")
|
||||
|
||||
# block just prior to lock in
|
||||
self.generate(self.wallet, 287 - gbci207["blocks"])
|
||||
gbci287 = self.nodes[0].getblockchaininfo()
|
||||
self.check_signalling_deploymentinfo_result(self.nodes[0].getdeploymentinfo(), gbci287["blocks"], gbci287["bestblockhash"], "locked_in")
|
||||
|
||||
# calling with an explicit hash works
|
||||
self.check_signalling_deploymentinfo_result(self.nodes[0].getdeploymentinfo(gbci207["bestblockhash"]), gbci207["blocks"], gbci207["bestblockhash"], "started")
|
||||
|
||||
def _test_getchaintxstats(self):
|
||||
self.log.info("Test getchaintxstats")
|
||||
|
||||
|
||||
@@ -270,7 +270,7 @@ class SignRawTransactionsTest(BitcoinTestFramework):
|
||||
getcontext().prec = 8
|
||||
|
||||
# Make sure CSV is active
|
||||
assert self.nodes[0].getblockchaininfo()['softforks']['csv']['active']
|
||||
assert self.nodes[0].getdeploymentinfo()['deployments']['csv']['active']
|
||||
|
||||
# Create a P2WSH script with CSV
|
||||
script = CScript([1, OP_CHECKSEQUENCEVERIFY, OP_DROP])
|
||||
@@ -305,7 +305,7 @@ class SignRawTransactionsTest(BitcoinTestFramework):
|
||||
getcontext().prec = 8
|
||||
|
||||
# Make sure CLTV is active
|
||||
assert self.nodes[0].getblockchaininfo()['softforks']['bip65']['active']
|
||||
assert self.nodes[0].getdeploymentinfo()['deployments']['bip65']['active']
|
||||
|
||||
# Create a P2WSH script with CLTV
|
||||
script = CScript([100, OP_CHECKLOCKTIMEVERIFY, OP_DROP])
|
||||
|
||||
@@ -438,7 +438,7 @@ def delete_cookie_file(datadir, chain):
|
||||
|
||||
def softfork_active(node, key):
|
||||
"""Return whether a softfork is active."""
|
||||
return node.getblockchaininfo()['softforks'][key]['active']
|
||||
return node.getdeploymentinfo()['deployments'][key]['active']
|
||||
|
||||
|
||||
def set_node_times(nodes, t):
|
||||
|
||||
Reference in New Issue
Block a user