Skip to content

Commit

Permalink
Set dynamic params as null by default on air public input (#1716)
Browse files Browse the repository at this point in the history
* Set dynamic params as null by default

* Add changelog entry

* Remove old fn
  • Loading branch information
fmoletta authored Apr 22, 2024
1 parent a462d8d commit 7eff520
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 20 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

#### Upcoming Changes

* BREAKING: Set dynamic params as null by default on air public input [#1716](https://github.com/lambdaclass/cairo-vm/pull/1716)
* `PublicInput` field `layout_params` renamed to `dynamic_params` & type changed from`&'a CairoLayout` to `()`.

* feat: `cairo1-run` accepts Sierra programs [#1719](https://github.com/lambdaclass/cairo-vm/pull/1719)

* refactor(BREAKING): Use `BuiltinName` enum instead of string representation [#1722](https://github.com/lambdaclass/cairo-vm/pull/1722)
Expand Down
11 changes: 2 additions & 9 deletions vm/src/air_public_input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ use crate::{
collections::HashMap,
prelude::{String, Vec},
},
types::layout::CairoLayout,
vm::{
errors::{trace_errors::TraceError, vm_errors::VirtualMachineError},
trace::trace_entry::RelocatedTraceEntry,
Expand Down Expand Up @@ -98,16 +97,14 @@ pub struct PublicInput<'a> {
pub n_steps: usize,
pub memory_segments: HashMap<&'a str, MemorySegmentAddresses>,
pub public_memory: Vec<PublicMemoryEntry>,
#[serde(rename = "dynamic_params")]
#[serde(skip_deserializing)] // This is set to None by default so we can skip it
layout_params: Option<&'a CairoLayout>,
dynamic_params: (),
}

impl<'a> PublicInput<'a> {
pub fn new(
memory: &[Option<Felt252>],
layout: &'a str,
dyn_layout_params: Option<&'a CairoLayout>,
public_memory_addresses: &[(usize, usize)],
memory_segment_addresses: HashMap<&'static str, (usize, usize)>,
trace: &[RelocatedTraceEntry],
Expand Down Expand Up @@ -136,7 +133,7 @@ impl<'a> PublicInput<'a> {

Ok(PublicInput {
layout,
layout_params: dyn_layout_params,
dynamic_params: (),
rc_min,
rc_max,
n_steps: trace.len(),
Expand Down Expand Up @@ -220,9 +217,5 @@ mod tests {
public_input.public_memory,
deserialized_public_input.public_memory
);
assert!(
public_input.layout_params.is_none()
&& deserialized_public_input.layout_params.is_none()
);
}
}
11 changes: 0 additions & 11 deletions vm/src/vm/runners/cairo_runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1432,24 +1432,13 @@ impl CairoRunner {
})
}

/// Return CairoRunner.layout
fn get_layout(&self) -> &CairoLayout {
&self.layout
}

pub fn get_air_public_input(
&self,
vm: &VirtualMachine,
) -> Result<PublicInput, PublicInputError> {
let dyn_layout = match self.layout.name {
LayoutName::dynamic => Some(self.get_layout()),
_ => None,
};

PublicInput::new(
&self.relocated_memory,
self.layout.name.to_str(),
dyn_layout,
&vm.get_public_memory_addresses()?,
self.get_memory_segment_addresses(vm)?,
self.relocated_trace
Expand Down

0 comments on commit 7eff520

Please sign in to comment.