[go: up one dir, main page]

RISC-V: Implement state hashing in new CommitmentLayout trait

Closes RV-389, part of RV-388.

What

This MR changes the way in which the PVM state is hashed from the RootHashable trait to a new CommitmentLayout trait.

Why

The RootHashable trait is implemented on a combination of backend-specific types (Cells, DynCells, EnrichedCell) and generic layout types (tuples, arrays, vectors) and in most cases relies on derived serde::Serialize implementations to first serialise then hash values of these types.

Given this and the invariant that states should have the same root hash for all state backend managers (Owned, ProofGen, Verify) this creates the requirement that backend types be serialised the same way for all state backend managers.

How

CommitmentLayout, a subtrait of Layout is introduced, only requiring the state_hash function initially. It is implemented for all layout type required to produce a hash of the PVM state. The relevant hashing function in the node PVM and the PVM stepper are placed to use it. Under the hood, the way in which hashing is done is unchanged for now.

Manually Testing

make -C src/riscv all

Benchmarking

No impact on performance.

Regressions

No changes to regressions. Indeed, we want to make sure the state_hash implementations introduced in this MR result in the same root hashes as previously via RootHashable.

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.
    • make -C src/riscv
    • dune build src/lib_riscv
    • dune build src/rust_deps
  • Benchmark performance and populate the table above if needed.
  • Explain changes to regression test captures when applicable.
  • 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 Victor Dumitrescu

Merge request reports

Loading