Skip to content

Commit 9174010

Browse files
starknet_os: os resources test - library call (#14129)
1 parent 617731b commit 9174010

7 files changed

Lines changed: 23 additions & 17 deletions

File tree

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ const ALLOWED_VIRTUAL_OS_PROGRAM_HASHES_1 = (
7272
0x06ecb73d21c7d98ddd4148f5bcd91cc2747c65364245fbf32a63b05cca1685c2
7373
);
7474
const ALLOWED_VIRTUAL_OS_PROGRAM_HASHES_2 = (
75-
0x059a0052ae80a978ca71126c9774a17c67c19f79b14bb9d1ea96fb77dc6032d8
75+
0x028619dbc9767792fb536aaba7a2d55f70faadf808c95ec66b956d33fdee1bc0
7676
);
7777
const ALLOWED_VIRTUAL_OS_PROGRAM_HASHES_LEN = 3;
7878

@@ -113,7 +113,7 @@ const DEPLOY_CALLDATA_FACTOR_GAS_COST = 4850;
113113
const GET_BLOCK_HASH_GAS_COST = 10840;
114114
const GET_CLASS_HASH_AT_GAS_COST = 10000;
115115
const GET_EXECUTION_INFO_GAS_COST = 12640;
116-
const LIBRARY_CALL_GAS_COST = 89160;
116+
const LIBRARY_CALL_GAS_COST = 88660;
117117
const REPLACE_CLASS_GAS_COST = 10670;
118118
// TODO(Yoni, 1/1/2026): take into account Patricia updates and dict squash.
119119
const STORAGE_READ_GAS_COST = 24070;
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"os": "0x47f5b47e73f1736037ea946704c57d9072f26d12beee01a55d947d87f779436",
3-
"virtual_os": "0x59a0052ae80a978ca71126c9774a17c67c19f79b14bb9d1ea96fb77dc6032d8",
2+
"os": "0x7b762f60dc1f9ecb199322522749de4e926c1eee33454764ae8974744ef0c5a",
3+
"virtual_os": "0x28619dbc9767792fb536aaba7a2d55f70faadf808c95ec66b956d33fdee1bc0",
44
"aggregator": "0x700786d51b3854af43d8e12180380bda3029be6c1767e007858de6ca2edac40",
55
"aggregator_with_prefix": "0xe08d300e3f5996e43d6d7cc5a20068e0e58cf1309089f2348317ac580f6c1f"
66
}

