Skip to content

Commit

Permalink
fix use_kzg_da global variable
Browse files Browse the repository at this point in the history
  • Loading branch information
ftheirs committed Dec 26, 2024
1 parent a394e9e commit 96d4c29
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
11 changes: 7 additions & 4 deletions crates/starknet-os/src/hints/output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,16 @@ pub const SET_STATE_UPDATES_START: &str = indoc! {r#"# `use_kzg_da` is used in a

pub fn set_state_updates_start(
vm: &mut VirtualMachine,
_exec_scopes: &mut ExecutionScopes,
exec_scopes: &mut ExecutionScopes,
ids_data: &HashMap<String, HintReference>,
ap_tracking: &ApTracking,
_constants: &HashMap<String, Felt252>,
) -> Result<(), HintError> {
let use_kzg_da_felt = get_integer_from_var_name(vars::ids::USE_KZG_DA, vm, ids_data, ap_tracking)?;

// Set `use_kzg_da` in globals since it will be used in `process_data_availability`
exec_scopes.insert_value(vars::scopes::USE_KZG_DA, use_kzg_da_felt);

// Recompute `compress_state_updates` until this issue is fixed
// https://github.com/lambdaclass/cairo-vm/issues/1897
let full_output = get_integer_from_var_name(vars::ids::FULL_OUTPUT, vm, ids_data, ap_tracking)?;
Expand Down Expand Up @@ -159,20 +162,20 @@ pub fn set_state_updates_start(
Ok(())
}

pub const SET_COMPRESSED_START: &str = indoc! {r#"if ids.use_kzg_da:
pub const SET_COMPRESSED_START: &str = indoc! {r#"if use_kzg_da:
ids.compressed_start = segments.add()
else:
# Assign a temporary segment, to be relocated into the output segment.
ids.compressed_start = segments.add_temp_segment()"#};

pub fn set_compressed_start(
vm: &mut VirtualMachine,
_exec_scopes: &mut ExecutionScopes,
exec_scopes: &mut ExecutionScopes,
ids_data: &HashMap<String, HintReference>,
ap_tracking: &ApTracking,
_constants: &HashMap<String, Felt252>,
) -> Result<(), HintError> {
let use_kzg_da_felt = get_integer_from_var_name(vars::ids::USE_KZG_DA, vm, ids_data, ap_tracking)?;
let use_kzg_da_felt = exec_scopes.get::<Felt252>(vars::scopes::USE_KZG_DA)?;

let use_kzg_da = if use_kzg_da_felt == Felt252::ONE {
Ok(true)
Expand Down
1 change: 1 addition & 0 deletions crates/starknet-os/src/hints/vars.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ pub mod scopes {
pub const TRANSACTIONS: &str = "transactions";
pub const TX: &str = "tx";
pub const VALUE: &str = "value";
pub const USE_KZG_DA: &str = "use_kzg_da";
}

pub mod ids {
Expand Down

0 comments on commit 96d4c29

Please sign in to comment.