ethereum / go-verkle

A go implementation of Verkle trees
The Unlicense
210 stars 64 forks source link

fix: include non-root node collectNonHashedNodes #439

Closed tianyueli8227 closed 3 months ago

tianyueli8227 commented 3 months ago

In the original implementation of collectNonHashedNodes, the function only works when the internal node is root. Since only BatchSerialize calls this function by nodes, paths = n.collectNonHashedNodes(nodes, paths, nil), and BatchSerialize seems to assume only root will call this function. However, if we want to have any internal node to call BatchSerialize without losing generality, we should modify the collectNonHashedNodes and make it returns correct leave path correspondingly.

gballet commented 3 months ago

Thank you for your PR. It is intentional that this function can only be called from the root, and also the change you propose will force more allocations. The point is that we do want to pool all the computation together. Allowing this to be called at lower levels would defeat that purpose. So we won't be merging this.