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.
Describe the bug
A clear and concise description of what the bug is.
When I include core::internal::require_implicit::<System>(); into any program, the cairo1run binary crashes with the error below.
Run it with cairo1runcargo run -r --manifest-path ../cairo-vm/cairo1-run/Cargo.toml ../lib.cairo --args "[0 0]" --layout all_cairo --print_output --proof_mode
See error
Expected behavior
The output of the program instead of an error.
What version/commit are you on?
For example: v0.6.0, e762069, etc.
Current main, rev=3fb0344ce038b3a68cae897c403d1f561cfe8da7
I am working on a custom version of cairo-vm, that would be able to run contracts and I hit a blocker.
I managed to add a custom plugin, and gas management is also handled, and working fine. The issue I had was with the memory, which fails. If I try to access the program's arguments and there is a core::internal::require_implicit::<System>(); anywhere in the program, I get the error above.
Describe the bug A clear and concise description of what the bug is. When I include
core::internal::require_implicit::<System>();
into any program, thecairo1run
binary crashes with the error below.To Reproduce Steps to reproduce the behavior:
Create the program below
Run it with
cairo1run
cargo run -r --manifest-path ../cairo-vm/cairo1-run/Cargo.toml ../lib.cairo --args "[0 0]" --layout all_cairo --print_output --proof_mode
See error
Expected behavior The output of the program instead of an error.
What version/commit are you on? For example: v0.6.0, e762069, etc. Current main, rev=
3fb0344ce038b3a68cae897c403d1f561cfe8da7
Additional context
Related to: https://t.me/lambdaworks/9122
I am working on a custom version of cairo-vm, that would be able to run contracts and I hit a blocker.
I managed to add a custom plugin, and gas management is also handled, and working fine. The issue I had was with the memory, which fails. If I try to access the program's arguments and there is a
core::internal::require_implicit::<System>();
anywhere in the program, I get the error above.Potentially unexpected change in the AP pointer. I traced the problem back to failed allocation hint here: https://github.com/lambdaclass/cairo-vm/blob/3fb0344ce038b3a68cae897c403d1f561cfe8da7/vm/src/hint_processor/cairo_1_hint_processor/hint_processor.rs#L301 The issue is present on the main branch as well, so not attaching a repository.
I think I narrowed down the place where the allocation hint is triggered.
hint AllocSegment {} into {dst: system}
; here: https://github.com/lambdaclass/cairo-vm/blob/850ff8ec5b7a506f8caeac2d831bc23a8dc72145/cairo1-run/src/cairo_run.rs#L604-L605