# Cairo 1/2 support from Programs without Gas related functions and builtins

**URL:** <https://community.starknet.io/t/cairo-1-2-support-from-programs-without-gas-related-functions-and-builtins/99327>\
**Category:** 🙏 Help and Support\
**Created:** [August 26, 2023, 2:02am UTC](https://community.starknet.io/t/cairo-1-2-support-from-programs-without-gas-related-functions-and-builtins/99327 "2023-08-26T02:02:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![maurotoscano](https://avatars.discourse-cdn.com/v4/letter/m/e36b37/32.png) [@maurotoscano](https://community.starknet.io/u/maurotoscano)\
**Post date:** [August 26, 2023, 2:02am UTC](https://community.starknet.io/t/cairo-1-2-support-from-programs-without-gas-related-functions-and-builtins/99327/1 "2023-08-26T02:02:22Z")

</div>

Hello, I’m doing a proof of concept program to support running cairo 1/2 programs without the gas cost related built ins. The starting point is the cairo lang runner.

So far I have removed the call in the cairo lang runner to the `create_entry_code()` as it’s used here:

> <https://github.com/starkware-libs/cairo/blob/98af2f86dfd19a75a8ebe7870e4f69b57fdeb756/crates/cairo-lang-runner/src/lib.rs#L194>

And I’m replacing it with one that works like the cairo 0 proof mode ([Call rel 4, jmp rel 0](https://github.com/lambdaclass/cairo-vm/blob/b73868d2f88b70f600434a992e0b02030e28fee7/cairo1-run/src/main.rs#L158-L162) ). This is missing the update of the allocation pointer but in the case of programs without args and builtins it should behave just like the [Cairo 0 version](https://github.com/starkware-libs/cairo-lang/blob/27a157d761ae49b242026bcbe5fca6e60c1e98bd/src/starkware/cairo/lang/compiler/cairo_compile.py#L334-L340).

Since builtins shouldn’t be necessary for simpler programs, I’m also running the virtual machine with a plain layout, but I’m not sure in which cases Cairo 1/2 uses built ins.

Right now this approach seems to be working for programs without recursion, we are trying to find what’s the issue with these programs.

To summarize some specific questions:

- How can I know if a program is using a built in ?
- Is there something important that I should add from the entry code, when I don’t care about the gas costs?

If someone sees any issue with this approach, do tell.

For reference, these programs seem to be running fine:

Add  
[Add with function](https://github.com/lambdaclass/cairo-vm/blob/cairo1_for_prover/cairo1-run/add_func.cairo)

These are having problems:  
[https://github.com/lambdaclass/cairo-vm/blob/cairo1\_for\_prover/cairo1-run/factorial.cairo](https://github.com/lambdaclass/cairo-vm/blob/cairo1_for_prover/cairo1-run/factorial.cairo)

---

<div class="post-metadata">

**Author:** ![ilyalesokhin](https://dub1.discourse-cdn.com/flex005/user_avatar/community.starknet.io/ilyalesokhin/32/77680_2.png) [@ilyalesokhin](https://community.starknet.io/u/ilyalesokhin)\
**Post date:** [October 24, 2023, 8:33am UTC](https://community.starknet.io/t/cairo-1-2-support-from-programs-without-gas-related-functions-and-builtins/99327/2 "2023-10-24T08:33:18Z")

</div>

You can look at `create_entry_code()` to figure out what builtins are used by a specific function.

> <https://github.com/starkware-libs/cairo/blob/98af2f86dfd19a75a8ebe7870e4f69b57fdeb756/crates/cairo-lang-runner/src/lib.rs#L427>

The issue with recursive programs is that they need the GasBuiltin.

---

<div class="post-metadata">

**Author:** ![maurotoscano](https://avatars.discourse-cdn.com/v4/letter/m/e36b37/32.png) [@maurotoscano](https://community.starknet.io/u/maurotoscano)\
**Post date:** [October 25, 2023, 1:40am UTC](https://community.starknet.io/t/cairo-1-2-support-from-programs-without-gas-related-functions-and-builtins/99327/3 "2023-10-25T01:40:00Z")

</div>

> [@ilyalesokhin](#):
>
> The issue with recursive programs is that they need the GasBuiltin.

Thank you Ilya! I’ll check if that solves the problem! This is great news
