Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rpc: Backport getblock verbosity #2779

Merged
merged 4 commits into from
Nov 20, 2022

Conversation

tecnovert
Copy link

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

@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


"\nResult (for verbose = true):\n"
"\nResult (for verbosity = 1):\n"

This comment was marked as resolved.

@@ -1449,7 +1454,7 @@ static const CRPCCommand commands[] =
// --------------------- ------------------------ ----------------------- ------ --------
{ "blockchain", "getbestblockhash", &getbestblockhash, true, {} },
{ "blockchain", "getbestsaplinganchor", &getbestsaplinganchor, true, {} },
{ "blockchain", "getblock", &getblock, true, {"blockhash","verbose"} },
{ "blockchain", "getblock", &getblock, true, {"blockhash","verbosity"} },
Copy link

Choose a reason for hiding this comment

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

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

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
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
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
@@ -30,5 +30,6 @@ def run_test(self):
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

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 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

@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

@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

@@ -53,7 +53,7 @@ static const CRPCConvertParam vRPCConvertParams[] = {
{ "getbalance", 1, "include_watchonly" },
{ "getbalance", 2, "include_delegated" },
{ "getbalance", 3, "include_shield" },
{ "getblock", 1, "verbose" },

This comment was marked as resolved.


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

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
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

@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
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