RISC-V: Let context repo store serialised object
Closes RV-203
What
Implements methods commit_serialised and checkout_serialised which can leverage serde::Serialize and serde::Deserialize to store and fetch things from the context's repository (a.k.a. the store).
Why
This is one of the prerequisites for switching the NodePvm to use the owned backend.
The owned backend doesn't come with a backend that has the already-serialised representation. However, we can serialise and deserialise in other ways.
For serialisation, we can use the AllocatedOf<StateLayout, Ref<'_, Owned>> returned by the struct_ref method as it implements serde::Serialize.
For deserialisation, we can use Allocated<StateLayout, Owned> which implements serde::Deserialize and can be used to re-bind the PVM state again.
How
The existing commit and checkout methods use chunking internally to reduce data duplication. I created ChunkedWriter and ChunkedReader which can be used as a serialisation target and deserialisation source.
Manually Testing
make -C src/riscv all
Benchmarking
This does not impact performance.
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.