As of SDK v1, the epoch hash calculation was grounded on the memory space of the machine, which has 8-byte words. For SDK v2, the Merkle trees will be constructed on top of 32-byte words, namely the output hashes. This means that we need to update the on-chain proof verification algorithm to work under these new premises.
Merkle proofs are currently done by the MerkleV2 library from solidity-util, which has several optimizations for working with 8-byte leaves, such as pre-computed pristine hashes. This library, however, is not suitable for our needs.
✔️ Solution
We need to develop a new library for working with Merkle trees with 32-byte leaves.
We should thoroughly test this library with concrete and fuzzy tests.
For Output Unification Part 1, we'll use this library but not MerkleV2.
As for Output Unification Part 2, we'll use this library AND MerkleV2.
It will be necessary then to use MerkleV2 because the epoch hash will be equal to the machine state hash, and we'll have to prove that the output Merkle tree root hash is contained in the memory space of the machine, which contains 8-byte words.
📚 Context
As of SDK v1, the epoch hash calculation was grounded on the memory space of the machine, which has 8-byte words. For SDK v2, the Merkle trees will be constructed on top of 32-byte words, namely the output hashes. This means that we need to update the on-chain proof verification algorithm to work under these new premises.
Merkle proofs are currently done by the
MerkleV2
library fromsolidity-util
, which has several optimizations for working with 8-byte leaves, such as pre-computed pristine hashes. This library, however, is not suitable for our needs.✔️ Solution
We need to develop a new library for working with Merkle trees with 32-byte leaves. We should thoroughly test this library with concrete and fuzzy tests. For Output Unification Part 1, we'll use this library but not
MerkleV2
. As for Output Unification Part 2, we'll use this library ANDMerkleV2
. It will be necessary then to useMerkleV2
because the epoch hash will be equal to the machine state hash, and we'll have to prove that the output Merkle tree root hash is contained in the memory space of the machine, which contains 8-byte words.