Skip to content

Commit

Permalink
remove limitation from katana too
Browse files Browse the repository at this point in the history
  • Loading branch information
lambda-0x committed May 15, 2024
1 parent 2c7f86f commit 1a54e7c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
5 changes: 2 additions & 3 deletions crates/katana/primitives/src/conversion/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ use crate::class::{
ClassHash, CompiledClassHash, DeprecatedCompiledClass, FlattenedSierraClass,
SierraCompiledClass, SierraProgram,
};
use crate::utils::class::MAX_BYTECODE_SIZE;
use crate::FieldElement;

/// Converts the legacy inner compiled class type [DeprecatedCompiledClass] into its RPC equivalent
Expand Down Expand Up @@ -149,7 +148,7 @@ pub fn flattened_sierra_to_compiled_class(
let entry_points_by_type = class.entry_points_by_type.clone();
let sierra = SierraProgram { program, entry_points_by_type };

let casm = CasmContractClass::from_contract_class(class, true, MAX_BYTECODE_SIZE)?;
let casm = CasmContractClass::from_contract_class(class, true, usize::MAX)?;
let compiled_hash = FieldElement::from_bytes_be(&casm.compiled_class_hash().to_be_bytes())?;

let class = crate::class::CompiledClass::Class(SierraCompiledClass { casm, sierra });
Expand All @@ -161,7 +160,7 @@ pub fn compiled_class_hash_from_flattened_sierra_class(
contract_class: &FlattenedSierraClass,
) -> Result<FieldElement> {
let contract_class = rpc_to_cairo_contract_class(contract_class)?;
let casm = CasmContractClass::from_contract_class(contract_class, true, MAX_BYTECODE_SIZE)?;
let casm = CasmContractClass::from_contract_class(contract_class, true, usize::MAX)?;

Check warning on line 163 in crates/katana/primitives/src/conversion/rpc.rs

View check run for this annotation

Codecov / codecov/patch

crates/katana/primitives/src/conversion/rpc.rs#L163

Added line #L163 was not covered by tests
let compiled_class: CompiledClass = serde_json::from_str(&serde_json::to_string(&casm)?)?;
Ok(compiled_class.class_hash()?)
}
Expand Down
4 changes: 2 additions & 2 deletions crates/katana/primitives/src/utils/class.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use crate::class::{
// We may want to make this configurable.
// We also need this value into `dojo-world`.. which is not ideal as we don't want
// primitives to depend on `dojo-world` or vice-versa.
pub const MAX_BYTECODE_SIZE: usize = 81_290;
// pub const MAX_BYTECODE_SIZE: usize = 81_290;

pub fn parse_compiled_class(artifact: Value) -> Result<CompiledClass> {
if let Ok(class) = parse_compiled_class_v1(artifact.clone()) {
Expand All @@ -29,7 +29,7 @@ pub fn parse_compiled_class_v1(class: Value) -> Result<SierraCompiledClass> {
let entry_points_by_type = class.entry_points_by_type.clone();
let sierra = SierraProgram { program, entry_points_by_type };

let casm = CasmContractClass::from_contract_class(class, true, MAX_BYTECODE_SIZE)?;
let casm = CasmContractClass::from_contract_class(class, true, usize::MAX)?;

Ok(SierraCompiledClass { casm, sierra })
}
Expand Down
3 changes: 1 addition & 2 deletions crates/katana/rpc/rpc/tests/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use anyhow::{anyhow, Result};
use cairo_lang_starknet_classes::casm_contract_class::CasmContractClass;
use cairo_lang_starknet_classes::contract_class::ContractClass;
use katana_primitives::conversion::rpc::CompiledClass;
use katana_primitives::utils::class::MAX_BYTECODE_SIZE;
use starknet::accounts::Call;
use starknet::core::types::contract::SierraClass;
use starknet::core::types::{FieldElement, FlattenedSierraClass};
Expand All @@ -31,7 +30,7 @@ fn get_compiled_class_hash(artifact_path: &PathBuf) -> Result<FieldElement> {
let file = File::open(artifact_path)?;
let casm_contract_class: ContractClass = serde_json::from_reader(file)?;
let casm_contract =
CasmContractClass::from_contract_class(casm_contract_class, true, MAX_BYTECODE_SIZE)
CasmContractClass::from_contract_class(casm_contract_class, true, usize::MAX)
.map_err(|e| anyhow!("CasmContractClass from ContractClass error: {e}"))?;
let res = serde_json::to_string_pretty(&casm_contract)?;
let compiled_class: CompiledClass = serde_json::from_str(&res)?;
Expand Down

0 comments on commit 1a54e7c

Please sign in to comment.