When computing MPT roots, the current version of the code works by constructing a database of the full value and then hashing up to the root - this is extremely inefficient due to the many allocations involved as well as the cost of maintaining the full data in memory - instead, it's possible to build an incremental hasher that:
- only stores hashes, not values
- every time a branch is full (ie has 16 children) collapses those into a single hash
Examples of this can be found:
Also related is #698