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: Add level 3 verbosity to getblock RPC call (#21245 modified) #22918

Merged

Conversation

kiminuo
Copy link
Contributor

@kiminuo kiminuo commented Sep 8, 2021

Author of #21245 expressed time issues in the original PR. Given that #21245 has received a lot of review*, I have decided to open this new pull request with modifications required to get ACK from luke-jr and a few nits of mine.

Original PR description

Display the prevout in transaction inputs when calling getblock level 3 verbosity. This PR affects the existing /rest/block API by adding a prevout fields to tx inputs. This is mentioned in the change to the release notes.

I added some functional tests that

* checks that the RPC call still works when TxUndo can't be found

* Doesn't display the "value" or "scriptPubKey" of the previous output when at a lower verbosity level

This "completes" the issue #18771

Possible improvements

Examples

Examples of the getblock output with various verbose levels. Note that 000000000000001f682b188971cc1a121546be4e9d5baf22934fdc7f538288d5 contains only 2 transactions.

(See: #21245 (comment))

Verbose level 0

./bitcoin-cli -testnet getblock 000000000000001f682b188971cc1a121546be4e9d5baf22934fdc7f538288d5 0
Verbose level 1
./bitcoin-cli -testnet getblock 000000000000001f682b188971cc1a121546be4e9d5baf22934fdc7f538288d5 1
Verbose level 2
./bitcoin-cli -testnet getblock 000000000000001f682b188971cc1a121546be4e9d5baf22934fdc7f538288d5 2
Verbose level 3
./bitcoin-cli -testnet getblock 000000000000001f682b188971cc1a121546be4e9d5baf22934fdc7f538288d5 3

REST

curl -H "content-type:text/plain;" http://127.0.0.1:18332/rest/block/000000000000001f682b188971cc1a121546be4e9d5baf22934fdc7f538288d5.json

* ... and my everyday obsessive checking of my email inbox whether the PR moves forward.

Edit laanwj: Removed at symbol from message, and large example output to prevent it from all ending up in the commit message.

@0xB10C
Copy link
Contributor

0xB10C commented Sep 8, 2021

Concept ACK. Thanks for picking this up. Will review now that the requested changes are in.

@DrahtBot
Copy link
Contributor

DrahtBot commented Sep 8, 2021

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #22981 (doc: Fix incorrect C++ named args by MarcoFalke)
  • #22924 (refactor: cleanup/followup of Remove -deprecatedrpc=addresses flag by mjdietzx)
  • #22564 ([WIP] refactor: Move mutable globals cleared in ::UnloadBlockIndex to BlockManager by dongcarl)

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

@laanwj
Copy link
Member

laanwj commented Sep 16, 2021

Concept ACK, this is a useful feature to have, an interesting approach to use the undo data.

@laanwj laanwj added the Feature label Sep 16, 2021
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 305a59a

fyquah and others added 6 commits October 5, 2021 10:42
Co-authored-by: Luke Dashjr <luke_github1@dashjr.org>
Co-authored-by: 0xB10C <19157360+0xB10C@users.noreply.github.com>
Display the prevout in transaction inputs when calling getblock level 3
verbosity.

Co-authored-by: Luke Dashjr <luke_github1@dashjr.org>
Co-authored-by: 0xB10C <19157360+0xB10C@users.noreply.github.com>
@kiminuo kiminuo force-pushed the feature/2021-09-verbose-level-3-for-getblock branch from b0f7af3 to 5c34507 Compare October 5, 2021 08:42
@kiminuo
Copy link
Contributor Author

kiminuo commented Oct 6, 2021

@luke-jr Could you please re-ACK if you feel like it?

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.

re-utACK b0f7af3

Copy link
Contributor

@meshcollider meshcollider left a comment

Choose a reason for hiding this comment

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

utACK 5c34507

I am leaning towards including the helptext for the new verbosity level. Obviously that will make the help output pretty long, but I think it should be documented.

@@ -76,6 +76,14 @@ Updated RPCs
`gettransaction verbose=true` and REST endpoints `/rest/tx`, `/rest/getutxos`,
`/rest/block` no longer return the `addresses` and `reqSigs` fields, which
were previously deprecated in 22.0. (#22650)
- The `getblock` RPC command now supports verbose level 3 containing transaction inputs
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: verbose -> verbosity and inputs -> inputs'

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you. I will fix in a next rebase or in a follow-up PR.

@kiminuo
Copy link
Contributor Author

kiminuo commented Oct 8, 2021

I am leaning towards including the helptext for the new verbosity level. Obviously that will make the help output pretty long, but I think it should be documented.

Do you possibly mean kiminuo@b0bf4f2 mentioned in the OP (under Possible improvements)? Or what do you mean by helptext, please?

@kiminuo
Copy link
Contributor Author

kiminuo commented Oct 8, 2021

re-utACK b0f7af3

@luke-jr Ah, you acked previous version, not the current one.

luke-jr pushed a commit to bitcoinknots/bitcoin that referenced this pull request Oct 10, 2021
Co-authored-by: Luke Dashjr <luke_github1@dashjr.org>
Co-authored-by: 0xB10C <19157360+0xB10C@users.noreply.github.com>

Github-Pull: bitcoin#22918
Rebased-From: 6cd4414
luke-jr pushed a commit to bitcoinknots/bitcoin that referenced this pull request Oct 10, 2021
Display the prevout in transaction inputs when calling getblock level 3
verbosity.

Co-authored-by: Luke Dashjr <luke_github1@dashjr.org>
Co-authored-by: 0xB10C <19157360+0xB10C@users.noreply.github.com>

Github-Pull: bitcoin#22918
Rebased-From: dda6ef1
luke-jr pushed a commit to bitcoinknots/bitcoin that referenced this pull request Oct 10, 2021
luke-jr pushed a commit to bitcoinknots/bitcoin that referenced this pull request Oct 10, 2021
@kiminuo
Copy link
Contributor Author

kiminuo commented Oct 11, 2021

@theStack Would you please re-ACK if you feel like it?

@0xB10C
Copy link
Contributor

0xB10C commented Oct 11, 2021

ACK 5c34507

p.pushKV("scriptPubKey", o_script_pub_key);
in.pushKV("prevout", p);
break;
}
Copy link
Contributor

@jonatack jonatack Oct 11, 2021

Choose a reason for hiding this comment

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

Per doc/developer-notes.md::L672-694,the following comment and assert are usually employed with self-contained switch statements so the compiler can warn about missing cases. It looks like that could work here as the switch is scoped within the have_undo conditional:

    } // no default case, so the compiler can warn about missing cases
    assert(false);
}

