RISC-V: Compute Merkle root hash
Closes RV-116
What
This MR introduces the RootHash trait and implements it for all types that make up the PVM state. It enables computing the root hash of the Merkle tree corresponding to the layout of the state.
Why
We need a way to Merkle-ise the state in order to produce viable commitments.
How
The RootHash trait is implemented in the simplest way for now, by hashing together in one node any data in a compound type and treating all other serialisable values as leaves.
Manually Testing
dune exec ./tezt/tests/main.exe -- riscv
In particular, the "Alpha: riscv - node advances PVM state with messages (external)" and " Alpha: riscv - node advances PVM state with jstz kernel" request a state hash at every level and check that it changes from one level to the next.
Benchmarking
No impact on performance observed on the benchmark machine.
Tasks for the Author
-
Link all Linear issues related to this MR using magic words (e.g. part of, relates to, closes). -
Eliminate dead code and other spurious artefacts introduced in your changes. -
Document new public functions, methods and types. -
Make sure the documentation for updated functions, methods, and types is correct. -
Add tests for bugs that have been fixed. -
Put in reasonable effort to ensure that CI will pass. -
Benchmark performance and populate the table above if needed. -
Write commit messages to reflect the changes they're about. -
Self-review your changes to ensure they are high-quality. -
Complete all of the above before assigning this MR to reviewers.