rpc: expose CBlockIndex::nTx in getblock(header) #13451

pull instagibbs wants to merge 1 commits into bitcoin:master from instagibbs:expose_nTx changing 3 files +12 −0
  1. instagibbs commented at 8:47 pm on June 12, 2018: member

    Recent publication of a weakness in Bitcoin’s merkle tree construction demonstrates many SPV applications vulnerable to an expensive to pull off yet still plausible attack: https://bitslog.wordpress.com/2018/06/09/leaf-node-weakness-in-bitcoin-merkle-tree-design/

    Including the coinbase in the txoutproof seems the most effective fix, however results in a significant efficiency downgrade. Transactors will not even know a priori what the size of their proof will be within a couple orders of magnitude, unless they use the mid-state of SHA2 as detailed in the blog post.

    Some applications, like Elements blockchain platform that take SPV-style proofs have optional access to a bitcoind to verify these proofs of inclusion and check depth in the chain. Returning CBlockIndex::nTx would allow an extremely easy and compact way of checking the depth of the tree, with no additional overhead to the codebase, and works with pruned nodes.

    getblockheader is arguably not the place for it, but as mentioned before, is a natural workflow for us checking depth of a block in a possibly pruned node.

    We should also ensure that verifytxoutproof ends up validating this depth fact as well, but left this for another PR.

  2. in src/rpc/blockchain.cpp:698 in f9eda3e14e outdated
    694@@ -694,6 +695,7 @@ static UniValue getblockheader(const JSONRPCRequest& request)
    695             "  \"bits\" : \"1d00ffff\", (string) The bits\n"
    696             "  \"difficulty\" : x.xxx,  (numeric) The difficulty\n"
    697             "  \"chainwork\" : \"0000...1f3\"     (string) Expected number of hashes required to produce the current chain (in hex)\n"
    698+            "  \"nTx\" : n,             (numeric) The number of transactions in the block. This result can also be returned for pruned blocks, as it's stored in the block index.\n"
    


    MarcoFalke commented at 10:22 pm on June 12, 2018:

    This result can also be returned for pruned blocks, as it’s stored in the block index

    Should be a comment in the source code instead?

    I believe we have a pruning test, so it would make sense to add an assert_equal(nTx, whatever) there?

  3. MarcoFalke added the label RPC/REST/ZMQ on Jun 12, 2018
  4. MarcoFalke renamed this:
    expose CBlockIndex::nTx in getblockheader
    rpc: expose CBlockIndex::nTx in getblockheader
    on Jun 12, 2018
  5. MarcoFalke commented at 10:27 pm on June 12, 2018: member
    Similar to mediantime, this should also be exposed in getblock
  6. expose CBlockIndex::nTx in getblock(header) 86edf4a2a5
  7. instagibbs force-pushed on Jun 13, 2018
  8. instagibbs commented at 2:21 pm on June 13, 2018: member
    more tests, exposure and rewording as per @MarcoFalke suggestions
  9. instagibbs commented at 2:22 pm on June 13, 2018: member
    If it’s not too much trouble I’d also like this backported for 0.16.2
  10. instagibbs renamed this:
    rpc: expose CBlockIndex::nTx in getblockheader
    rpc: expose CBlockIndex::nTx in getblock(header)
    on Jun 13, 2018
  11. MarcoFalke commented at 2:38 pm on June 13, 2018: member

    utACK 86edf4a2a502416ba8d6cebbce61030992f7ff6f

    Also, tagged for backport, since it is a rather trivial rpc change with tests already included.

  12. MarcoFalke added this to the milestone 0.16.2 on Jun 13, 2018
  13. MarcoFalke added the label Needs backport on Jun 13, 2018
  14. promag commented at 5:34 pm on June 13, 2018: member
    utACK 86edf4a.
  15. jtimon commented at 3:11 pm on June 14, 2018: contributor
    utACK 86edf4a2a502416ba8d6cebbce61030992f7ff6f
  16. laanwj commented at 5:39 pm on June 14, 2018: member
    utACK 86edf4a2a502416ba8d6cebbce61030992f7ff6f
  17. laanwj merged this on Jun 14, 2018
  18. laanwj closed this on Jun 14, 2018

  19. laanwj referenced this in commit cc7cbd756a on Jun 14, 2018
  20. fanquake referenced this in commit cbd2f70b75 on Jun 15, 2018
  21. fanquake commented at 0:03 am on June 26, 2018: member
    Added to #13455 for backport.
  22. fanquake removed the label Needs backport on Jun 26, 2018
  23. laanwj referenced this in commit 7e74c54fed on Jul 9, 2018
  24. laanwj referenced this in commit dac5374cce on Jul 9, 2018
  25. HashUnlimited referenced this in commit 6f9ba098aa on Jan 11, 2019
  26. jasonbcox referenced this in commit b209ed30d6 on Dec 20, 2019
  27. PastaPastaPasta referenced this in commit 046b5b09e4 on Apr 7, 2020
  28. PastaPastaPasta referenced this in commit f7d5e538df on Apr 8, 2020
  29. jonspock referenced this in commit 38ba78b205 on Oct 2, 2020
  30. jonspock referenced this in commit 8aa103bfe2 on Oct 5, 2020
  31. jonspock referenced this in commit 682550b52a on Oct 10, 2020
  32. PastaPastaPasta referenced this in commit 300572e4f1 on Dec 16, 2020
  33. PastaPastaPasta referenced this in commit 46b08dada0 on Dec 18, 2020
  34. PastaPastaPasta referenced this in commit 0da4f596bb on Dec 18, 2020
  35. ckti referenced this in commit 381e268d45 on Mar 28, 2021
  36. MarcoFalke locked this on Sep 8, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-12-18 18:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me