(usually, the case statements have the same indentation as switch, without blank lines between them)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you. I would like to address that a next rebase or in a follow-up PR.

Copy link
Contributor

@theStack theStack left a comment

Choose a reason for hiding this comment

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

ACK 5c34507 👘

Verified via git range-diff 72dbe981...5c34507e that since my last ACK (review done in PR #21245, see #21245 (review)) all changes are rebase-related or minor improvements (related to comments, variable renames etc.).

Copy link
Member

@promag promag left a comment

Choose a reason for hiding this comment

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

Concept ACK 5c34507

UniValue objTx(UniValue::VOBJ);
TxToUniv(*tx, uint256(), objTx, true, RPCSerializationFlags(), txundo);
txs.push_back(objTx);
}
Copy link
Member

Choose a reason for hiding this comment

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

3cc9534

nit, add break;?

amt_total_in += prev_txout.nValue;
switch (verbosity) {
Copy link
Member

Choose a reason for hiding this comment

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

51dbc16

nit, we only care about one value, what's wrong with

if (verbosity == TxVerbosity::SHOW_DETAILS_AND_PREVOUT) {

If you do this, then declare prev_coin in the inner scope.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you. I would like to address that a next rebase or in a follow-up PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have actually proposed the same in the original PR: #21245 (comment)

@kiminuo
Copy link
Contributor Author

kiminuo commented Oct 13, 2021

@MarcoFalke Should I address the review comments now (and thus invalidate ACKs) or can I do it in a follow-up PR? I mean can the PR be merged?

@laanwj laanwj merged commit 986003a into bitcoin:master Oct 19, 2021
@laanwj
Copy link
Member

laanwj commented Oct 19, 2021

Merged this as there were no critical comments, many ACKs, and to not drag this on forever. I do think in general it's better to just incorporate comments and not move small nits 'to follow-up PRs' because of fear of invalidating ACKs.

sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Oct 19, 2021
@fanquake
Copy link
Member

I do think in general it's better to just incorporate comments and not move small nits 'to follow-up PRs' because of fear of invalidating ACKs.

I agree. The point of PR review (among other things) is to get code to a mergable state. There are trade-offs depending on the size/complexity of a change, and whether or not everything must be addressed, but I think we have started to drift too far to the wrong side of pushing changes to followups / not actually taking review suggestions onboard for fear of invalidating ACKs (not saying that is the case here).

@kiminuo kiminuo deleted the feature/2021-09-verbose-level-3-for-getblock branch October 20, 2021 05:46
kiminuo added a commit to kiminuo/bitcoin that referenced this pull request Oct 20, 2021
* fix English in release notes
* Simplify `switch` to `if`.
kiminuo added a commit to kiminuo/bitcoin that referenced this pull request Oct 20, 2021
* fix English in release notes
* Simplify `switch` to `if`.
@mjdietzx
Copy link
Contributor

Post merge ACK 5c34507

Did some review and light testing while rebasing #22924

I'll be joining in on review of #23320 bc I also had some nits

laanwj added a commit that referenced this pull request Jan 4, 2022
059f88b Add RPC help for getblock verbosity level 3 (Kiminuo)
1bdd5f6 Address review comments from #22918 (Kiminuo)

Pull request description:

  This is a follow-up PR to #22918 which addresses review comments (first commit). The second commit adds missing RPC help for verbosity level 3.

ACKs for top commit:
  pg156:
    ACK 059f88b
  laanwj:
    re-ACK 059f88b

Tree-SHA512: f27d53ac34b93a304ef5668701ed2b5c986a926bc8ad0df4de89695fc9e1df26acb008611451319ea897658acd9c56c6a0555d60359960c9cd28238ebefa2d50
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Jan 4, 2022
059f88b Add RPC help for getblock verbosity level 3 (Kiminuo)
1bdd5f6 Address review comments from bitcoin#22918 (Kiminuo)

Pull request description:

  This is a follow-up PR to bitcoin#22918 which addresses review comments (first commit). The second commit adds missing RPC help for verbosity level 3.

ACKs for top commit:
  pg156:
    ACK bitcoin@059f88b
  laanwj:
    re-ACK 059f88b

Tree-SHA512: f27d53ac34b93a304ef5668701ed2b5c986a926bc8ad0df4de89695fc9e1df26acb008611451319ea897658acd9c56c6a0555d60359960c9cd28238ebefa2d50
mzumsande pushed a commit to mzumsande/bitcoin that referenced this pull request Jan 17, 2022
* fix English in release notes
* Simplify `switch` to `if`.
rebroad pushed a commit to rebroad/bitcoin that referenced this pull request Feb 3, 2022
* fix English in release notes
* Simplify `switch` to `if`.
@bitcoin bitcoin locked and limited conversation to collaborators Oct 30, 2022
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