@@ -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.
0 commit comments