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

chore(blockifier): replace sierra_program with casm field for NativeContractClassV1 #1540

Merged
merged 1 commit into from
Oct 30, 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
1 change: 0 additions & 1 deletion crates/blockifier/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ cairo-lang-casm = { workspace = true, features = ["parity-scale-codec"] }
cairo-lang-runner.workspace = true
cairo-lang-sierra.workspace = true
cairo-lang-starknet-classes.workspace = true
cairo-lang-utils.workspace = true
cairo-native = { workspace = true, optional = true }
cairo-vm.workspace = true
derive_more.workspace = true
Expand Down
21 changes: 11 additions & 10 deletions crates/blockifier/src/execution/native/contract_class.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,14 @@ use cairo_lang_starknet_classes::contract_class::{
ContractClass as SierraContractClass,
ContractEntryPoint as SierraContractEntryPoint,
};
use cairo_lang_utils::bigint::BigUintAsHex;
#[allow(unused_imports)]
use cairo_native::executor::AotNativeExecutor;
use starknet_api::core::EntryPointSelector;

use crate::execution::contract_class::{EntryPointsByType, HasSelector};
use crate::execution::contract_class::{ContractClassV1, EntryPointsByType, HasSelector};
use crate::execution::entry_point::CallEntryPoint;
use crate::execution::errors::PreExecutionError;
use crate::execution::native::utils::contract_entrypoint_to_entrypoint_selector;

#[derive(Clone, Debug, PartialEq, Eq)]
pub struct NativeContractClassV1(pub Arc<NativeContractClassV1Inner>);
impl Deref for NativeContractClassV1 {
Expand All @@ -38,8 +36,9 @@ impl NativeContractClassV1 {
pub fn new(
executor: AotNativeExecutor,
sierra_contract_class: SierraContractClass,
casm: ContractClassV1,
) -> NativeContractClassV1 {
let contract = NativeContractClassV1Inner::new(executor, sierra_contract_class);
let contract = NativeContractClassV1Inner::new(executor, sierra_contract_class, casm);

Self(Arc::new(contract))
}
Expand All @@ -54,16 +53,19 @@ impl NativeContractClassV1 {
pub struct NativeContractClassV1Inner {
pub executor: AotNativeExecutor,
entry_points_by_type: EntryPointsByType<NativeEntryPoint>,
// Storing the raw sierra program and entry points to be able to compare the contract class.
sierra_program: Vec<BigUintAsHex>,
casm: ContractClassV1,
}

impl NativeContractClassV1Inner {
fn new(executor: AotNativeExecutor, sierra_contract_class: SierraContractClass) -> Self {
fn new(
executor: AotNativeExecutor,
sierra_contract_class: SierraContractClass,
casm: ContractClassV1,
) -> Self {
NativeContractClassV1Inner {
executor,
entry_points_by_type: EntryPointsByType::from(&sierra_contract_class),
sierra_program: sierra_contract_class.sierra_program,
casm,
}
}
}
Expand All @@ -72,8 +74,7 @@ impl NativeContractClassV1Inner {
// be the same therefore we exclude it from the comparison.
impl PartialEq for NativeContractClassV1Inner {
fn eq(&self, other: &Self) -> bool {
self.entry_points_by_type == other.entry_points_by_type
&& self.sierra_program == other.sierra_program
self.entry_points_by_type == other.entry_points_by_type && self.casm == other.casm
}
}

Expand Down
Loading