HomePhabricator

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

Description

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

Summary:
86edf4a2a502416ba8d6cebbce61030992f7ff6f expose CBlockIndex::nTx in getblock(header) (Gregory Sanders)

Pull request description:

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.

Tree-SHA512: af4cf48e704c6088f8da06a477fda1aaa6f8770cee9b876c4465d1075966d6a95831a88817673fe5a0d6bbcdc1ffcbc1892e2be0d838c60fc6958d33eacdcc14

Backport of Core PR13451
https://github.com/bitcoin/bitcoin/pull/13451/

Test Plan:

make check
test_runner.py
test_runner.py feature_pruning

./bitcoind
./bitcoin-cli help getblock
./bitcoin-cli help getblockheader

Verify changes to help text.

Reviewers: deadalnix, Fabien, jasonbcox, O1 Bitcoin ABC, #bitcoin_abc

Reviewed By: deadalnix, jasonbcox, O1 Bitcoin ABC, #bitcoin_abc

Differential Revision: https://reviews.bitcoinabc.org/D4762

Details

Provenance
Wladimir J. van der Laan <laanwj@gmail.com>Authored on Jun 14 2018, 17:38
nakihitoCommitted on Dec 19 2019, 22:53
nakihitoPushed on Dec 19 2019, 22:53
Reviewer
Restricted Owners Package
Differential Revision
D4762: Merge #13451: rpc: expose CBlockIndex::nTx in getblock(header)
Parents
rABCf4ccfea4ad20: [backport] net: Allow connections from misbehavior banned peers
Branches
Unknown
Tags
Unknown