Skip to content

Commit a5c1ecf

Browse files
starknet_os: remove public key hash and add public key to os hints config
1 parent 45c0a8f commit a5c1ecf

File tree

9 files changed

+16
-42
lines changed

9 files changed

+16
-42
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ func get_block_context{range_check_ptr}(
5757
execute_syscalls_ptr: felt*,
5858
execute_deprecated_syscalls_ptr: felt*,
5959
compiled_class_facts_bundle: CompiledClassFactsBundle*,
60+
public_key_hash: felt,
6061
) -> (block_context: BlockContext*) {
6162
alloc_locals;
6263
let (builtin_params) = get_builtin_params();
@@ -87,7 +88,7 @@ func get_block_context{range_check_ptr}(
8788
starknet_os_config=StarknetOsConfig(
8889
chain_id=nondet %{ os_hints_config.starknet_os_config.chain_id %},
8990
fee_token_address=nondet %{ os_hints_config.starknet_os_config.fee_token_address %},
90-
public_key_hash=nondet %{ os_hints_config.starknet_os_config.public_key_hash %},
91+
public_key_hash=public_key_hash,
9192
),
9293
execute_syscalls_ptr=execute_syscalls_ptr,
9394
execute_deprecated_syscalls_ptr=execute_deprecated_syscalls_ptr,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,7 @@ func execute_blocks{
284284
execute_syscalls_ptr=execute_syscalls_ptr,
285285
execute_deprecated_syscalls_ptr=execute_deprecated_syscalls_ptr,
286286
compiled_class_facts_bundle=compiled_class_facts_bundle,
287+
public_key_hash=public_key_hash,
287288
);
288289

289290
// Pre-process block.
@@ -343,7 +344,6 @@ func execute_blocks{
343344
}
344345

345346
let pedersen_ptr = hash_ptr;
346-
assert public_key_hash = block_context.starknet_os_config.public_key_hash;
347347

348348
// All blocks inside of a multi block should be off-chain and therefore
349349
// should not be compressed.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"os": "0x755f467f5f44c7b656ce24695938d8b0e7529d85074a67395bf55bd3b7037c5",
2+
"os": "0x5945b60fb72e40cab6ebfd9cf7dd9e71276d706eeadc09004c3d7b5f1c574f2",
33
"aggregator": "0x36894c1d2bdad67c9c924a4f0e13b795d2e529e0a53ffefad847749cd082216",
44
"aggregator_with_prefix": "0x61fcd2f0365f1238d264da99f0ac264a6b7f7e1932eee061bb2977a0b74b1fc"
55
}

crates/starknet_os/src/hint_processor/snos_hint_processor.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,6 @@ pub struct SnosHintProcessor<'a, S: StateReader> {
137137
da_segment: Option<Vec<Felt>>,
138138
// Indicates wether to create pages or not when serializing data-availability.
139139
pub(crate) serialize_data_availability_create_pages: bool,
140-
pub(crate) public_key_x: Felt,
141-
pub(crate) public_key_y: Felt,
142140
// For testing, track hint coverage.
143141
#[cfg(any(test, feature = "testing"))]
144142
pub unused_hints: HashSet<AllHints>,
@@ -154,8 +152,6 @@ impl<'a, S: StateReader> SnosHintProcessor<'a, S> {
154152
deprecated_compiled_classes: BTreeMap<CompiledClassHash, ContractClass>,
155153
compiled_classes: BTreeMap<CompiledClassHash, CasmContractClass>,
156154
state_readers: Vec<S>,
157-
public_key_x: Felt,
158-
public_key_y: Felt,
159155
) -> Result<Self, StarknetOsError> {
160156
if state_readers.len() != os_block_inputs.len() {
161157
return Err(OsInputError::InvalidLengthOfStateReaders(
@@ -189,8 +185,6 @@ impl<'a, S: StateReader> SnosHintProcessor<'a, S> {
189185
state_update_pointers: None,
190186
commitment_type: CommitmentType::State,
191187
serialize_data_availability_create_pages: false,
192-
public_key_x,
193-
public_key_y,
194188
#[cfg(any(test, feature = "testing"))]
195189
unused_hints: AllHints::all_iter().collect(),
196190
})
@@ -355,8 +349,6 @@ impl<'a> SnosHintProcessor<'a, DictStateReader> {
355349
BTreeMap::new(),
356350
BTreeMap::new(),
357351
vec![state_reader],
358-
Felt::from(0),
359-
Felt::from(0),
360352
)?;
361353
hint_processor.execution_helpers_manager.increment_current_helper_index();
362354
Ok(hint_processor)

crates/starknet_os/src/hints/enum_definition.rs

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ use crate::hints::hint_implementation::block_context::{
3535
chain_id,
3636
fee_token_address,
3737
get_block_mapping,
38-
public_key_hash,
3938
sequencer_address,
4039
write_use_kzg_da_to_memory,
4140
};
@@ -141,8 +140,8 @@ use crate::hints::hint_implementation::os::{
141140
create_block_additional_hints,
142141
get_n_blocks,
143142
get_n_class_hashes_to_migrate,
144-
get_public_key_x_from_os_input,
145-
get_public_key_y_from_os_input,
143+
get_public_key_x_in_os,
144+
get_public_key_y_in_os,
146145
init_state_update_pointer,
147146
initialize_class_hashes,
148147
initialize_state_changes,
@@ -1086,11 +1085,6 @@ define_hint_enum!(
10861085
fee_token_address,
10871086
"memory[ap] = to_felt_or_relocatable(os_hints_config.starknet_os_config.fee_token_address)"
10881087
),
1089-
(
1090-
PublicKeyHash,
1091-
public_key_hash,
1092-
"memory[ap] = to_felt_or_relocatable(os_hints_config.starknet_os_config.public_key_hash)"
1093-
),
10941088
(
10951089
SequencerAddress,
10961090
sequencer_address,
@@ -1859,13 +1853,13 @@ block_input = next(block_input_iterator)
18591853
)"#}
18601854
),
18611855
(
1862-
GetPublicKeyXFromOsInput,
1863-
get_public_key_x_from_os_input,
1856+
GetPublicKeyXInOs,
1857+
get_public_key_x_in_os,
18641858
r#"memory[ap] = to_felt_or_relocatable(os_input.public_key_x)"#
18651859
),
18661860
(
1867-
GetPublicKeyYFromOsInput,
1868-
get_public_key_y_from_os_input,
1861+
GetPublicKeyYInOs,
1862+
get_public_key_y_in_os,
18691863
r#"memory[ap] = to_felt_or_relocatable(os_input.public_key_y)"#
18701864
),
18711865
);

crates/starknet_os/src/hints/hint_implementation/block_context.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,3 @@ pub(crate) fn write_use_kzg_da_to_memory<S: StateReader>(
7777
Felt::from(use_kzg_da),
7878
)
7979
}
80-
81-
pub(crate) fn public_key_hash<S: StateReader>(
82-
hint_processor: &mut SnosHintProcessor<'_, S>,
83-
HintArgs { vm, .. }: HintArgs<'_>,
84-
) -> OsHintResult {
85-
let public_key_hash = hint_processor.os_hints_config.public_key_hash;
86-
Ok(insert_value_into_ap(vm, public_key_hash)?)
87-
}

crates/starknet_os/src/hints/hint_implementation/os.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,18 +151,18 @@ pub(crate) fn create_block_additional_hints<S: StateReader>(
151151
Ok(())
152152
}
153153

154-
pub(crate) fn get_public_key_x_from_os_input<S: StateReader>(
154+
pub(crate) fn get_public_key_x_in_os<S: StateReader>(
155155
hint_processor: &mut SnosHintProcessor<'_, S>,
156156
HintArgs { vm, .. }: HintArgs<'_>,
157157
) -> OsHintResult {
158-
let public_key_x = hint_processor.public_key_x;
158+
let public_key_x = hint_processor.os_hints_config.public_key_x;
159159
Ok(insert_value_into_ap(vm, public_key_x)?)
160160
}
161161

162-
pub(crate) fn get_public_key_y_from_os_input<S: StateReader>(
162+
pub(crate) fn get_public_key_y_in_os<S: StateReader>(
163163
hint_processor: &mut SnosHintProcessor<'_, S>,
164164
HintArgs { vm, .. }: HintArgs<'_>,
165165
) -> OsHintResult {
166-
let public_key_y = hint_processor.public_key_y;
166+
let public_key_y = hint_processor.os_hints_config.public_key_y;
167167
Ok(insert_value_into_ap(vm, public_key_y)?)
168168
}

crates/starknet_os/src/io/os_input.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,6 @@ pub struct StarknetOsInput {
6060
pub cached_state_inputs: Vec<CachedStateInput>,
6161
pub(crate) deprecated_compiled_classes: BTreeMap<CompiledClassHash, ContractClass>,
6262
pub(crate) compiled_classes: BTreeMap<CompiledClassHash, CasmContractClass>,
63-
pub(crate) public_key_x: Felt,
64-
pub(crate) public_key_y: Felt,
6563
}
6664

6765
// TODO(Meshi): Remove Once the blockifier ChainInfo do not support deprecated fee token.
@@ -120,7 +118,8 @@ pub struct OsHintsConfig {
120118
pub full_output: bool,
121119
pub use_kzg_da: bool,
122120
pub chain_info: OsChainInfo,
123-
pub public_key_hash: Felt,
121+
pub public_key_x: Felt,
122+
pub public_key_y: Felt,
124123
}
125124

126125
impl OsHintsConfig {

crates/starknet_os/src/runner.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,6 @@ pub fn run_os<S: StateReader>(
9999
cached_state_inputs,
100100
deprecated_compiled_classes,
101101
compiled_classes,
102-
public_key_x,
103-
public_key_y,
104102
},
105103
}: OsHints,
106104
state_readers: Vec<S>,
@@ -114,8 +112,6 @@ pub fn run_os<S: StateReader>(
114112
deprecated_compiled_classes,
115113
compiled_classes,
116114
state_readers,
117-
public_key_x,
118-
public_key_y,
119115
)?;
120116

121117
let mut runner_output = run_program(layout, &OS_PROGRAM, &mut snos_hint_processor)?;

0 commit comments

Comments
 (0)