Skip to content

Commit

Permalink
refactor(blockifier): min compiler version for sierra gas type
Browse files Browse the repository at this point in the history
  • Loading branch information
AvivYossef-starkware committed Dec 3, 2024
1 parent e0a4c01 commit e5d5bca
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
8 changes: 4 additions & 4 deletions crates/blockifier/src/execution/contract_class.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use itertools::Itertools;
use semver::Version;
use serde::de::Error as DeserializationError;
use serde::{Deserialize, Deserializer, Serialize};
use starknet_api::contract_class::{ContractClass, EntryPointType};
use starknet_api::contract_class::{ContractClass, EntryPointType, SierraVersion, VersionedCasm};
use starknet_api::core::EntryPointSelector;
use starknet_api::deprecated_contract_class::{
ContractClass as DeprecatedContractClass,
Expand Down Expand Up @@ -132,7 +132,7 @@ impl RunnableCompiledClass {
/// Returns whether this contract should run using Cairo steps or Sierra gas.
pub fn tracked_resource(
&self,
min_sierra_version: &CompilerVersion,
min_sierra_version: &SierraVersion,
gas_mode: GasVectorComputationMode,
) -> TrackedResource {
match gas_mode {
Expand Down Expand Up @@ -262,8 +262,8 @@ impl CompiledClassV1 {
}

/// Returns whether this contract should run using Cairo steps or Sierra gas.
pub fn tracked_resource(&self, min_sierra_version: &CompilerVersion) -> TrackedResource {
if *min_sierra_version <= self.compiler_version {
pub fn tracked_resource(&self, min_sierra_version: &SierraVersion) -> TrackedResource {
if *min_sierra_version <= self.sierra_version {
TrackedResource::SierraGas
} else {
TrackedResource::CairoSteps
Expand Down
2 changes: 1 addition & 1 deletion crates/blockifier/src/execution/contract_class_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ fn test_get_visited_segments() {
program: Default::default(),
entry_points_by_type: Default::default(),
hints: Default::default(),
compiler_version: Default::default(),
sierra_version: Default::default(),
bytecode_segment_lengths: NestedIntList::Node(vec![
NestedIntList::Leaf(151),
NestedIntList::Leaf(104),
Expand Down
3 changes: 2 additions & 1 deletion crates/blockifier/src/versioned_constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use serde::de::Error as DeserializationError;
use serde::{Deserialize, Deserializer, Serialize};
use serde_json::{Map, Number, Value};
use starknet_api::block::{GasPrice, StarknetVersion};
use starknet_api::contract_class::SierraVersion;
use starknet_api::core::ContractAddress;
use starknet_api::execution_resources::{GasAmount, GasVector};
use starknet_api::transaction::fields::GasVectorComputationMode;
Expand Down Expand Up @@ -183,7 +184,7 @@ pub struct VersionedConstants {
pub max_recursion_depth: usize,
pub validate_max_n_steps: u32,
pub validate_max_sierra_gas: GasAmount,
pub min_compiler_version_for_sierra_gas: CompilerVersion,
pub min_compiler_version_for_sierra_gas: SierraVersion,
// BACKWARD COMPATIBILITY: If true, the segment_arena builtin instance counter will be
// multiplied by 3. This offsets a bug in the old vm where the counter counted the number of
// cells used by instances of the builtin, instead of the number of instances.
Expand Down
2 changes: 1 addition & 1 deletion crates/starknet_api/src/contract_class.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ impl ContractClass {
}
}

#[derive(Deref, Serialize, Deserialize, Clone, Debug, Eq, PartialEq)]
#[derive(Deref, Serialize, Deserialize, Clone, Debug, Eq, PartialEq, PartialOrd)]
pub struct SierraVersion(Version);

impl SierraVersion {
Expand Down

0 comments on commit e5d5bca

Please sign in to comment.