Skip to content

rpc: Backport getblock verbosity#2779

Merged
Fuzzbawls merged 4 commits intoPIVX-Project:masterfrom
tecnovert:pivx_getblock
Nov 20, 2022
Merged

rpc: Backport getblock verbosity#2779
Fuzzbawls merged 4 commits intoPIVX-Project:masterfrom
tecnovert:pivx_getblock

Conversation

@tecnovert
Copy link
Copy Markdown

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

Copy link
Copy Markdown

@PeterL73 PeterL73 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems technically sound, only some esthetic changes and backward compatibilty

Comment thread src/rpc/blockchain.cpp
"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.

Comment thread src/rpc/blockchain.cpp Outdated
{ "blockchain", "getbestblockhash", &getbestblockhash, true, {} },
{ "blockchain", "getbestsaplinganchor", &getbestsaplinganchor, true, {} },
{ "blockchain", "getblock", &getblock, true, {"blockhash","verbose"} },
{ "blockchain", "getblock", &getblock, true, {"blockhash","verbosity"} },
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread test/functional/rpc_named_arguments.py Outdated
Comment on lines +33 to +43
# 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])


Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this functional test necessary? These are the only named arguments being tested

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's necessary to test the different options, although it would perhaps make more sense to move it to rpc_blockchain.py

@tecnovert
Copy link
Copy Markdown
Author

tecnovert commented Nov 2, 2022

Thank you for the detailed review.

I've added the missing help text and added back the 'verbose' named argument for backwards compatibility.

@Fuzzbawls Fuzzbawls added this to the 5.5.0 milestone Nov 3, 2022
Comment thread test/functional/rpc_named_arguments.py Outdated
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])


Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test/functional/rpc_named_arguments.py is now unchanged and could be removed from this PR

Comment thread test/functional/rpc_blockchain.py Outdated
Comment on lines +117 to +121
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])
Copy link
Copy Markdown

@PeterL73 PeterL73 Nov 3, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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'])

Copy link
Copy Markdown

@PeterL73 PeterL73 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't know what went wrong, but this remark didn't get added in my last review

Comment thread src/rpc/client.cpp
{ "getbalance", 1, "include_watchonly" },
{ "getbalance", 2, "include_delegated" },
{ "getbalance", 3, "include_shield" },
{ "getblock", 1, "verbose" },

This comment was marked as resolved.

Comment thread test/functional/rpc_blockchain.py Outdated

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']);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test/functional/rpc_blockchain.py:122:88: E703 statement ends with a semicolon
^---- failure generated from test/lint/lint-python.sh

Copy link
Copy Markdown
Member

@Liquid369 Liquid369 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown

@PeterL73 PeterL73 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tACK b512d94

@Fuzzbawls Fuzzbawls added the Needs Backport Placeholder tag for anything needing a backport to prior version branches label Nov 18, 2022
Copy link
Copy Markdown
Collaborator

@Fuzzbawls Fuzzbawls left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK b512d94

@Fuzzbawls Fuzzbawls merged commit abb888b into PIVX-Project:master Nov 20, 2022
Fuzzbawls pushed a commit to Fuzzbawls/PIVX that referenced this pull request Nov 22, 2022
Fuzzbawls pushed a commit to Fuzzbawls/PIVX that referenced this pull request Nov 22, 2022
Fuzzbawls pushed a commit to Fuzzbawls/PIVX that referenced this pull request Nov 22, 2022
Fuzzbawls pushed a commit to Fuzzbawls/PIVX that referenced this pull request Nov 22, 2022
@Fuzzbawls Fuzzbawls mentioned this pull request Nov 22, 2022
@Fuzzbawls Fuzzbawls added Needs Release Notes Placeholder tag for anything needing mention in the "Notable Changes" section of release notes and removed Needs Backport Placeholder tag for anything needing a backport to prior version branches Needs Release Notes Placeholder tag for anything needing mention in the "Notable Changes" section of release notes labels Dec 11, 2022
Fuzzbawls added a commit that referenced this pull request Dec 12, 2022
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants