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

can't run cairo1 fibonacci with proof_mode flag #1865

Closed
Retamogordo opened this issue Nov 3, 2024 · 3 comments
Closed

can't run cairo1 fibonacci with proof_mode flag #1865

Retamogordo opened this issue Nov 3, 2024 · 3 comments

Comments

@Retamogordo
Copy link

Hola,
I'm trying to follow the readme steps for running the cairo1 basic program.
While I was able to run it as suggested to generate execution trace related outputs:

cargo run ../cairo_programs/cairo-1-programs/fibonacci.cairo --trace_file ../cairo_programs/cairo-1-programs/fibonacci.trace --memory_file ../cairo_programs/cairo-1-programs/fibonacci.memory

when I try to do so in a proof mode:

cargo run ../cairo_programs/cairo-1-programs/fibonacci.cairo \
--trace_file ../cairo_programs/cairo-1-programs/fibonacci.trace \
--memory_file ../cairo_programs/cairo-1-programs/fibonacci.memory \
--air_public_input=fibonacci_public_input.json \
--air_private_input=fibonacci_private_input.json \
--proof_mode

an error is returned:

Error: IlegalReturnValue

I printed out the returned value TypeInfo:

TypeInfo { long_id: ConcreteTypeLongId { generic_id: GenericTypeId("felt252"), generic_args: [] }, storable: true, droppable: true, duplicatable: true, zero_sized: false }

which seems to be a single felt instead array of felts which is apparently expected.

@FrancoGiachetta
Copy link
Contributor

FrancoGiachetta commented Nov 4, 2024

Hi @Retamogordo!
Two things on this:

  1. As you said, the program you are running returns a felt instead of the array. This is because that program is not meant to be proven. You may want to look inside the serialized_output folder (inside cairo-1-programs) and search for the fibonacci one. Those programs do return the array that is expected.

  2. You also need to use a different layout, by default plain is used (which provides no builtins). If you get the sierra out of the .../serialized_output/fibonacci.cairo, you'll see that you need RangeCheck builtin. So you need at least the small layout.

If you want to know which builtins provide each layout, take a look at this file

This command should do the trick:

cargo run ../cairo_programs/cairo-1-programs/serialized_output/fibonacci.cairo \
--trace_file ../cairo_programs/cairo-1-programs/fibonacci.trace \
--memory_file ../cairo_programs/cairo-1-programs/fibonacci.memory \
--air_public_input=fibonacci_public_input.json \
--air_private_input=fibonacci_private_input.json \
--proof_mode \
--layout small

@FrancoGiachetta
Copy link
Contributor

I'll close the issue as the solution is the one provided. Ping us if you need anything else!

@Retamogordo
Copy link
Author

Hi @Retamogordo! Two things on this:

1. As you said, the program you are running returns a felt instead of the array. This is because that program is not meant to be proven. You may want to look inside the `serialized_output` folder (inside `cairo-1-programs`) and search for the fibonacci one. Those programs do return the array that is expected.

2. You also need to use a different layout, by default `plain` is used (which provides no builtins). If you get the sierra out of the `.../serialized_output/fibonacci.cairo`, you'll see that you need `RangeCheck` builtin. So you need at least the `small` layout.

If you want to know which builtins provide each layout, take a look at this file

This command should do the trick:

cargo run ../cairo_programs/cairo-1-programs/serialized_output/fibonacci.cairo \
--trace_file ../cairo_programs/cairo-1-programs/fibonacci.trace \
--memory_file ../cairo_programs/cairo-1-programs/fibonacci.memory \
--air_public_input=fibonacci_public_input.json \
--air_private_input=fibonacci_private_input.json \
--proof_mode \
--layout small

Thank you. I definitely omitted the layout specification. Thank you for pointing out the location of provable cairo1 programs.

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

2 participants