crates/blockifier/resources/blockifier_versioned_constants_0_14_4.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@
128128
"allowed_virtual_os_program_hashes": [
129129
"0x3e98c2d7703b03a7edb73ed7f075f97f1dcbaa8f717cdf6e1a57bf058265473",
130130
"0x6ecb73d21c7d98ddd4148f5bcd91cc2747c65364245fbf32a63b05cca1685c2",
131-
"0x59a0052ae80a978ca71126c9774a17c67c19f79b14bb9d1ea96fb77dc6032d8"
131+
"0x28619dbc9767792fb536aaba7a2d55f70faadf808c95ec66b956d33fdee1bc0"
132132
],
133133
"constructor_entry_point_selector": "0x28ffe4ff0f226a9107253e17a904099aa4f63a02a5621de0576e5aa71bc5194",
134134
"default_entry_point_selector": "0x0",
@@ -346,7 +346,7 @@
346346
}
347347
},
348348
"LibraryCall": {
349-
"n_steps": 879,
349+
"n_steps": 874,
350350
"n_memory_holes": 0,
351351
"builtin_instance_counter": {
352352
"range_check_builtin": 18
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
+ /os_constants/allowed_virtual_os_program_hashes/2: "0x59a0052ae80a978ca71126c9774a17c67c19f79b14bb9d1ea96fb77dc6032d8"
1+
+ /os_constants/allowed_virtual_os_program_hashes/2: "0x28619dbc9767792fb536aaba7a2d55f70faadf808c95ec66b956d33fdee1bc0"
22
~ /os_resources/execute_syscalls/CallContract/n_steps: 901
3+
~ /os_resources/execute_syscalls/LibraryCall/n_steps: 874

crates/blockifier/src/execution/syscalls/syscall_tests/library_call.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ fn test_library_call(runnable_version: RunnableCairo1) {
6464
l2_to_l1_messages: [],
6565
cairo_native: false,
6666
failed: false,
67-
gas_consumed: 189170,
67+
gas_consumed: 188670,
6868
}
6969
"#]]
7070
.assert_debug_eq(&execution);
@@ -108,7 +108,7 @@ fn test_library_call_assert_fails(runnable_version: RunnableCairo1) {
108108
l2_to_l1_messages: [],
109109
cairo_native: false,
110110
failed: true,
111-
gas_consumed: 109750,
111+
gas_consumed: 109250,
112112
}
113113
"#]]
114114
.assert_debug_eq(&call_info.execution);
@@ -153,7 +153,7 @@ fn test_nested_library_call(runnable_version: RunnableCairo1) {
153153
..trivial_external_entry_point_new(test_contract)
154154
};
155155
let expected_nested_initial_gas = expect![[r#"
156-
9999085250
156+
9999086250
157157
"#]];
158158
let nested_storage_entry_point = CallEntryPoint {
159159
entry_point_selector: inner_entry_point_selector,
@@ -165,7 +165,7 @@ fn test_nested_library_call(runnable_version: RunnableCairo1) {
165165
..trivial_external_entry_point_new(test_contract)
166166
};
167167
let expected_library_initial_gas = expect![[r#"
168-
9999185000
168+
9999185500
169169
"#]];
170170
let library_entry_point = CallEntryPoint {
171171
entry_point_selector: outer_entry_point_selector,
@@ -183,7 +183,7 @@ fn test_nested_library_call(runnable_version: RunnableCairo1) {
183183
..trivial_external_entry_point_new(test_contract)
184184
};
185185
let expected_storage_initial_gas = expect![[r#"
186-
9998916670
186+
9998918170
187187
"#]];
188188
let storage_entry_point = CallEntryPoint {
189189
calldata: calldata![felt!(key), felt!(value)],
@@ -223,7 +223,7 @@ fn test_nested_library_call(runnable_version: RunnableCairo1) {
223223
};
224224

225225
let expected_library_call_gas_consumed = expect![[r#"
226-
189170
226+
188670
227227
"#]];
228228
let library_call_info = CallInfo {
229229
call: library_entry_point,
@@ -269,7 +269,7 @@ fn test_nested_library_call(runnable_version: RunnableCairo1) {
269269
};
270270

271271
let expected_main_gas_consumed = expect![[r#"
272-
465190
272+
463690
273273
"#]];
274274
let expected_call_info = CallInfo {
275275
call: main_entry_point.clone(),

crates/blockifier_test_utils/resources/feature_contracts/cairo1/os_resources_test_contract.cairo

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#[starknet::contract(account)]
33
mod OsResourcesTestContract {
44
use starknet::info::SyscallResultTrait;
5-
use starknet::syscalls::call_contract_syscall;
5+
use starknet::syscalls::{call_contract_syscall, library_call_syscall};
66
use starknet::{ClassHash, ContractAddress};
77

88
const STABLE_EXTERNAL_ENTRY_POINT_SELECTOR: felt252 = selector!("external");
@@ -34,5 +34,11 @@ mod OsResourcesTestContract {
3434
stable_address, STABLE_EXTERNAL_ENTRY_POINT_SELECTOR, array![0].span(),
3535
)
3636
.unwrap_syscall();
37+
38+
// library_call syscall — calls empty_function on stable class hash.
39+
library_call_syscall(
40+
stable_class_hash, STABLE_EXTERNAL_ENTRY_POINT_SELECTOR, array![0].span(),
41+
)
42+
.unwrap_syscall();
3743
}
3844
}

crates/starknet_os_flow_tests/src/os_resources_test.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ use crate::test_manager::{TestBuilder, TestBuilderConfig, FUNDED_ACCOUNT_ADDRESS
3636
use crate::tests::NON_TRIVIAL_RESOURCE_BOUNDS;
3737

3838
// TODO(Dori): Delete this, or at least reduce it to a minimal set of unmeasurable syscalls.
39-
const UNMEASURABLE_SYSCALLS: [Selector; 35] = [
39+
const UNMEASURABLE_SYSCALLS: [Selector; 34] = [
4040
Selector::DelegateCall,
4141
Selector::DelegateL1Handler,
4242
Selector::Deploy,
@@ -55,7 +55,6 @@ const UNMEASURABLE_SYSCALLS: [Selector; 35] = [
5555
Selector::KeccakRound,
5656
Selector::Sha256ProcessBlock,
5757
Selector::Sha512ProcessBlock,
58-
Selector::LibraryCall,
5958
Selector::LibraryCallL1Handler,
6059
Selector::MetaTxV0,
6160
Selector::ReplaceClass,

0 commit comments

Comments
 (0)