Closed odesenfans closed 4 months ago
Hi @odesenfans ! Is there a way we can replicate the error?
Damn you're fast @pefontana ! I'll add one based on the new CLI tool we just released, let me create an example branch!
This should allow you to reproduce the issue:
git clone --recurse-submodules https://github.com/Moonsong-Labs/stone-prover-cli.git --branch od/reproduce-cairo-vm-allow-missing-builtin-issue
cd stone-prover-cli/
cargo build
./target/debug/stone-prover-cli prove --with-bootloader dependencies/cairo-programs/cairo0/fibonacci/fibonacci.json --verifier=l1 --layout=starknet --allow-missing-builtins
I think the problem comes from this function and causes the issue here.
As keccak
is not in the layout, vm.builtin_runners
only has 7 entries. The program entrypoint expects all 8 values to be present on the stack, hence the failure. Instead, initialize_main_entrypoint
should add values on the stack for each builtin specified in the program. I'll check what the Python VM does for this, I've been told it's compatible so it might just be a matter of reproducing the same behaviour.
Yep, the Python VM does this:
for builtin_name in self.program.builtins:
builtin_runner = self.builtin_runners.get(f"{builtin_name}_builtin")
if builtin_runner is None:
assert self.allow_missing_builtins, "Missing builtin."
stack += [0]
else:
stack += builtin_runner.initial_stack()
I'll try to implement this.
Invalid stop pointer for ec_op_builtin: Stop pointer has value 0:0 but builtin segment is 7
Pushed a fix on #1632. There were issues when finalizing the stack for builtins.
Amaizing @odesenfans !! Thanks for the fix, we will review it
Fixed by #1703
Describe the bug For an experiment, I tried to execute the Starknet bootloader with layout
starknet
and allowing missing builtins to suppress the warning about the absence of thekeccak
builtin in the layout. This bypasses the builtin check successfully but yields the following error:This is somewhat surprising because the missing builtin is
keccak
, notposeidon
. Upon further inspection, I realized that the Cairo program expects pointers to the builtins in the main function:My best guess so far is that the issue happens because the builtin pointers are generated from the list of builtins in the layout, and not the list of builtins required by the program.
Expected behavior The pointers for each builtin should be initialized based on what the program requires, not on the builtins available in the layout.
What version/commit are you on? 59254f4c53594217e0182e04008e56df5c187889