-
Notifications
You must be signed in to change notification settings - Fork 160
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
core: not able to run when execution_base
segment is not 1
#1908
Comments
Hi @ClementWalter, we can document the initialization functions to clarify that they are meant to be called only once. |
@gabrielbosio sure you can document, but I don't think enforcing execution_base = 1 is a correct behavior for the VM, see the reference python implementation https://github.com/starkware-libs/cairo-lang/blob/master/src/starkware/cairo/lang/vm/vm_core.py#L31-L40 ap and fp are relocatable and could point to any segment |
@ClementWalter While it's not explicit that in the VM |
it's true that Cairo PIE enforces the segments orders (0 and 1) but it's because the goal of PIEe is to concatenate runs. This is a special use case of the VM, not the spec. The VM itself doesn't care about segment orders. As a matter of fact, the reference implementation allowed program and execution to be anything, but enforced this at the PIE level. I don't see good reason to depart from this. |
From an example of the Cairo 0 docs:
I'm curious about what's the context where |
it's just not part of the spec. it's like if builtins segments were expected to have constant indexes. It would work, but it's not part of the spec. As a real world use case, it happened to me because we're pre filling the memory with a lot of data even before the runner starts. It should be an issue because the segments indexes don't matter. But now it's one. |
Describe the bug
It's possible to initialize the runner with
self.execution_base != (1, 0)
as theinitialize_segments
function just adds segments without constraint on already existing segmentsIn this context,
runner.initial_(f/a)p
are properly targeting the right segment but this info is dropped during the initialization of theRunContext
which actually has a hard-coded 1
All together, this makes the VM unable to run since
ap
andfp
are pointing to the wrong segment.Since there is no reason to enforce the execution segment to be 1, the easiest and most reasonable fix to me is to add a
execution_base_segment_index
to theRunContext
and to update theget_ap
andget_fp
methods.The text was updated successfully, but these errors were encountered: