mirror of
https://github.com/dashpay/dash.git
synced 2024-12-24 19:42:46 +01:00
Merge #12317: Document method for reviewers to verify chainTxData
7444149
Document method for reviewers to verify chainTxData (John Newbery)
Pull request description:
This commit adds the final block hash of the window to getchaintxstats
and documents how reviewers can verify changes to chainTxData.
Tree-SHA512: d16abb5f47d058e52660f4d495f1e453205b1b83716d7c810ff62a70338db721386c1808ec1fc8468f514e4d80cc58e3c96eeb3184cbbcb1d07830fa5e53f342
This commit is contained in:
parent
8ff171262a
commit
3af9ef9194
@ -22,7 +22,7 @@ Before every major release:
|
||||
* Update hardcoded [seeds](/contrib/seeds/README.md). TODO: Give example PR for Dash
|
||||
* Update [`BLOCK_CHAIN_SIZE`](/src/qt/intro.cpp) to the current size plus some overhead.
|
||||
* Update `src/chainparams.cpp` chainTxData with statistics about the transaction count and rate. Use the output of the RPC `getchaintxstats`, see
|
||||
[this pull request](https://github.com/bitcoin/bitcoin/pull/12270) for an example.
|
||||
[this pull request](https://github.com/bitcoin/bitcoin/pull/12270) for an example. Reviewers can verify the results by running `getchaintxstats <window_block_count> <window_last_block_hash>` with the `window_block_count` and `window_last_block_hash` from your output.
|
||||
* Update version of `contrib/gitian-descriptors/*.yml`: usually one'd want to do this on master after branching off the release - but be sure to at least do it before a new major release
|
||||
|
||||
### First time / New builders
|
||||
|
@ -1815,12 +1815,13 @@ UniValue getchaintxstats(const JSONRPCRequest& request)
|
||||
"2. \"blockhash\" (string, optional) The hash of the block that ends the window.\n"
|
||||
"\nResult:\n"
|
||||
"{\n"
|
||||
" \"time\": xxxxx, (numeric) The timestamp for the final block in the window in UNIX format.\n"
|
||||
" \"txcount\": xxxxx, (numeric) The total number of transactions in the chain up to that point.\n"
|
||||
" \"window_block_count\": xxxxx, (numeric) Size of the window in number of blocks.\n"
|
||||
" \"window_tx_count\": xxxxx, (numeric) The number of transactions in the window. Only returned if \"window_block_count\" is > 0.\n"
|
||||
" \"window_interval\": xxxxx, (numeric) The elapsed time in the window in seconds. Only returned if \"window_block_count\" is > 0.\n"
|
||||
" \"txrate\": x.xx, (numeric) The average rate of transactions per second in the window. Only returned if \"window_interval\" is > 0.\n"
|
||||
" \"time\": xxxxx, (numeric) The timestamp for the final block in the window in UNIX format.\n"
|
||||
" \"txcount\": xxxxx, (numeric) The total number of transactions in the chain up to that point.\n"
|
||||
" \"window_final_block_hash\": \"...\", (string) The hash of the final block in the window.\n"
|
||||
" \"window_block_count\": xxxxx, (numeric) Size of the window in number of blocks.\n"
|
||||
" \"window_tx_count\": xxxxx, (numeric) The number of transactions in the window. Only returned if \"window_block_count\" is > 0.\n"
|
||||
" \"window_interval\": xxxxx, (numeric) The elapsed time in the window in seconds. Only returned if \"window_block_count\" is > 0.\n"
|
||||
" \"txrate\": x.xx, (numeric) The average rate of transactions per second in the window. Only returned if \"window_interval\" is > 0.\n"
|
||||
"}\n"
|
||||
"\nExamples:\n"
|
||||
+ HelpExampleCli("getchaintxstats", "")
|
||||
@ -1871,6 +1872,7 @@ UniValue getchaintxstats(const JSONRPCRequest& request)
|
||||
UniValue ret(UniValue::VOBJ);
|
||||
ret.push_back(Pair("time", (int64_t)pindex->nTime));
|
||||
ret.push_back(Pair("txcount", (int64_t)pindex->nChainTx));
|
||||
ret.push_back(Pair("window_final_block_hash", pindex->GetBlockHash().GetHex()));
|
||||
ret.push_back(Pair("window_block_count", blockcount));
|
||||
if (blockcount > 0) {
|
||||
ret.push_back(Pair("window_tx_count", nTxDiff));
|
||||
|
@ -108,6 +108,8 @@ class BlockchainTest(BitcoinTestFramework):
|
||||
assert_greater_than(res['size_on_disk'], 0)
|
||||
|
||||
def _test_getchaintxstats(self):
|
||||
self.log.info("Test getchaintxstats")
|
||||
|
||||
chaintxstats = self.nodes[0].getchaintxstats(1)
|
||||
# 200 txs plus genesis tx
|
||||
assert_equal(chaintxstats['txcount'], 201)
|
||||
@ -115,21 +117,25 @@ class BlockchainTest(BitcoinTestFramework):
|
||||
# we have to round because of binary math
|
||||
assert_equal(round(chaintxstats['txrate'] * 156, 10), Decimal(1))
|
||||
|
||||
b1 = self.nodes[0].getblock(self.nodes[0].getblockhash(1))
|
||||
b200 = self.nodes[0].getblock(self.nodes[0].getblockhash(200))
|
||||
b1_hash = self.nodes[0].getblockhash(1)
|
||||
b1 = self.nodes[0].getblock(b1_hash)
|
||||
b200_hash = self.nodes[0].getblockhash(200)
|
||||
b200 = self.nodes[0].getblock(b200_hash)
|
||||
time_diff = b200['mediantime'] - b1['mediantime']
|
||||
|
||||
chaintxstats = self.nodes[0].getchaintxstats()
|
||||
assert_equal(chaintxstats['time'], b200['time'])
|
||||
assert_equal(chaintxstats['txcount'], 201)
|
||||
assert_equal(chaintxstats['window_final_block_hash'], b200_hash)
|
||||
assert_equal(chaintxstats['window_block_count'], 199)
|
||||
assert_equal(chaintxstats['window_tx_count'], 199)
|
||||
assert_equal(chaintxstats['window_interval'], time_diff)
|
||||
assert_equal(round(chaintxstats['txrate'] * time_diff, 10), Decimal(199))
|
||||
|
||||
chaintxstats = self.nodes[0].getchaintxstats(blockhash=b1['hash'])
|
||||
chaintxstats = self.nodes[0].getchaintxstats(blockhash=b1_hash)
|
||||
assert_equal(chaintxstats['time'], b1['time'])
|
||||
assert_equal(chaintxstats['txcount'], 2)
|
||||
assert_equal(chaintxstats['window_final_block_hash'], b1_hash)
|
||||
assert_equal(chaintxstats['window_block_count'], 0)
|
||||
assert('window_tx_count' not in chaintxstats)
|
||||
assert('window_interval' not in chaintxstats)
|
||||
@ -180,8 +186,7 @@ class BlockchainTest(BitcoinTestFramework):
|
||||
def _test_getblockheader(self):
|
||||
node = self.nodes[0]
|
||||
|
||||
assert_raises_rpc_error(-5, "Block not found",
|
||||
node.getblockheader, "nonsense")
|
||||
assert_raises_rpc_error(-5, "Block not found", node.getblockheader, "nonsense")
|
||||
|
||||
besthash = node.getbestblockhash()
|
||||
secondbesthash = node.getblockhash(199)
|
||||
|
Loading…
Reference in New Issue
Block a user