You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Changes
Adds the function load_arguments which loads the input arguments (if any) into the VM after initialization and removes the instructions that create these arguments in create_entry_code. This change has no effect on the execution segment.
Adds test to make sure that the program_hash does not depend on the arguments used to run it.
Motive & Context
This PR solves the issue of the program_hash changing depending on the arguments passed to the vm when running it. This happens due to how cairo 1 handles arguments. Cairo 0 doesn't have arguments when running a program, this was circumvented by Cairo 1 by adding instructions to the original program that declare the arguments as constants and insert them into the execution segment (via tempvars) before calling the main function (they also add the builtin and segment arena pointers). While this allows running cairo 1 programs with arguments, it also makes the program (and therefore the program_hash) vary depending on the arguments used, as the arguments are now part of the instructions.
This PR is the later of 3 approaches to solve this issue, the previous three attempts consisted on:
Replacing all instructions that create values in the execution segment with loading them directly into the VM before the run [Cairo 1] Replace hardcoded arguments with vm initialization #1751 (This worked similarly to this PR, but aside from loading the input arguments, it also loaded the builtin bases & segment arena values and removed the instructions that created them. While this solution worked (aka it allowed proving using Stone Prover), it involves more values being magically created, which can reduce the integrity of the proof (see discussion & possible issues))
Discussion & possible issues
As arguments are now loaded into the memory directly instead of being created by a cairo instruction, this could be seen as a hint being the one that creates those values in memory, which means that we won't be able to prove that it was those specific input values that produced an output based on a program as the prover doesn't currently take these arguments as public inputs.
Since program arguments are no longer included in the public inputs for the prover, one way to verify that a program has been executed correctly with specific arguments would to return those arguments in the program's output, right?. This way, we ensure that the arguments become part of the public inputs, similar to serialize_word in CairoZero.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes
Adds the function
load_arguments
which loads the input arguments (if any) into the VM after initialization and removes the instructions that create these arguments increate_entry_code
. This change has no effect on the execution segment.Adds test to make sure that the program_hash does not depend on the arguments used to run it.
Motive & Context
This PR solves the issue of the program_hash changing depending on the arguments passed to the vm when running it. This happens due to how cairo 1 handles arguments. Cairo 0 doesn't have arguments when running a program, this was circumvented by Cairo 1 by adding instructions to the original program that declare the arguments as constants and insert them into the execution segment (via tempvars) before calling the main function (they also add the builtin and segment arena pointers). While this allows running cairo 1 programs with arguments, it also makes the program (and therefore the program_hash) vary depending on the arguments used, as the arguments are now part of the instructions.
This PR is the later of 3 approaches to solve this issue, the previous three attempts consisted on:
Removing the create_entry_code altogether [WIP] Remove
create_entry_code
#1746 (This run into issues due to the segment arena builtin)Replacing all instructions that create values in the execution segment with loading them directly into the VM before the run [Cairo 1] Replace hardcoded arguments with vm initialization #1751 (This worked similarly to this PR, but aside from loading the input arguments, it also loaded the builtin bases & segment arena values and removed the instructions that created them. While this solution worked (aka it allowed proving using Stone Prover), it involves more values being magically created, which can reduce the integrity of the proof (see discussion & possible issues))
Discussion & possible issues
As arguments are now loaded into the memory directly instead of being created by a cairo instruction, this could be seen as a
hint
being the one that creates those values in memory, which means that we won't be able to prove that it was those specific input values that produced an output based on a program as the prover doesn't currently take these arguments as public inputs.