starkware-libs / cairo-lang

Apache License 2.0
1.33k stars 262 forks source link

Incomplete Bazel Build Process for `cairo_verifier` in v0.13.0a2 #178

Open Okm165 opened 9 months ago

Okm165 commented 9 months ago

Description:

Issue Summary:

I encountered a problem with the build process for the cairo_verifier in the cairo-lang repository, specifically in the version tagged as v0.13.0a2 using Python 3.9.0. The build completes successfully, but when attempting to run cairo_verifier, it seems that some python components are not present.

Steps to Reproduce:

  1. Clone the cairo-lang repository and checkout to tag v0.13.0a2.
  2. Use the following Docker commands to build the project:
    docker build --tag cairo .
    container_id=$(docker create cairo)
    docker cp ${container_id}:/app/cairo-lang-0.13.0a2.zip .
    docker rm -v ${container_id}
    pip install cairo-lang-0.13.0a2.zip

    This builds the Bazel project as expected.

  3. Try compiling cairo_verifier with the following command:
    cairo-compile --cairo_path=./src src/starkware/cairo/cairo_verifier/layouts/all_cairo/cairo_verifier.cairo --output cairo_verifier.json --no_debug_info
  4. Then run it with:
    cairo-run \
          --program=cairo_verifier.json \
          --layout=starknet_with_keccak \
          --program_input=cairo_verifier_input.json \
          --trace_file=cairo_verifier_trace.json \
          --memory_file=cairo_verifier_memory.json \
          --print_output

    The cairo_verifier_input.json file used is:

    {
       "proof": {
       <copy the content of src/starkware/cairo/stark_verifier/air/example_proof.json>
       }
    }

    Expected Result:

    The cairo_verifier should compile and run without any issues.

Actual Result:

Error at pc=0:13207:
Got an exception while executing a hint.
Traceback (most recent call last):
  File "<hint33>", line 2, in <module>
  File "/home/bartosz/.pyenv/versions/3.9.0/envs/cairo-lang/lib/python3.9/site-packages/starkware/cairo/stark_verifier/air/parser.py", line 158, in parse_proof
    CPU_COMPONENT_STEP = get_dynamic_or_const_value(
  File "/home/bartosz/.pyenv/versions/3.9.0/envs/cairo-lang/lib/python3.9/site-packages/starkware/cairo/stark_verifier/air/parser.py", line 150, in get_dynamic_or_const_value
    res = identifiers.root.get(
  File "/home/bartosz/.pyenv/versions/3.9.0/envs/cairo-lang/lib/python3.9/site-packages/starkware/cairo/lang/compiler/identifier_manager.py", line 308, in get
    return scope.get(non_parsed)
  File "/home/bartosz/.pyenv/versions/3.9.0/envs/cairo-lang/lib/python3.9/site-packages/starkware/cairo/lang/compiler/identifier_manager.py", line 308, in get
    return scope.get(non_parsed)
  File "/home/bartosz/.pyenv/versions/3.9.0/envs/cairo-lang/lib/python3.9/site-packages/starkware/cairo/lang/compiler/identifier_manager.py", line 308, in get
    return scope.get(non_parsed)
  [Previous line repeated 2 more times]
  File "/home/bartosz/.pyenv/versions/3.9.0/envs/cairo-lang/lib/python3.9/site-packages/starkware/cairo/lang/compiler/identifier_manager.py", line 321, in get
    raise MissingIdentifierError(fullname=self.fullname + first_name)
starkware.cairo.lang.compiler.identifier_manager.MissingIdentifierError: Unknown identifier 'starkware.cairo.stark_verifier.air.layouts.starknet_with_keccak'.

Additional Information:

Okm165 commented 9 months ago

When i investigate the cairo-lang-0.13.0a2.zip there is no such folder (starkware.cairo.stark_verifier.air.layouts.starknet_with_keccak) how to fix it? What chenges do i need to make in bazel BUILD's to have this repo properly working?

unzip cairo-lang-0.13.0a2.zip 
cd cairo-lang-0.13.0a2/starkware/cairo/
Okm165 commented 8 months ago

Exact manual steps i took to make bazel out package work in compilation and running process can be tracked here https://github.com/Okm165/cairo-lang/tree/bazel-build-issue-manual-fix

Okm165 commented 8 months ago

Then cairo verifier is run on example proof cairo_verifier_input.json and works

Okm165 commented 8 months ago

I tried to fix bazel BUILD files myself but it took longer then expected can u help to solve bazel build issues?

Okm165 commented 8 months ago

I created repository that has this issue solved, if anybody encounters this problem please track the commits or contact me directly 👍🏼 https://github.com/Okm165/stone-prover-cairo0-verifier