Summary
Simplifies merkle tree computation by removing dead code found through coverage analysis (following up on #33768 and #33786).
History
BlockWitnessMerkleRoot
Original MerkleComputation was added in https://github.com/bitcoin/bitcoin/commit/ee60e5625bf8a11c8e5509b9cea8b6465056c448#diff-706988c23877f8a557484053887f932b2cafb3b5998b50497ce7ff8118ac85a3R131 where it was called for either &hash, mutated or position, &ret args.
In https://github.com/bitcoin/bitcoin/commit/1f0e7ca09c9d7c5787c218156fa5096a1bdf2ea8#diff-706988c23877f8a557484053887f932b2cafb3b5998b50497ce7ff8118ac85a3L135-L165 the first usage was inlined in ComputeMerkleRoot, leaving the proot and , pmutated values unused in MerkleComputation.
Later in https://github.com/bitcoin/bitcoin/commit/4defdfab94504018f822dc34a313ad26cedc8255 the method was moved to test and in https://github.com/bitcoin/bitcoin/commit/63d6ad7c89cd682f6e779968c4861ea085058356#diff-706988c23877f8a557484053887f932b2cafb3b5998b50497ce7ff8118ac85a3R87-R95 was restored to the code, though with unused parameters again.
BlockWitnessMerkleRoot
BlockWitnessMerkleRoot was introduced in https://github.com/bitcoin/bitcoin/commit/8b49040854be2e26b66366aeae1cba4716f93d93 where it was already called with NULL https://github.com/bitcoin/bitcoin/commit/8b49040854be2e26b66366aeae1cba4716f93d93#diff-34d21af3c614ea3cee120df276c9c4ae95053830d7f1d3deaf009a4625409ad2R3509 or an unused dummy https://github.com/bitcoin/bitcoin/commit/8b49040854be2e26b66366aeae1cba4716f93d93#diff-34d21af3c614ea3cee120df276c9c4ae95053830d7f1d3deaf009a4625409ad2R3598-R3599 for the mutated parameter.
Fixes
BlockWitnessMerkleRoot
- Converts
pathparameter from pointer to reference (always non-null at call site) - Removes
prootandpmutatedparameters (alwaysnullptrat call site)
BlockWitnessMerkleRoot
- Removes unused
mutatedoutput parameter (always passed asnullptr)
The change is a refactor that shouldn’t introduce any behavioral change, only remove dead code, leftovers from previous refactors.
Coverage proof
https://maflcko.github.io/b-c-cov/total.coverage/src/consensus/merkle.cpp.gcov.html