RISC-V: Use generic tree structure for MerkleProof
Part of RV-233
What
Introduce a Tree<A> enum type and change MerkleProof = Tree<MerkleProofLeaf>.
Why
Distinguishing between intermediary nodes and leaves at the type level in a payload-agnostic makes writing the deserialisation more straight forward and more type-safe.
How
TLDR, introduced the type:
pub enum Tree<A> {
Node(Vec<Self>),
Leaf(A),
}
pub type MerkleProof = Tree<MerkleProofLeaf>;
pub enum MerkleProofLeaf {
Blind(Hash),
Read(Vec<u8>),
}
Manually Testing
make -C src/riscv all
# In particular
(cd src/riscv && cargo test proof)
Benchmarking
Interpreter performance not impacted
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.
Edited by Felix Puscasu