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

refactor(blockifier): get_execution_info v1 and v2 #31

Merged
merged 1 commit into from
Oct 29, 2024

Conversation

PearsonWhite
Copy link

Moved the block_info and tx_info blocks from get_execution_info and get_execution_info_v2 to helper functions in impl<'state> NativeSyscallHandler<'state> to make functions smaller and reduce duplication. block_info = ... was the same for both functions.

@PearsonWhite PearsonWhite force-pushed the pwhite/refactor_get_execution_info branch from c7724a1 to 57981db Compare October 21, 2024 17:15
@@ -253,49 +337,9 @@ impl<'state> StarknetSyscallHandler for &mut NativeSyscallHandler<'state> {
self.execution_context.gas_costs().get_execution_info_gas_cost,
)?;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's fine to keep some duplication between these functions because:

  1. This "get" functions breaks the Command Query Separation principle with pre_execute_syscall and hiding it behind anything would make it less immediately noticeable.
  2. Both get_execution_info functions should still have the basic logic of what they're doing directly in their function bodies.
  3. The functions are now both pretty small and straightforward.

@PearsonWhite PearsonWhite force-pushed the pwhite/refactor_get_execution_info branch from 57981db to f8cddb4 Compare October 21, 2024 17:36
@PearsonWhite
Copy link
Author

PearsonWhite commented Oct 21, 2024

I don't know why the commit linter thinks I have an empty subject and type, but I modeled my commit message after the ones on the Starkware repo.

Fixed. It was looking at the PR title.

@PearsonWhite PearsonWhite force-pushed the pwhite/refactor_get_execution_info branch 2 times, most recently from 45ee597 to 1d10294 Compare October 22, 2024 17:18
@PearsonWhite PearsonWhite changed the title refactor get execution info refactor(blockifier): get_execution_info v1 and v2 Oct 22, 2024
Copy link

@varex83 varex83 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM overall

crates/blockifier/src/execution/native/syscall_handler.rs Outdated Show resolved Hide resolved
crates/blockifier/src/execution/native/syscall_handler.rs Outdated Show resolved Hide resolved
@PearsonWhite PearsonWhite force-pushed the pwhite/refactor_get_execution_info branch from 1d10294 to 28113df Compare October 28, 2024 17:11
@PearsonWhite PearsonWhite merged commit b7c2cce into native2.8.x Oct 29, 2024
11 checks passed
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