0xmozak / mozak-vm

Mozak RISC-V Virtual Machine
Apache License 2.0
12 stars 8 forks source link

Reproducible builds of guest programs #132

Open matthiasgoergens opened 1 year ago

matthiasgoergens commented 1 year ago

The same source code (say in Rust or C) of a guest program whose execution we want to prove should lead to the same program hash.

For that to work, we need to provide our users with compiler settings for all languages we want to support that reliably produce the same Risc-V ELF file, when fed the same source code.

See https://reproducible-builds.org/ for details. For Rust, we might be able to do this with pure cargo, or we might want to enlist the help of Nix and/or Docker. For C, we can see if LLVM/Clang settings are enough, or otherwise also use Nix and/or Docker.

eightfilms commented 1 year ago

This came up in a private conversation, but to expand on the original point, it sometimes isn't enough to assume that build tools will create a unique, reproducible program (in this case, a RISC-V ELF program).

This seems to be a sneaky issue that has plagued projects in the past/present:

https://github.com/near/near-sdk-rs/issues/456 https://github.com/risc0/risc0/issues/116

using Docker to fix this seems to be a bandaid solution. (and Docker in itself is not deterministic either way)

Reproducibility is important because otherwise proving the execution of a program would not be useful, since we would be unable to create the same program/binary that generated that proof to begin with.