Skip to content

Commit 737666a

Browse files
fix(starknet_os): allign memory allocation order with python (#6379)
1 parent 40423e0 commit 737666a

1 file changed

Lines changed: 12 additions & 14 deletions

File tree

  • crates/starknet_os/src/hints/hint_implementation/compiled_class

crates/starknet_os/src/hints/hint_implementation/compiled_class/utils.rs

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::collections::HashMap;
33

44
use cairo_lang_starknet_classes::casm_contract_class::{CasmContractClass, CasmContractEntryPoint};
55
use cairo_lang_starknet_classes::NestedIntList;
6-
use cairo_vm::types::relocatable::{MaybeRelocatable, Relocatable};
6+
use cairo_vm::types::relocatable::Relocatable;
77
use cairo_vm::vm::vm_core::VirtualMachine;
88
use starknet_api::core::ClassHash;
99
use starknet_api::hash::PoseidonHash;
@@ -77,6 +77,16 @@ impl<IG: IdentifierGetter> LoadCairoObject<IG> for CasmContractClass {
7777
) -> VmUtilsResult<()> {
7878
// Insert compiled class version field.
7979
let compiled_class_version = Const::CompiledClassVersion.fetch(constants)?;
80+
81+
// Insert external entry points.
82+
let externals_list_base = vm.add_memory_segment();
83+
self.entry_points_by_type.external.load_into(
84+
vm,
85+
identifier_getter,
86+
externals_list_base,
87+
constants,
88+
)?;
89+
8090
// Insert l1 handler entry points.
8191
let l1_handlers_list_base = vm.add_memory_segment();
8292
self.entry_points_by_type.l1_handler.load_into(
@@ -95,21 +105,9 @@ impl<IG: IdentifierGetter> LoadCairoObject<IG> for CasmContractClass {
95105
constants,
96106
)?;
97107

98-
// Insert external entry points.
99-
let externals_list_base = vm.add_memory_segment();
100-
self.entry_points_by_type.external.load_into(
101-
vm,
102-
identifier_getter,
103-
externals_list_base,
104-
constants,
105-
)?;
106-
107108
// Insert the bytecode entirely.
108109
let bytecode_base = vm.add_memory_segment();
109-
// TODO(Nimrod): See if we can transfer ownership here instead of cloning.
110-
111-
let bytecode: Vec<_> =
112-
self.bytecode.iter().map(|x| MaybeRelocatable::from(Felt::from(&x.value))).collect();
110+
let bytecode: Vec<_> = self.bytecode.iter().map(|x| Felt::from(&x.value).into()).collect();
113111
vm.load_data(bytecode_base, &bytecode)?;
114112

115113
// Insert the fields.

0 commit comments

Comments
 (0)