@@ -127,6 +127,8 @@ use crate::hints::hint_implementation::kzg::implementation::store_da_segment;
127
127
use crate :: hints:: hint_implementation:: math:: log2_ceil;
128
128
use crate :: hints:: hint_implementation:: os:: {
129
129
configure_kzg_manager,
130
+ create_block_additional_hints,
131
+ get_n_blocks,
130
132
init_state_update_pointer,
131
133
initialize_class_hashes,
132
134
initialize_state_changes,
@@ -399,15 +401,17 @@ define_hint_enum!(
399
401
block_timestamp,
400
402
"memory[ap] = to_felt_or_relocatable(syscall_handler.block_info.block_timestamp)"
401
403
) ,
404
+ // TODO(Meshi): Fix hint implantation.
402
405
(
403
406
ChainId ,
404
407
chain_id,
405
- "memory[ap] = to_felt_or_relocatable(os_input .general_config.chain_id.value)"
408
+ "memory[ap] = to_felt_or_relocatable(block_input .general_config.chain_id.value)"
406
409
) ,
410
+ // TODO(Meshi): Fix hint implantation.
407
411
(
408
412
FeeTokenAddress ,
409
413
fee_token_address,
410
- "memory[ap] = to_felt_or_relocatable(os_input .general_config.fee_token_address)"
414
+ "memory[ap] = to_felt_or_relocatable(block_input .general_config.fee_token_address)"
411
415
) ,
412
416
(
413
417
SequencerAddress ,
@@ -431,13 +435,13 @@ define_hint_enum!(
431
435
)
432
436
ids.is_leaf = 1 if isinstance(bytecode_segment_structure, BytecodeLeaf) else 0"# }
433
437
) ,
438
+ // TODO(Meshi): Fix hint implantation.
434
439
(
435
440
WriteUseKzgDaToMemory ,
436
441
write_use_kzg_da_to_memory,
437
- indoc! { r#"
438
- memory[fp + 18] = to_felt_or_relocatable(syscall_handler.block_info.use_kzg_da and (
439
- not os_input.full_output
440
- ))"# }
442
+ indoc! { r#"memory[fp + 19] = to_felt_or_relocatable(syscall_handler.block_info.use_kzg_da and (
443
+ not block_input.full_output
444
+ ))"# }
441
445
) ,
442
446
(
443
447
ComputeIdsLow ,
@@ -578,6 +582,7 @@ define_hint_enum!(
578
582
"is_segment_used_callback": bytecode_segment_access_oracle.is_segment_used
579
583
})"# }
580
584
) ,
585
+ // TODO(Meshi): Fix hint implantation.
581
586
(
582
587
EnterScopeWithAliases ,
583
588
enter_scope_with_aliases,
@@ -589,7 +594,7 @@ vm_enter_scope(dict(
589
594
aliases=execution_helper.storage_by_address[ALIAS_CONTRACT_ADDRESS],
590
595
execution_helper=execution_helper,
591
596
__dict_manager=__dict_manager,
592
- os_input=os_input ,
597
+ block_input=block_input ,
593
598
))"# }
594
599
) ,
595
600
(
@@ -765,14 +770,15 @@ else:
765
770
(
766
771
SegmentsAddTemp ,
767
772
segments_add_temp,
768
- indoc! { r#"memory[fp + 6 ] = to_felt_or_relocatable(segments.add_temp_segment())"#
773
+ indoc! { r#"memory[fp + 7 ] = to_felt_or_relocatable(segments.add_temp_segment())"#
769
774
}
770
775
) ,
771
776
( StartTx , start_tx, indoc! { r#"execution_helper.start_tx()"# } ) ,
777
+ // TODO(Meshi): Fix hint implantation.
772
778
(
773
779
OsInputTransactions ,
774
780
os_input_transactions,
775
- indoc! { r#"memory[fp + 12] = to_felt_or_relocatable(len(os_input .transactions))"#
781
+ indoc! { r#"memory[fp + 12] = to_felt_or_relocatable(len(block_input .transactions))"#
776
782
}
777
783
) ,
778
784
(
@@ -966,13 +972,14 @@ segments.write_arg(ids.sha256_ptr_end, padding)"#}
966
972
"is_deprecated = 1 if ids.execution_context.class_hash in __deprecated_class_hashes else 0"
967
973
) ,
968
974
( IsDeprecated , is_deprecated, "memory[ap] = to_felt_or_relocatable(is_deprecated)" ) ,
975
+ // TODO(Meshi): Fix hint implantation.
969
976
(
970
977
EnterSyscallScopes ,
971
978
enter_syscall_scopes,
972
979
indoc! { r#"vm_enter_scope({
973
980
'__deprecated_class_hashes': __deprecated_class_hashes,
974
- 'transactions': iter(os_input .transactions),
975
- 'component_hashes': os_input .declared_class_hash_to_component_hashes,
981
+ 'transactions': iter(block_input .transactions),
982
+ 'component_hashes': block_input .declared_class_hash_to_component_hashes,
976
983
'execution_helper': execution_helper,
977
984
'deprecated_syscall_handler': deprecated_syscall_handler,
978
985
'syscall_handler': syscall_handler,
@@ -1269,11 +1276,12 @@ segments.write_arg(ids.sha256_ptr_end, padding)"#}
1269
1276
assert ids.value == value, "Inconsistent storage value.""#
1270
1277
}
1271
1278
) ,
1279
+ // TODO(Meshi): Fix hint implantation.
1272
1280
(
1273
1281
GetOldBlockNumberAndHash ,
1274
1282
get_old_block_number_and_hash,
1275
1283
indoc! { r#"
1276
- old_block_number_and_hash = program_input[' old_block_number_and_hash']
1284
+ old_block_number_and_hash = block_input. old_block_number_and_hash
1277
1285
assert (
1278
1286
old_block_number_and_hash is not None
1279
1287
), f"Block number is probably < {ids.STORED_BLOCK_HASH_BUFFER}."
@@ -1324,6 +1332,12 @@ segments.write_arg(ids.sha256_ptr_end, padding)"#}
1324
1332
ids.index = n_elms
1325
1333
ids.exists = 0"# }
1326
1334
) ,
1335
+ // TODO(Meshi): Fix hint implantation.
1336
+ (
1337
+ GetBlocksNumber ,
1338
+ get_n_blocks,
1339
+ r#"memory[fp + 0] = to_felt_or_relocatable(len(os_input.block_inputs))"#
1340
+ ) ,
1327
1341
(
1328
1342
StoreDaSegment ,
1329
1343
store_da_segment,
@@ -1352,26 +1366,29 @@ segments.write_arg(ids.sha256_ptr_end, padding)"#}
1352
1366
ids.res = log2_ceil(ids.value)"#
1353
1367
}
1354
1368
) ,
1369
+ // TODO(Meshi): Fix hint implantation.
1355
1370
(
1356
1371
WriteFullOutputToMemory ,
1357
1372
write_full_output_to_memory,
1358
- indoc! { r#"memory[fp + 19 ] = to_felt_or_relocatable(os_input .full_output)"# }
1373
+ indoc! { r#"memory[fp + 20 ] = to_felt_or_relocatable(block_input .full_output)"# }
1359
1374
) ,
1360
1375
(
1361
1376
ConfigureKzgManager ,
1362
1377
configure_kzg_manager,
1363
1378
indoc! { r#"__serialize_data_availability_create_pages__ = True
1364
- kzg_manager = execution_helper .kzg_manager"# }
1379
+ kzg_manager = global_hints .kzg_manager"# }
1365
1380
) ,
1381
+ // TODO(Meshi): Fix hint implantation.
1366
1382
(
1367
1383
SetApToPrevBlockHash ,
1368
1384
set_ap_to_prev_block_hash,
1369
- indoc! { r#"memory[ap] = to_felt_or_relocatable(os_input .prev_block_hash)"# }
1385
+ indoc! { r#"memory[ap] = to_felt_or_relocatable(block_input .prev_block_hash)"# }
1370
1386
) ,
1387
+ // TODO(Meshi): Fix hint implantation.
1371
1388
(
1372
1389
SetApToNewBlockHash ,
1373
1390
set_ap_to_new_block_hash,
1374
- "memory[ap] = to_felt_or_relocatable(os_input .new_block_hash)"
1391
+ "memory[ap] = to_felt_or_relocatable(block_input .new_block_hash)"
1375
1392
) ,
1376
1393
(
1377
1394
SetTreeStructure ,
@@ -1538,44 +1555,45 @@ else:
1538
1555
read_ec_point_from_address,
1539
1556
r#"memory[ap] = to_felt_or_relocatable(ids.response.ec_point.address_ if ids.not_on_curve == 0 else segments.add())"#
1540
1557
) ,
1558
+ // TODO(Meshi): Fix hint implantation.
1541
1559
(
1542
1560
SetPreimageForStateCommitments ,
1543
1561
set_preimage_for_state_commitments,
1544
- indoc! { r#"
1545
- ids.initial_root = os_input .contract_state_commitment_info.previous_root
1546
- ids.final_root = os_input .contract_state_commitment_info.updated_root
1547
- preimage = {
1548
- int(root): children
1549
- for root, children in os_input.contract_state_commitment_info. commitment_facts.items()
1550
- }
1551
- assert os_input .contract_state_commitment_info.tree_height == ids.MERKLE_HEIGHT"#
1562
+ indoc! { r#"ids.initial_root = block_input.contract_state_commitment_info.previous_root
1563
+ ids.final_root = block_input .contract_state_commitment_info.updated_root
1564
+ commitment_facts = block_input .contract_state_commitment_info.commitment_facts.items()
1565
+ preimage = {
1566
+ int(root): children
1567
+ for root, children in commitment_facts
1568
+ }
1569
+ assert block_input .contract_state_commitment_info.tree_height == ids.MERKLE_HEIGHT"#
1552
1570
}
1553
1571
) ,
1572
+ // TODO(Meshi): Fix hint implantation.
1554
1573
(
1555
1574
SetPreimageForClassCommitments ,
1556
1575
set_preimage_for_class_commitments,
1557
- indoc! { r#"
1558
- ids.initial_root = os_input .contract_class_commitment_info.previous_root
1559
- ids.final_root = os_input .contract_class_commitment_info.updated_root
1560
- preimage = {
1561
- int(root): children
1562
- for root, children in os_input.contract_class_commitment_info. commitment_facts.items()
1563
- }
1564
- assert os_input .contract_class_commitment_info.tree_height == ids.MERKLE_HEIGHT"#
1576
+ indoc! { r#"ids.initial_root = block_input.contract_class_commitment_info.previous_root
1577
+ ids.final_root = block_input .contract_class_commitment_info.updated_root
1578
+ commitment_facts = block_input .contract_class_commitment_info.commitment_facts.items()
1579
+ preimage = {
1580
+ int(root): children
1581
+ for root, children in commitment_facts
1582
+ }
1583
+ assert block_input .contract_class_commitment_info.tree_height == ids.MERKLE_HEIGHT"#
1565
1584
}
1566
1585
) ,
1567
1586
(
1568
1587
SetPreimageForCurrentCommitmentInfo ,
1569
1588
set_preimage_for_current_commitment_info,
1570
- indoc! { r#"
1571
- commitment_info = commitment_info_by_address[ids.contract_address]
1572
- ids.initial_contract_state_root = commitment_info.previous_root
1573
- ids.final_contract_state_root = commitment_info.updated_root
1574
- preimage = {
1575
- int(root): children
1576
- for root, children in commitment_info.commitment_facts.items()
1577
- }
1578
- assert commitment_info.tree_height == ids.MERKLE_HEIGHT"#
1589
+ indoc! { r#"ids.initial_contract_state_root = commitment_info.previous_root
1590
+ ids.final_contract_state_root = commitment_info.updated_root
1591
+ commitment_info = commitment_info_by_address[ids.contract_address]
1592
+ preimage = {
1593
+ int(root): children
1594
+ for root, children in commitment_info.commitment_facts.items()
1595
+ }
1596
+ assert commitment_info.tree_height == ids.MERKLE_HEIGHT"#
1579
1597
}
1580
1598
) ,
1581
1599
(
@@ -1661,22 +1679,14 @@ memory[ap] = 1 if case != 'both' else 0"#
1661
1679
) ,
1662
1680
( OsLoggerExitSyscall , os_logger_exit_syscall, "exit_syscall()" ) ,
1663
1681
( IsOnCurve , is_on_curve, "ids.is_on_curve = (y * y) % SECP_P == y_square_int" ) ,
1682
+ // TODO(Meshi): Fix hint implantation.
1664
1683
(
1665
1684
StarknetOsInput ,
1666
1685
starknet_os_input,
1667
- indoc! { r#"
1668
- from starkware.starknet.core.os.os_hints import get_execution_helper_and_syscall_handlers
1669
- from starkware.starknet.core.os.os_input import StarknetOsInput
1670
-
1671
- os_input = StarknetOsInput.load(data=program_input)
1686
+ indoc! { r#"from starkware.starknet.core.os.os_input import StarknetOsInput
1672
1687
1673
- (
1674
- execution_helper,
1675
- syscall_handler,
1676
- deprecated_syscall_handler
1677
- ) = get_execution_helper_and_syscall_handlers(
1678
- os_input=os_input, global_hints=global_hints
1679
- )"#
1688
+ os_input = StarknetOsInput.load(data=program_input)
1689
+ block_input_iterator = iter(os_input.block_inputs)"#
1680
1690
}
1681
1691
) ,
1682
1692
(
@@ -1689,20 +1699,33 @@ memory[ap] = 1 if case != 'both' else 0"#
1689
1699
(
1690
1700
InitializeStateChanges ,
1691
1701
initialize_state_changes,
1692
- indoc! { r#"
1693
- from starkware.python.utils import from_bytes
1702
+ indoc! { r#"from starkware.python.utils import from_bytes
1694
1703
1695
- initial_dict = {
1696
- address: segments.gen_arg(
1697
- (from_bytes(contract.contract_hash), segments.add(), contract.nonce))
1698
- for address, contract in os_input .contracts.items()
1699
- }"#
1704
+ initial_dict = {
1705
+ address: segments.gen_arg(
1706
+ (from_bytes(contract.contract_hash), segments.add(), contract.nonce))
1707
+ for address, contract in block_input .contracts.items()
1708
+ }"#
1700
1709
}
1701
1710
) ,
1711
+ // TODO(Meshi): Fix hint implantation.
1702
1712
(
1703
1713
InitializeClassHashes ,
1704
1714
initialize_class_hashes,
1705
- "initial_dict = os_input.class_hash_to_compiled_class_hash"
1715
+ "initial_dict = block_input.class_hash_to_compiled_class_hash"
1716
+ ) ,
1717
+ (
1718
+ CreateBlockAdditionalHints ,
1719
+ create_block_additional_hints,
1720
+ indoc! { r#"from starkware.starknet.core.os.os_hints import get_execution_helper_and_syscall_handlers
1721
+ block_input = next(block_input_iterator)
1722
+ (
1723
+ execution_helper,
1724
+ syscall_handler,
1725
+ deprecated_syscall_handler
1726
+ ) = get_execution_helper_and_syscall_handlers(
1727
+ block_input=block_input, global_hints=global_hints
1728
+ )"# }
1706
1729
)
1707
1730
) ;
1708
1731
0 commit comments