Skip to content

Commit 4e4a022

Browse files
starknet_os: os resources test - add replace_class
1 parent 0e14e52 commit 4e4a022

7 files changed

Lines changed: 10 additions & 7 deletions

File tree

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ const GET_BLOCK_HASH_GAS_COST = 10810;
114114
const GET_CLASS_HASH_AT_GAS_COST = 10000;
115115
const GET_EXECUTION_INFO_GAS_COST = 11240;
116116
const LIBRARY_CALL_GAS_COST = 88660;
117-
const REPLACE_CLASS_GAS_COST = 10670;
117+
const REPLACE_CLASS_GAS_COST = 10000;
118118
// TODO(Yoni, 1/1/2026): take into account Patricia updates and dict squash.
119119
const STORAGE_READ_GAS_COST = 24070;
120120
const STORAGE_WRITE_GAS_COST = 59970;

crates/apollo_starknet_os_program/src/program_hash.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"os": "0x3b23e69c999017f0a08ca8080de329bf80922aaa8bd364f1bf3b5445b38f989",
2+
"os": "0x2f2a3b9083c0d74ac187befa00a61033e46f5b4782c03b87869592babcbe3e9",
33
"virtual_os": "0x4373ade67a35a6ae0466730e5807b828a5db813010d6070bb1db85f99682dcb",
44
"aggregator": "0x700786d51b3854af43d8e12180380bda3029be6c1767e007858de6ca2edac40",
55
"aggregator_with_prefix": "0xe08d300e3f5996e43d6d7cc5a20068e0e58cf1309089f2348317ac580f6c1f"

crates/blockifier/resources/blockifier_versioned_constants_0_14_4.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@
378378
}
379379
},
380380
"ReplaceClass": {
381-
"n_steps": 106,
381+
"n_steps": 92,
382382
"n_memory_holes": 0,
383383
"builtin_instance_counter": {
384384
"range_check_builtin": 1

crates/blockifier/resources/versioned_constants_diff_regression/0.14.3_0.14.4.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@
99
~ /os_resources/execute_syscalls/KeccakRound/n_steps: 223
1010
~ /os_resources/execute_syscalls/LibraryCall/n_steps: 874
1111
~ /os_resources/execute_syscalls/MetaTxV0/constant/n_steps: 1307
12+
~ /os_resources/execute_syscalls/ReplaceClass/n_steps: 92
1213
~ /os_resources/execute_syscalls/Sha256ProcessBlock/n_steps: 1854

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ fn positive_flow(runnable_version: RunnableCairo1) {
8585
l2_to_l1_messages: [],
8686
cairo_native: false,
8787
failed: false,
88-
gas_consumed: 14150,
88+
gas_consumed: 13480,
8989
}
9090
"#]]
9191
.assert_debug_eq(&execution);

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ mod OsResourcesTestContract {
66
use starknet::info::SyscallResultTrait;
77
use starknet::syscalls::{
88
call_contract_syscall, deploy_syscall, emit_event_syscall, get_execution_info_v3_syscall,
9-
keccak_syscall, library_call_syscall, sha256_process_block_syscall,
9+
keccak_syscall, library_call_syscall, replace_class_syscall, sha256_process_block_syscall,
1010
};
1111
use starknet::{ClassHash, ContractAddress, get_block_hash_syscall, get_class_hash_at_syscall};
1212

@@ -122,5 +122,8 @@ mod OsResourcesTestContract {
122122
let mut input = BoxTrait::new([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]);
123123
let mut state = sha256_state_handle_init(BoxTrait::new(SHA256_INITIAL_STATE));
124124
let _ = sha256_process_block_syscall(state, input).unwrap_syscall();
125+
126+
// replace class syscall.
127+
replace_class_syscall(stable_class_hash).unwrap_syscall();
125128
}
126129
}

crates/starknet_os_flow_tests/src/os_resources_test.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ use crate::test_manager::{
4747
use crate::tests::NON_TRIVIAL_RESOURCE_BOUNDS;
4848

4949
// TODO(Dori): Delete this, or at least reduce it to a minimal set of unmeasurable syscalls.
50-
const UNMEASURABLE_SYSCALLS: [Selector; 25] = [
50+
const UNMEASURABLE_SYSCALLS: [Selector; 24] = [
5151
Selector::DelegateCall,
5252
Selector::DelegateL1Handler,
5353
Selector::GetBlockNumber,
@@ -59,7 +59,6 @@ const UNMEASURABLE_SYSCALLS: [Selector; 25] = [
5959
Selector::GetTxSignature,
6060
Selector::Sha512ProcessBlock,
6161
Selector::LibraryCallL1Handler,
62-
Selector::ReplaceClass,
6362
Selector::Secp256k1Add,
6463
Selector::Secp256k1GetPointFromX,
6564
Selector::Secp256k1GetXy,

0 commit comments

Comments
 (0)