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

feat(blockifier): update AotNativeExecutor to AotContractExecutor #1955

Merged
merged 2 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions crates/blockifier/src/execution/native/contract_class.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use cairo_lang_starknet_classes::contract_class::{
ContractClass as SierraContractClass,
ContractEntryPoint as SierraContractEntryPoint,
};
use cairo_native::executor::AotNativeExecutor;
use cairo_native::executor::AotContractExecutor;
use starknet_api::core::EntryPointSelector;

use crate::execution::contract_class::{ContractClassV1, EntryPointsByType, HasSelector};
Expand All @@ -33,7 +33,7 @@ impl NativeContractClassV1 {
/// executor must be derived from sierra_program which in turn must be derived from
/// sierra_contract_class.
pub fn new(
executor: AotNativeExecutor,
executor: AotContractExecutor,
sierra_contract_class: SierraContractClass,
casm: ContractClassV1,
) -> NativeContractClassV1 {
Expand All @@ -54,14 +54,14 @@ impl NativeContractClassV1 {

#[derive(Debug)]
pub struct NativeContractClassV1Inner {
pub executor: AotNativeExecutor,
pub executor: AotContractExecutor,
entry_points_by_type: EntryPointsByType<NativeEntryPoint>,
casm: ContractClassV1,
}

impl NativeContractClassV1Inner {
fn new(
executor: AotNativeExecutor,
executor: AotContractExecutor,
sierra_contract_class: SierraContractClass,
casm: ContractClassV1,
) -> Self {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub fn execute_entry_point_call(
let mut syscall_handler: NativeSyscallHandler<'_> =
NativeSyscallHandler::new(call, state, resources, context);

let execution_result = contract_class.executor.invoke_contract_dynamic(
let execution_result = contract_class.executor.run(
&function_id,
&syscall_handler.call.calldata.0.clone(),
Some(syscall_handler.call.initial_gas.into()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use crate::test_utils::{trivial_external_entry_point_new, CairoVersion, BALANCE}

#[cfg_attr(
feature = "cairo_native",
test_case(FeatureContract::TestContract(CairoVersion::Native), 27290; "Native")
test_case(FeatureContract::TestContract(CairoVersion::Native), 25920; "Native")
)]
#[test_case(FeatureContract::TestContract(CairoVersion::Cairo1), REQUIRED_GAS_STORAGE_READ_WRITE_TEST; "VM")]
fn test_storage_read_write(test_contract: FeatureContract, expected_gas: u64) {
Expand Down
13 changes: 3 additions & 10 deletions crates/blockifier/src/test_utils/struct_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use cairo_lang_starknet_classes::casm_contract_class::CasmContractClass;
#[cfg(feature = "cairo_native")]
use cairo_lang_starknet_classes::contract_class::ContractClass as SierraContractClass;
#[cfg(feature = "cairo_native")]
use cairo_native::executor::AotNativeExecutor;
use cairo_native::executor::AotContractExecutor;
use cairo_vm::vm::runners::cairo_runner::ExecutionResources;
use serde_json::Value;
use starknet_api::block::{BlockNumber, BlockTimestamp, NonzeroGasPrice};
Expand Down Expand Up @@ -250,15 +250,8 @@ impl NativeContractClassV1 {
.extract_sierra_program()
.expect("Cannot extract sierra program from sierra contract class");

// Create a Cairo Native MLIR context. This structure handles MLIR initialization and
// compiles Sierra programs into an MLIR module
let native_context = cairo_native::context::NativeContext::new();
// Compile the sierra program into a MLIR module
let native_program = native_context
.compile(&sierra_program, false)
.expect("Cannot compile sierra program into native program");
let executor =
AotNativeExecutor::from_native_module(native_program, cairo_native::OptLevel::Default);
let executor = AotContractExecutor::new(&sierra_program, cairo_native::OptLevel::Default)
.expect("Cannot compile sierra into native");

// Compile the sierra contract class into casm
let casm_contract_class = CasmContractClass::from_contract_class(
Expand Down
Loading