rpc: Backport getblock verbosity#2779
Conversation
PeterL73
left a comment
There was a problem hiding this comment.
Seems technically sound, only some esthetic changes and backward compatibilty
| "2. verbosity (numeric, optional, default=1) 0 for hex encoded data, 1 for a json object, and 2 for json object with transaction data\n" | ||
|
|
||
| "\nResult (for verbose = true):\n" | ||
| "\nResult (for verbosity = 1):\n" |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
| { "blockchain", "getbestblockhash", &getbestblockhash, true, {} }, | ||
| { "blockchain", "getbestsaplinganchor", &getbestsaplinganchor, true, {} }, | ||
| { "blockchain", "getblock", &getblock, true, {"blockhash","verbose"} }, | ||
| { "blockchain", "getblock", &getblock, true, {"blockhash","verbosity"} }, |
There was a problem hiding this comment.
To be backward compatible this should be "verbose|verbosity"
(source: https://github.com/bitcoin/bitcoin/pull/8704/files#diff-decae4be02fb8a47ab4557fe74a9cb853bdfa3ec0fa1b515c0a1e5de91f4ad0bR1437)
But then src/rpc/server.cpp would have to be updated as well to recognise "|" as seperator
Like https://github.com/bitcoin/bitcoin/pull/8704/files#diff-019ee7d5e66b74eac42199f64e08cd0e90af4603bb3c105e294665ea4b411219R437-R446
| # Test getblock verbosity | ||
| block = node.getblock(blockhash=h, verbosity=0) | ||
| assert(isinstance(block, str)) | ||
|
|
||
| block = node.getblock(blockhash=h, verbosity=1) | ||
| assert(isinstance(block['tx'][0], str)) | ||
|
|
||
| block = node.getblock(blockhash=h, verbosity=2) | ||
| assert('vin' in block['tx'][0]) | ||
|
|
||
|
|
There was a problem hiding this comment.
Is this functional test necessary? These are the only named arguments being tested
There was a problem hiding this comment.
I think it's necessary to test the different options, although it would perhaps make more sense to move it to rpc_blockchain.py
|
Thank you for the detailed review. I've added the missing help text and added back the 'verbose' named argument for backwards compatibility. |
| assert_equal(node.echo(arg9=None), [None]*10) | ||
| assert_equal(node.echo(arg0=0,arg3=3,arg9=9), [0] + [None]*2 + [3] + [None]*5 + [9]) | ||
|
|
||
|
|
There was a problem hiding this comment.
test/functional/rpc_named_arguments.py is now unchanged and could be removed from this PR
| assert(isinstance(node.getblock(blockhash=besthash, verbose=False), str)) | ||
| assert(isinstance(node.getblock(blockhash=besthash, verbosity=0), str)) | ||
| assert(isinstance(node.getblock(besthash, 1)['tx'][0], str)) | ||
| assert(isinstance(node.getblock(besthash, True)['tx'][0], str)) | ||
| assert('vin' in node.getblock(besthash, 2)['tx'][0]) |
There was a problem hiding this comment.
Nice!
I think this covers the basics
Would love to see some stricter tests then just checking if a string is returned
Maybe something like:
assert_is_hex_string(node.getblock(besthash, False))
assert_is_hex_string(node.getblock(besthash, 0))
assert_is_hash_string(node.getblock(besthash, True)['tx'][0])
assert_is_hash_string(node.getblock(besthash, 1)['tx'][0])
assert_is_hash_string(node.getblock(besthash, 2)['tx'][0]['txid'])
PeterL73
left a comment
There was a problem hiding this comment.
Don't know what went wrong, but this remark didn't get added in my last review
| { "getbalance", 1, "include_watchonly" }, | ||
| { "getbalance", 2, "include_delegated" }, | ||
| { "getbalance", 3, "include_shield" }, | ||
| { "getblock", 1, "verbose" }, |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
|
|
||
| assert_is_hash_string(node.getblock(besthash, 1)['tx'][0]) | ||
| assert_is_hash_string(node.getblock(besthash, True)['tx'][0]) | ||
| assert_is_hex_string(node.getblock(besthash, 2)['tx'][0]['vin'][0]['coinbase']); |
There was a problem hiding this comment.
test/functional/rpc_blockchain.py:122:88: E703 statement ends with a semicolon
^---- failure generated from test/lint/lint-python.sh
Liquid369
left a comment
There was a problem hiding this comment.
tACK
Upon completion of the last changes, everything looks good now.
I had my own nit of verbose from earlier after compiling but that was all.
Github-Pull: PIVX-Project#2779 Rebased-From: 715f2a2
Github-Pull: PIVX-Project#2779 Rebased-From: f4943e5
Github-Pull: PIVX-Project#2779 Rebased-From: 8488f7e
Github-Pull: PIVX-Project#2779 Rebased-From: b512d94
c0f6055 [Consensus] Bump v5.5 activation height for mainnet (Fuzzbawls) 200b908 [Consensus] Set v5.5 activation height for mainnet (Fuzzbawls) dc31cef Add functional test for scantxoutset (PeterL73) b452fb6 Remove commented out code (PeterL73) 3fc2e6b Backport scantxoutset and descriptors from BitCoin Core v0.17.2 (PeterL73) 8f5f52d Remove semicolon and add "verbose" back to vRPCConvertParams. (tecnovert) ba310d1 Test for hex strings and remove stray newline from rpc_named_arguments. (tecnovert) 2b244ba Fix missing help text and add backwards compatibility. (tecnovert) cce6951 rpc: Backport getblock verbosity (tecnovert) fd719a2 add include_delegated to vRPCConvertParams (PeterL73) d285af0 use block height from caller (PeterL73) Pull request description: Backports the following PRs to the `5.5` branch: #2772 #2774 #2779 #2780 #2781 #2784 Top commit has no ACKs. Tree-SHA512: b0858e8ce7a39a1a3399fb2cf3eb4c4e77ecd526d9c8ca38fab0dc1ca6d108c962a581c8e481d8ac584a35b8a88f58d9d887166a35aec8fdfb66e8d57232dfa8
Changes the boolean 'verbose' parameter of the getblock rpc command to an integer.
Enables getblock output to include full transaction details.
Backported from Bitcoin v15
https://github.com/bitcoin/bitcoin/blob/master/doc/release-notes/release-notes-0.15.0.md