Skip to content

Commit

Permalink
chore(blockifier): alternate use of casm and native depending on trac…
Browse files Browse the repository at this point in the history
…ked_resource
  • Loading branch information
avivg-starkware committed Oct 31, 2024
1 parent 1545731 commit a216985
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
25 changes: 18 additions & 7 deletions crates/blockifier/src/execution/execution_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,24 @@ pub fn execute_entry_point_call(
),
#[cfg(feature = "cairo_native")]
ContractClass::V1Native(contract_class) => {
native_entry_point_execution::execute_entry_point_call(
call,
contract_class,
state,
resources,
context,
)
if context.tracked_resource_stack.last() == Some(&TrackedResource::CairoSteps) {
// if CairoSteps are tracked instead of SierraGas, use Casm for all following calling txs.
entry_point_execution::execute_entry_point_call(
call,
contract_class.casm(),
state,
resources,
context,
)
} else {
native_entry_point_execution::execute_entry_point_call(
call,
contract_class,
state,
resources,
context,
)
}
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions crates/blockifier/src/execution/native/contract_class.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ impl NativeContractClassV1 {
pub fn get_entry_point(&self, call: &CallEntryPoint) -> Result<FunctionId, PreExecutionError> {
self.entry_points_by_type.get_entry_point(call).map(|ep| ep.function_id)
}

pub fn casm(&self) -> ContractClassV1 {
self.casm.clone()
}
}

#[derive(Debug)]
Expand Down

0 comments on commit a216985

Please sign in to comment.