-
Notifications
You must be signed in to change notification settings - Fork 60
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
Implement program executor #1197
base: next
Are you sure you want to change the base?
Conversation
pub fn execute_program( | ||
&self, | ||
account_id: AccountId, | ||
block_ref: BlockNumber, | ||
source: &str, | ||
assembler: Assembler, | ||
advice_inputs: AdviceInputs, | ||
) -> Result<[Felt; 16], TransactionExecutorError> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason not to use the interface I suggested in #1161 (comment)? Basically:
pub fn execute_program(
&self,
account_id: AccountId,
block_ref: BlockNumber,
tx_script: TransactionScript,
advice_inputs: AdviceInputs,
) -> Result<[Felt; 16], TransactionExecutorError>
This would also allow specifying inputs for the transaction script (i.e., values that get put on the top of the stack before the script is executed).
The user could then generate TransactionScript
using TransactionScript::compile()
method which is a bit more general than just using a string.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Usage of the TransactionScript
will indeed allow user to specify the transaction script inputs, but in that case creation of the final program will be more complicated.
To use this procedure in testing we need to execute the prologue before the provided code. If the code is provided as a string, I can just modify it, adding the execution of the prologue right after the begin
. But if we have already compiled TransactionScript
, we need to have something like a main
script, which will execute the prologue first and then call the code provided by the user. I can implement it, but I thought that for the testing purposes the first approach will be sufficient.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But if we have already compiled
TransactionScript
, we need to have something like amain
script, which will execute the prologue first and then call the code provided by the user. I can implement it, but I thought that for the testing purposes the first approach will be sufficient.
This is not just for testing purposes (i.e., it needs to work in the client under regular release). So, we should probably create another main
file and use it here.
This PR implement new
execute_program
public procedure for executing arbitrary scripts.