Skip to content
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

Draft
wants to merge 1 commit into
base: next
Choose a base branch
from
Draft

Implement program executor #1197

wants to merge 1 commit into from

Conversation

Fumuran
Copy link
Contributor

@Fumuran Fumuran commented Mar 4, 2025

This PR implement new execute_program public procedure for executing arbitrary scripts.

Comment on lines +199 to +206
pub fn execute_program(
&self,
account_id: AccountId,
block_ref: BlockNumber,
source: &str,
assembler: Assembler,
advice_inputs: AdviceInputs,
) -> Result<[Felt; 16], TransactionExecutorError> {
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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 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.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants