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] Transaction details in getblock #8704

Merged
merged 2 commits into from May 15, 2017

Conversation

achow101
Copy link
Member

Adds an optional parameter extraVerbose to getblock to have transaction details displayed in a getblock call.

@dcousens
Copy link
Contributor

dcousens commented Sep 12, 2016

concept NACK, is two RPC requests really so bad?

edit: weak concept NACK

@achow101
Copy link
Member Author

@dcousens yes, two RPC calls is really bad, especially when you want the details of all the transactions in a block. Then you end up running getrawtransaction thousands of times. Also, AFAICT, this doesn't require the txindex in order to get the transactions, unlike getrawtransaction.

@dcousens
Copy link
Contributor

dcousens commented Sep 12, 2016

@dcousens yes, two RPC calls is really bad

Why?
If you're following best practices (RPC is over localhost only) in terms of access, the latency should be irrelevant.

In a batched RPC call, the overhead is literally just 1RTT more.
Not N (aka, thousands), 1.

AFAICT, this doesn't require the txindex in order to get the transactions, unlike getrawtransaction.

Perhaps getrawtransaction should have an optional block parameter?

edit: In fact, adding that option would be significantly more useful than this RTT optimisation IMHO.

@achow101
Copy link
Member Author

In a batched RPC call, the overhead is literally just 1RTT more.
Not N (aka, thousands), 1.

How?

edit: In fact, adding that option would be significantly more useful than this RTT optimisation IMHO.

Well the functionality to this was already in the code. The BlockToJson method took a parameter for txDetails which was by default false. This just lets you set that to true.

@dcousens
Copy link
Contributor

http://www.jsonrpc.org/specification#batch

What language are you using? Your RPC library should be able to handle this quite easily.

@achow101
Copy link
Member Author

Huh. Didn't know that. I've been using bash with either curl or bitcoin-cli and python.

@laanwj
Copy link
Member

laanwj commented Sep 13, 2016

