feat: specify initial value for exec_scopes#1772
Conversation
fmoletta
left a comment
There was a problem hiding this comment.
This seems like a very specific behaviour, I would rather have it added to the CairoRunConfig struct, so users can just ignore it (aka leave it to the Default impl to handle).
One issue with that is that we get a What do you think @fmoletta ? |
|
It's not clear to me that you can't do this via a regular hint that you run as part of your program load process. Is there something getting in the way of doing that? |
@Oppen yes. You need to load these initial variables from somewhere. You could say "let's load it from the file system" but a) that involves some useless serialization/deserialization which is not that easy with types like Anecdotally, this feature exists for the Python VM (see here). |
33a55b8 to
feb7b24
Compare
Oh, then we could go with the current solution and rename |
Context: bootloader and Starknet OS support. Added an `exec_scopes` parameter to `cairo_run_program` to pass variables to the hints of the program being run. We need a way to set initial variables inside the execution scopes to pass bootloader/OS arguments. The Python VM relies on a program input file and uses hints to deserialize this input. In most cases we do not want to have to deserialize these input types, but rather pass them directly as variables inside the root execution scope. We did not extend this feature to `cairo_run` to keep the PR minimal for discussion, TBD if it is desirable.
feb7b24 to
45e929e
Compare
Done: 45e929e |
Context: bootloader and Starknet OS support.
Added a
cairo_run_program_with_initial_scopefunction that allows to run a program with a customized execution scope.cairo_run_programnow calls this function with an empty execution scope.We need a way to set initial variables inside the execution scopes to pass bootloader/OS arguments. The Python VM relies on a program input file and uses hints to deserialize this input. In most cases we do not want to have to deserialize these input types, but rather pass them directly as variables inside the root execution scope.
Possible alternatives:
CairoRunConfig.ProgramandCairoPie, so I'd prefer not to go down that road.Checklist