@@ -795,6 +795,10 @@ impl SyscallGasCost {
795795 assert ! ( self . linear_factor == 0 , "The syscall has a linear factor cost to be considered." ) ;
796796 self . base
797797 }
798+
799+ pub fn linear_syscall_cost ( & self ) -> u64 {
800+ self . linear_factor
801+ }
798802}
799803
800804#[ cfg_attr( any( test, feature = "testing" ) , derive( Clone ) ) ]
@@ -1072,29 +1076,125 @@ impl GasCosts {
10721076#[ derive( Debug , Default , PartialEq ) ]
10731077pub struct OsConstants {
10741078 pub gas_costs : GasCosts ,
1075- pub validate_rounding_consts : ValidateRoundingConsts ,
1076- pub os_contract_addresses : OsContractAddresses ,
1079+
1080+ // Selectors.
1081+ pub constructor_entry_point_selector : EntryPointSelector ,
1082+ pub default_entry_point_selector : EntryPointSelector ,
1083+ pub execute_entry_point_selector : EntryPointSelector ,
1084+ pub transfer_entry_point_selector : EntryPointSelector ,
1085+ pub validate_declare_entry_point_selector : EntryPointSelector ,
1086+ pub validate_deploy_entry_point_selector : EntryPointSelector ,
1087+ pub validate_entry_point_selector : EntryPointSelector ,
1088+
1089+ // Execution limits.
10771090 pub validate_max_sierra_gas : GasAmount ,
10781091 pub execute_max_sierra_gas : GasAmount ,
1092+
1093+ // Validation.
1094+ pub validate_rounding_consts : ValidateRoundingConsts ,
1095+ pub validated : String ,
1096+
1097+ // Error strings.
1098+ pub error_block_number_out_of_range : String ,
1099+ pub error_invalid_input_len : String ,
1100+ pub error_invalid_argument : String ,
1101+ pub error_out_of_gas : String ,
1102+ pub error_entry_point_failed : String ,
1103+ pub error_entry_point_not_found : String ,
1104+
1105+ // Resource bounds names.
1106+ pub l1_gas : String ,
1107+ pub l2_gas : String ,
1108+ pub l1_data_gas : String ,
1109+
1110+ // Resource bounds indices.
1111+ pub l1_gas_index : usize ,
1112+ pub l1_data_gas_index : usize ,
1113+ pub l2_gas_index : usize ,
1114+
1115+ // Initial costs.
1116+ pub entry_point_initial_budget : GasAmount ,
1117+ pub default_initial_gas_cost : GasAmount ,
1118+
1119+ // L1 handler.
1120+ pub l1_handler_version : u8 ,
1121+ pub l1_handler_max_amount_bounds : GasVector ,
1122+
1123+ // Miscellaneous.
1124+ pub nop_entry_point_offset : i8 ,
1125+ pub os_contract_addresses : OsContractAddresses ,
1126+ pub sierra_array_len_bound : u64 ,
1127+ pub stored_block_hash_buffer : u8 ,
1128+
1129+ // Entry point type identifiers (in the OS).
1130+ pub entry_point_type_constructor : u8 ,
1131+ pub entry_point_type_external : u8 ,
1132+ pub entry_point_type_l1_handler : u8 ,
1133+
1134+ // Deprecated contract logic support.
10791135 pub v1_bound_accounts_cairo0 : Vec < ClassHash > ,
10801136 pub v1_bound_accounts_cairo1 : Vec < ClassHash > ,
10811137 pub v1_bound_accounts_max_tip : Tip ,
1082- pub l1_handler_max_amount_bounds : GasVector ,
10831138 pub data_gas_accounts : Vec < ClassHash > ,
10841139}
10851140
10861141impl OsConstants {
10871142 fn from_raw ( raw_constants : & RawOsConstants , raw_resources : & RawOsResources ) -> Self {
1143+ let gas_costs = GasCosts :: from_raw ( raw_constants, raw_resources) ;
1144+
1145+ // Preprocess inital budget costs.
1146+ let RawStepGasCost { step_gas_cost : entry_point_initial_budget_steps } =
1147+ raw_constants. entry_point_initial_budget ;
1148+ let RawStepGasCost { step_gas_cost : default_initial_gas_cost_steps } =
1149+ raw_constants. default_initial_gas_cost ;
1150+ let entry_point_initial_budget = entry_point_initial_budget_steps
1151+ . checked_factor_mul ( gas_costs. base . step_gas_cost )
1152+ . expect ( "The entry point initial budget - in gas - should not overflow." ) ;
1153+ let default_initial_gas_cost = default_initial_gas_cost_steps
1154+ . checked_factor_mul ( gas_costs. base . step_gas_cost )
1155+ . expect ( "The default initial gas should not overflow." ) ;
1156+
10881157 Self {
1089- gas_costs : GasCosts :: from_raw ( raw_constants, raw_resources) ,
1090- validate_rounding_consts : raw_constants. validate_rounding_consts ,
1091- os_contract_addresses : raw_constants. os_contract_addresses ,
1158+ gas_costs,
1159+ constructor_entry_point_selector : raw_constants. constructor_entry_point_selector ,
1160+ default_entry_point_selector : raw_constants. default_entry_point_selector ,
1161+ execute_entry_point_selector : raw_constants. execute_entry_point_selector ,
1162+ transfer_entry_point_selector : raw_constants. transfer_entry_point_selector ,
1163+ validate_declare_entry_point_selector : raw_constants
1164+ . validate_declare_entry_point_selector ,
1165+ validate_deploy_entry_point_selector : raw_constants
1166+ . validate_deploy_entry_point_selector ,
1167+ validate_entry_point_selector : raw_constants. validate_entry_point_selector ,
10921168 validate_max_sierra_gas : raw_constants. validate_max_sierra_gas ,
10931169 execute_max_sierra_gas : raw_constants. execute_max_sierra_gas ,
1170+ validate_rounding_consts : raw_constants. validate_rounding_consts ,
1171+ validated : raw_constants. validated . clone ( ) ,
1172+ error_block_number_out_of_range : raw_constants. error_block_number_out_of_range . clone ( ) ,
1173+ error_invalid_input_len : raw_constants. error_invalid_input_len . clone ( ) ,
1174+ error_invalid_argument : raw_constants. error_invalid_argument . clone ( ) ,
1175+ error_out_of_gas : raw_constants. error_out_of_gas . clone ( ) ,
1176+ error_entry_point_failed : raw_constants. error_entry_point_failed . clone ( ) ,
1177+ error_entry_point_not_found : raw_constants. error_entry_point_not_found . clone ( ) ,
1178+ l1_gas : raw_constants. l1_gas . clone ( ) ,
1179+ l2_gas : raw_constants. l2_gas . clone ( ) ,
1180+ l1_data_gas : raw_constants. l1_data_gas . clone ( ) ,
1181+ l1_gas_index : raw_constants. l1_gas_index ,
1182+ l1_data_gas_index : raw_constants. l1_data_gas_index ,
1183+ l2_gas_index : raw_constants. l2_gas_index ,
1184+ entry_point_initial_budget,
1185+ default_initial_gas_cost,
1186+ l1_handler_version : raw_constants. l1_handler_version ,
1187+ l1_handler_max_amount_bounds : raw_constants. l1_handler_max_amount_bounds ,
1188+ nop_entry_point_offset : raw_constants. nop_entry_point_offset ,
1189+ os_contract_addresses : raw_constants. os_contract_addresses ,
1190+ sierra_array_len_bound : raw_constants. sierra_array_len_bound ,
1191+ stored_block_hash_buffer : raw_constants. stored_block_hash_buffer ,
1192+ entry_point_type_constructor : raw_constants. entry_point_type_constructor ,
1193+ entry_point_type_external : raw_constants. entry_point_type_external ,
1194+ entry_point_type_l1_handler : raw_constants. entry_point_type_l1_handler ,
10941195 v1_bound_accounts_cairo0 : raw_constants. v1_bound_accounts_cairo0 . clone ( ) ,
10951196 v1_bound_accounts_cairo1 : raw_constants. v1_bound_accounts_cairo1 . clone ( ) ,
10961197 v1_bound_accounts_max_tip : raw_constants. v1_bound_accounts_max_tip ,
1097- l1_handler_max_amount_bounds : raw_constants. l1_handler_max_amount_bounds ,
10981198 data_gas_accounts : raw_constants. data_gas_accounts . clone ( ) ,
10991199 }
11001200 }
0 commit comments