Saving roundtrip time is not a valid reason to add a RPC API (see discussion in #8457).

Also, AFAICT, this doesn't require the txindex in order to get the transactions, unlike getrawtransaction.

This is the only important fact here: you cannot get this information any other way. getrawtransaction won't get you transactions in blocks, at least without tx index.

The only way to get this information right now is to getblock raw then parse the block locally.

So concept ACK because of that.

@dcousens
Copy link
Contributor

dcousens commented Sep 13, 2016

@laanwj would it maybe be better to add functionality via getrawtransaction w/ a block id? (perhaps in addition to this)

@laanwj
Copy link
Member

laanwj commented Sep 14, 2016

would it maybe be better to add functionality via getrawtransaction w/ a block id? (perhaps in addition to this)

Well yes a "gather transaction [X,...] from prespecified block Y" RPC call could be useful in some rare cases. But on the other hand it'll still have to read the entire block from disk and deserialize it. It's terribly inefficient already.
So if it decoded the entire block why not report details for the entire block as done here?

@dcousens
Copy link
Contributor

dcousens commented Sep 14, 2016

@laanwj indeed! Forgot about the resulting deserialization.

@luke-jr
Copy link
Member

luke-jr commented Sep 22, 2016

Concept ACK for all the reasons @laanwj already discussed.

throw runtime_error(
"getblock \"hash\" ( verbose )\n"
"getblock \"hash\" ( verbose ) ( extraVerbose )\n"
Copy link
Member

Choose a reason for hiding this comment

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

Double boolean here seems ugly. Maybe allow verbose to be boolean or a number 0-2 (with 2 being extraVerbose)?

Copy link
Member

Choose a reason for hiding this comment

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

It is ugly, but overloading on type in JSON which is essentially dynamically typed is also ugly.

Named parameters as implemented in #8811 would make this more bearable.

Copy link
Member

@laanwj laanwj Oct 18, 2016

Choose a reason for hiding this comment

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

I do agree that for a new interface, a scale for verbosity would have made more sense instead of a boolean.
Maybe that's a better choice I'm just not sure. Changing the meaning of existing arguments is always annoying and means extra testing for backwards compatibility.

@laanwj
Copy link
Member

laanwj commented Oct 26, 2016

I'm starting to realize that @luke-jr's idea to accept 0-2 isn't such a bad idea after all. Just rename the argument 'verbosityLevel'. It is easier to use and understand from a user perspective than two booleans (we regularly get confused there in the tests ourselves). Also it'd remove having to deal with the redundant and nonsensical combo verbose=false extraVerbose=true.

It should still accept false and true too. For consistency we should do the same in getrawtransaction. This method currently accepts a verbose argument that can be 0 or 1 but not false or true. The mapping false:0,true:1 should be added there (not in this pull though).

Also: needs rebase.

@achow101
Copy link
Member Author

How should it document in the help message that the old behavior is still accepted?

@achow101
Copy link
Member Author

Rebased and made verbose an int from 0-2

@luke-jr
Copy link
Member

luke-jr commented Nov 24, 2016

@achow101 The old behaviour should be considered deprecated, and therefore not documented.

"\nArguments:\n"
"1. \"hash\" (string, required) The block hash\n"
"2. verbose (boolean, optional, default=true) true for a json object, false for the hex encoded data\n"
"\nResult (for verbose = true):\n"
"2. verbose (boolean, optional, default=1) 0 for hex encoded data, 1 for a json object, and 2 for json object with transaction data\n"
Copy link
Member

Choose a reason for hiding this comment

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

Should be renamed to verbosity.

@achow101
Copy link
Member Author

@luke-jr done

luke-jr pushed a commit to bitcoinknots/bitcoin that referenced this pull request Dec 21, 2016
Instead of having verbose and extraVerbose, verbose is just changed to an int. This can have values from 0-2 for each level of verbosity.

Github-Pull: bitcoin#8704
Rebased-From: 82a491f446a52953c856e930217f381d3724d20c
@achow101
Copy link
Member Author

merge please?

Copy link
Member

@luke-jr luke-jr left a comment

Choose a reason for hiding this comment

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

utACK

@luke-jr
Copy link
Member

luke-jr commented Feb 3, 2017

(Needs rebase)

@achow101
Copy link
Member Author

achow101 commented Feb 3, 2017

rebased

Verbose is changed to an int. This can have values from 0-2 for each level of verbosity.
Verbosity level 2 has transaction details displayed in the results.
@achow101
Copy link
Member Author

@paveljanik I made the change.

@laanwj
Copy link
Member

laanwj commented May 15, 2017

Tested ACK e3c9f2d

@laanwj laanwj merged commit e3c9f2d into bitcoin:master May 15, 2017
laanwj added a commit that referenced this pull request May 15, 2017
e3c9f2d Use a verbosity instead of two verbose parameters (Andrew Chow)
c99ab3c RPC: Allow multiple names for parameters (Luke Dashjr)

Tree-SHA512: 686b38f6b0106563738d51f55666fe6d49a5b121b30d4480c2bfb640a59ede8e6f7f3c05c3c5d80a5288e127991e191d19d1d4f9ace566fd39edeb27b31857ff
@achow101 achow101 deleted the getblock-extraverbose branch May 17, 2017 16:11
luke-jr pushed a commit to bitcoinknots/bitcoin that referenced this pull request Jun 15, 2017
wirwolf pushed a commit to wirwolf/minexcoin that referenced this pull request Sep 28, 2017
240189b add testcases for getrawtransaction (John Newbery)
ce2bb23 getrawtransaction should take a bool for verbose (jnewbery)

(cherry picked from commit 4d8558a2871ec70b9d09028c49fa39e4911435f5)
RPC: Allow multiple names for parameters
Use a verbosity instead of two verbose parameters

Verbose is changed to an int. This can have values from 0-2 for each level of verbosity.
Verbosity level 2 has transaction details displayed in the results.

(cherry picked from commit e3c9f2ddb1e49f719cc1f3f7cc2a98626bee4364)

bitcoin/bitcoin#8704
zkbot added a commit to zcash/zcash that referenced this pull request May 1, 2018
…ock_v2bitcartel, r=str4d

Add improvements to getblock RPC output

Includes and supercedes #3095. Includes code cherry-picked from bitcoin/bitcoin#8704.
@achow101 achow101 restored the getblock-extraverbose branch August 17, 2018 21:38
@achow101 achow101 deleted the getblock-extraverbose branch August 17, 2018 21:42
thephez added a commit to dash-docs/dash-docs that referenced this pull request Dec 17, 2018
Add missing versionHex field (dashpay/dash@e7d9ffa)
Change to use verbosity syntax (dashpay/dash#2506 and
bitcoin/bitcoin#8704)
thephez added a commit to dash-docs/dash-docs that referenced this pull request Dec 26, 2018
* Content - RPC - Update quick reference

* RPC - Update getblockchaininfo to show BIP-9 progress

Related to dashpay/dash#2435

* RPC - Update gobject prepare with new params

Use-IS (dashpay/dash#2452)
Use specific UTXO for fee (dashpay/dash#2482)

* RPC - Update mode name

* RPC - Update protx default mode

dashpay/dash#2513

* Content - Add spork 17

* Content - Special transactions

Add info for Quorum commitment
Remove messages not in 13.0 (SubTx)

* P2P - Add new txlvote fields

masternodeProTxHash (dashpay/dash#2484)
quorumModifierHash (dashpay/dash#2505)

* RPC - Update protx list

Make all options follow the same parameter format (dashpay/dash#2559)

* Content - version bump

0.13.0.0 bumped to 70213 (dashpay/dash#2557)

* Guide - PrivateSend dstx message limit

Up to 5 simultaneous dstxs per MN allowed (dashpay/dash#2552)

* RPC - Update getblock

Add missing versionHex field (dashpay/dash@e7d9ffa)
Change to use verbosity syntax (dashpay/dash#2506 and
bitcoin/bitcoin#8704)

* P2P - Add qfcommit message (no hexdump example)

DIP6 quorum final commitment (dashpay/dash#2477)

* P2P - qfcommit typo

Change description of llmqType field

* P2P - Special tx payload size clarification

* Guide - Update MN payment description

Related to dashpay/dash#2258

* Guide - fix broken link

* Guide - Update some example txs

Change to hashes on the chain following the 12.3.4 reset

* P2P - Add QcTx hexdump

* P2P - DIP4 message updates

Add SML entry
Update hexdump to include new fields
Add getmnlistd and mnlistdiff to cross ref

* P2P - minor DIP3-related comments
laanwj added a commit that referenced this pull request Jan 19, 2019
979bc0c Improve "help-console" message (Hennadii Stepanov)

Pull request description:

  Added a note that results can be queried in the parenthesized syntax as it does not work in the standard syntax.

  Deprecated (since #8704) boolean `verbose` replaced with numerical `verbosity` in `getblock` examples.

  Current master (acec9e4):
  ![screenshot from 2019-01-16 13-40-10](https://user-images.githubusercontent.com/32963518/51248127-d96bfd80-1997-11e9-83d3-47cf157e2f8d.png)

  Master + this PR:
  ![screenshot from 2019-01-16 14-00-39](https://user-images.githubusercontent.com/32963518/51248137-e852b000-1997-11e9-94dc-e9c949690beb.png)

Tree-SHA512: 663e359ed117306f789fdefcae298194fdd6f5477c87912740e1683323974a333dcca13f17bb2c0aa66639ab7658bd53e535ae8fe671ea5fc557a3db4b192908
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jun 26, 2021
979bc0c Improve "help-console" message (Hennadii Stepanov)

Pull request description:

  Added a note that results can be queried in the parenthesized syntax as it does not work in the standard syntax.

  Deprecated (since bitcoin#8704) boolean `verbose` replaced with numerical `verbosity` in `getblock` examples.

  Current master (acec9e4):
  ![screenshot from 2019-01-16 13-40-10](https://user-images.githubusercontent.com/32963518/51248127-d96bfd80-1997-11e9-83d3-47cf157e2f8d.png)

  Master + this PR:
  ![screenshot from 2019-01-16 14-00-39](https://user-images.githubusercontent.com/32963518/51248137-e852b000-1997-11e9-94dc-e9c949690beb.png)

Tree-SHA512: 663e359ed117306f789fdefcae298194fdd6f5477c87912740e1683323974a333dcca13f17bb2c0aa66639ab7658bd53e535ae8fe671ea5fc557a3db4b192908
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jun 26, 2021
979bc0c Improve "help-console" message (Hennadii Stepanov)

Pull request description:

  Added a note that results can be queried in the parenthesized syntax as it does not work in the standard syntax.

  Deprecated (since bitcoin#8704) boolean `verbose` replaced with numerical `verbosity` in `getblock` examples.

  Current master (acec9e4):
  ![screenshot from 2019-01-16 13-40-10](https://user-images.githubusercontent.com/32963518/51248127-d96bfd80-1997-11e9-83d3-47cf157e2f8d.png)

  Master + this PR:
  ![screenshot from 2019-01-16 14-00-39](https://user-images.githubusercontent.com/32963518/51248137-e852b000-1997-11e9-94dc-e9c949690beb.png)

Tree-SHA512: 663e359ed117306f789fdefcae298194fdd6f5477c87912740e1683323974a333dcca13f17bb2c0aa66639ab7658bd53e535ae8fe671ea5fc557a3db4b192908
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jun 27, 2021
979bc0c Improve "help-console" message (Hennadii Stepanov)

Pull request description:

  Added a note that results can be queried in the parenthesized syntax as it does not work in the standard syntax.

  Deprecated (since bitcoin#8704) boolean `verbose` replaced with numerical `verbosity` in `getblock` examples.

  Current master (acec9e4):
  ![screenshot from 2019-01-16 13-40-10](https://user-images.githubusercontent.com/32963518/51248127-d96bfd80-1997-11e9-83d3-47cf157e2f8d.png)

  Master + this PR:
  ![screenshot from 2019-01-16 14-00-39](https://user-images.githubusercontent.com/32963518/51248137-e852b000-1997-11e9-94dc-e9c949690beb.png)

Tree-SHA512: 663e359ed117306f789fdefcae298194fdd6f5477c87912740e1683323974a333dcca13f17bb2c0aa66639ab7658bd53e535ae8fe671ea5fc557a3db4b192908
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jun 28, 2021
979bc0c Improve "help-console" message (Hennadii Stepanov)

Pull request description:

  Added a note that results can be queried in the parenthesized syntax as it does not work in the standard syntax.

  Deprecated (since bitcoin#8704) boolean `verbose` replaced with numerical `verbosity` in `getblock` examples.

  Current master (acec9e4):
  ![screenshot from 2019-01-16 13-40-10](https://user-images.githubusercontent.com/32963518/51248127-d96bfd80-1997-11e9-83d3-47cf157e2f8d.png)

  Master + this PR:
  ![screenshot from 2019-01-16 14-00-39](https://user-images.githubusercontent.com/32963518/51248137-e852b000-1997-11e9-94dc-e9c949690beb.png)

Tree-SHA512: 663e359ed117306f789fdefcae298194fdd6f5477c87912740e1683323974a333dcca13f17bb2c0aa66639ab7658bd53e535ae8fe671ea5fc557a3db4b192908
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

10 participants