lambdaclass / cairo-vm

cairo-vm is a Rust implementation of the Cairo VM. Cairo (CPU Algebraic Intermediate Representation) is a programming language for writing provable programs, where one party can prove to another that a certain computation was executed correctly without the need for this party to re-execute the same program.
https://lambdaclass.github.io/cairo-vm
Apache License 2.0
514 stars 144 forks source link

Cairo1-run InvocationError during sierra->casm compilation on programs with loops and recursion #1745

Closed Okm165 closed 5 months ago

Okm165 commented 5 months ago

Bug Description: Encountering a compilation error during the sierra to casm compilation process in programs containing loops within the cairo-vm cairo1-run package. The error message indicates an InvocationError with the specific error being UnknownVariableData. Full error message:

Error: Compilation(InvocationError { statement_idx: StatementIdx(23), error: UnknownVariableData })

How to Reproduce:

  1. Set up a scarb project.
  2. Paste the program.
    fn main() -> felt252 {
    let mut i = 5;
    loop {
        if i == 0 {
            break;
        }
        i-=1;
    };
    i
    }
  3. Execute the following steps:
    • scarb build
    • cargo run (path to sierra) --layout all_cairo

It is important to note that if u remove loop from the above program the cairo1-run succeeds to run it


Branch and Commit:

fmoletta commented 5 months ago

Hello! Did you add the following to your Scarb.toml?

[cairo]
enable-gas = false
Okm165 commented 5 months ago

@fmoletta Hi! It solves this issue! Thank u for quick response🚀🚀🚀