Skip to content

Commit 479fd39

Browse files
apollo_starknet_os_program: move block preprocess to a function (#10673)
1 parent 9bda23d commit 479fd39

File tree

2 files changed

+22
-15
lines changed

2 files changed

+22
-15
lines changed

crates/apollo_starknet_os_program/src/cairo/starkware/starknet/core/os/os.cairo

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -265,20 +265,8 @@ func execute_blocks{
265265
// Build block context.
266266
let (block_context: BlockContext*) = get_block_context(os_global_context=os_global_context);
267267

268-
// Pre-process block.
269-
with contract_state_changes {
270-
write_block_number_to_block_hash_mapping(block_context=block_context);
271-
}
272-
273-
// Update the contract class changes according to the migration.
274-
275-
local n_classes_to_migrate;
276-
// TODO(Meshi): Change to rust VM notion once all python tests only uses the rust VM.
277-
%{ ids.n_classes_to_migrate = len(block_input.class_hashes_to_migrate) %}
278-
with contract_class_changes {
279-
migrate_classes_to_v2_casm_hash(
280-
n_classes=n_classes_to_migrate, block_context=block_context
281-
);
268+
with contract_state_changes, contract_class_changes {
269+
pre_process_block(block_context=block_context);
282270
}
283271

284272
// Execute transactions.
@@ -457,6 +445,25 @@ func migrate_classes_to_v2_casm_hash{
457445
return ();
458446
}
459447

448+
// Pre-processes the block.
449+
func pre_process_block{
450+
range_check_ptr,
451+
poseidon_ptr: PoseidonBuiltin*,
452+
contract_state_changes: DictAccess*,
453+
contract_class_changes: DictAccess*,
454+
}(block_context: BlockContext*) {
455+
alloc_locals;
456+
457+
write_block_number_to_block_hash_mapping(block_context=block_context);
458+
459+
// Update the contract class changes according to the migration.
460+
local n_classes_to_migrate;
461+
// TODO(Meshi): Change to rust VM notion once all python tests only uses the rust VM.
462+
%{ ids.n_classes_to_migrate = len(block_input.class_hashes_to_migrate) %}
463+
migrate_classes_to_v2_casm_hash(n_classes=n_classes_to_migrate, block_context=block_context);
464+
return ();
465+
}
466+
460467
// Returns an OsGlobalContext instance.
461468
//
462469
// Note: the compiled class facts are guessed here, and must be validated post-execution.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"os": "0x4a1b49d0eee46b874765afb8b4eb20f83604c98588a9076f1e6e54ee63a1c4a",
2+
"os": "0x49bd34ac72e2a7287a8acd58abc80f0fd200b15fc98b87a083b34132e9ac4e6",
33
"aggregator": "0x48f2eacd9ca42f9ec5ed541c48c5b4450abee50df44e9cbb5ebf7f61e87d0cc",
44
"aggregator_with_prefix": "0x683eebd5b16190d5f9c73cc8b17d1498172494fa7d7bd0dc889378e01f15a98"
55
}

0 commit comments

Comments
 (0)