The computeRoot function currently calculates the root from the leaves even if if the leaves are already hashed and the result is available in the leafHashes of NamespacedMerkleTree. This can result in redundant hashing and is inconsistent with the purpose of the leafHashes field, which is intended to act as a cache for hashed leaves and save computational time.
Acceptance Criteria
The computeRoot function should be modified to use the leafHashes field if it is non-empty.
Problem
The
computeRoot
function currently calculates the root from the leaves even if if the leaves are already hashed and the result is available in theleafHashes
ofNamespacedMerkleTree
. This can result in redundant hashing and is inconsistent with the purpose of theleafHashes
field, which is intended to act as a cache for hashed leaves and save computational time.Acceptance Criteria
The
computeRoot
function should be modified to use theleafHashes
field if it is non-empty.