snarkVM
snarkVM copied to clipboard
[Bug] Missing powers file
🐛 Bug Report
When starting on a clean machine where there is no ~/.aleo/ folder, and snarkVM has never run, using the universal SRS to generate proofs errors with the following:
thread panicked at 'called `Result::unwrap()` on an `Err` value: No such file or directory (os error 2)', /snarkvm/parameters/src/testnet3/powers.rs:333:67
One way I found to recreate this is to start with a clean Ubuntu machine (i.e. no ~/.aleo/ folder and no history running snarkVM), and cd snarkVM && cargo test to run the root level tests. There will be two tests which fail with the same error message.
I think we should remove usage of the file system from the powers.rs implementation.
The concern is that Rust doesn't check these at compile time (except in limited fashion if one uses OS-specific macro calls), and a file system limits the environments these parameters can be used in, as a file system may not be available (as in WASM).
One last thought: A user who isn't able to load the requisite SRS size into memory wouldn't be able to compute a circuit of the respective size. I believe holding in memory should be okay.
The error stems from .unwrap()s which need to be removed.
In addition, the code is relying on the OS to create a file-system temporary folder, and immediately begins using it. In this instance, I hypothesize the root cause is that Ubuntu is not guaranteeing immediate existence of this folder in its index, causing the file not found error.
let mut dir = std::env::temp_dir();
This call creates the following folder, which isn't found immediately after being created.
/var/folders/m0/bn9_082j6197nbc2g_lchbd00000gn/T/powers_of_g_1768192503
So I've been able to work out what's happening.
We are never even using the powers_of_{degree} files. This infra solely relies on the temp file existing in your computer to work.
And if I load from the powers_of_{degree} files, the values are indexed differently in the SonicPC.
TLDR - We aren't using the universal setup ceremony values in snarkVM.
I've refactored PowersOfG to address some of the above concerns. Note the version now does not use the powers_of_* files at all, instead it is all from the setup.
Changes are in commit https://github.com/AleoHQ/snarkVM/commit/f6f76904ef429680076eb0ae82a0d6427e4e221d