Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unexpected use of paths specified in private-input.json #337

Open
tdelabro opened this issue Jan 9, 2025 · 0 comments
Open

unexpected use of paths specified in private-input.json #337

tdelabro opened this issue Jan 9, 2025 · 0 comments

Comments

@tdelabro
Copy link

tdelabro commented Jan 9, 2025

In stwo_cairo_prover/crates/prover/src/input/vm_import/mod.rs

    let memory_path = private_input_json
        .parent()
        .unwrap()
        .join(&private_input.memory_path);
    let trace_path = private_input_json
        .parent()
        .unwrap()
        .join(&private_input.trace_path);

Those read the path of the memory.bin and trace.bin from the private-input.json fields "trace_path" and `"memory_path". The way they do so is not robust and coherent with the way they are generated.

I generated those using cairo1-run and the values are:

  "trace_path": "outputs/spending_conditions/trace/trace.bin",
  "memory_path": "outputs/spending_conditions/trace/memory.bin",

This is a path relative to the folder I was into when I ran cairo1-run. I ran

cairo1-run target/release/$PROGRAM_NAME.sierra.json \
  --args "[650157136941007917207724121471813482783483983289688285320161307177215463403 1655569645808460179723299787189716707852181277595105475126938070374837146371]" \
  --layout=$LAYOUT \
  --air_public_input=$TRACE_OUTPUT_DIR/public-input.json \
  --air_private_input=$TRACE_OUTPUT_DIR/private-input.json \
  --trace_file=$TRACE_OUTPUT_DIR/trace.bin \
  --memory_file=$TRACE_OUTPUT_DIR/memory.bin \
  --proof_mode 

And those values are $TRACE_OUTPUT_DIR/trace.bin and $TRACE_OUTPUT_DIR/memory.bin

But the code just append this to the private_input_path.parent(), which gives us outputs/spending_conditions/outputs/spending_conditions/trace/trace.bin, which fails.

That is not how stones works. If I run cpu_air_prover from the same folder, it will correctly retrieve the trace.bin file given the relative path.
We need coherence here.

Also the error I got wasn't descriptive enough:

➜  spending_conditions git:(main) ✗ adapted_stwo --pub_json outputs/spending_conditions/trace/public-input.json --priv_json outputs/spending_conditions/trace/private-input.json --proof_path ./proof.json
2025-01-09T09:04:47.484453Z  INFO run: adapted_stwo: enter
2025-01-09T09:04:47.484572Z  INFO run:adapt_vm_output: stwo_cairo_prover::input::vm_import: enter
2025-01-09T09:04:47.484955Z  INFO run:adapt_vm_output: stwo_cairo_prover::input::vm_import: close time.busy=382µs time.idle=917ns
2025-01-09T09:04:47.484970Z  INFO run: adapted_stwo: close time.busy=521µs time.idle=2.42µs
[INFO  stwo_cairo_utils::binary_utils] run_and_prove failed: VM import failed: IO error: No such file or directory (os error 2)
➜  spending_conditions git:(main) ✗ adapted_stwo --pub_json outputs/spending_conditions/trace/public-input.json --priv_json outputs/spending_conditions/trace/private-input.json --proof_path ./proof.json
2025-01-09T09:05:07.503604Z  INFO run: adapted_stwo: enter
2025-01-09T09:05:07.503751Z  INFO run:adapt_vm_output: stwo_cairo_prover::input::vm_import: enter
2025-01-09T09:05:07.504163Z  INFO run:adapt_vm_output: stwo_cairo_prover::input::vm_import: close time.busy=411µs time.idle=833ns
2025-01-09T09:05:07.504183Z  INFO run: adapted_stwo: close time.busy=585µs time.idle=3.71µs
[INFO  stwo_cairo_utils::binary_utils] run_and_prove failed: VM import failed: IO error: No such file or directory (os error 2)

Your error message is defined there:

    #[error("IO error: {0}")]
    Io(#[from] std::io::Error),

And it gives me no context on what I am doing wrong.
I'm expecting something along the lines of:

"Failed to open `trace.bin` using the "trace_path" value specified in `private_intput.json`: "outputs/spending_conditions/trace/memory.bin"

With this, I know what you tried to do, why it failed, and how I can try fixing it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant