Skip to content

stavbe: change AirPrivateInputSerializable fields to public #1900

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@

* fix: Check overflow in cairo pie address calculation [#1945](https://github.com/lambdaclass/cairo-vm/pull/1945)

* chore: Expose 'trace_path' and 'memory_path' fields in `AirPrivateInputSerializable` as public for external access [#1900] (https://github.com/lambdaclass/cairo-vm/pull/1900)

#### [2.0.0-rc5] - 2025-02-24

* fix: Fix Cairo Pie limiting the number of segments to 2^16 [#1960](https://github.com/lambdaclass/cairo-vm/pull/1960)
Expand Down
4 changes: 2 additions & 2 deletions vm/src/air_private_input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ use crate::Felt252;
// Serializable format, matches the file output of the python implementation
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)]
pub struct AirPrivateInputSerializable {
trace_path: String,
memory_path: String,
pub trace_path: String,
pub memory_path: String,
Comment on lines +15 to +16
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the idea is to read these fields and to not write them, I think it would be better to add getters for these fields instead of making them public

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It wouldn't work because I read it from json file.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not completely sure how reading the struct from a json file restricts implementing getters instead of making these fields public.
Let me rephrase my suggestion just in case. For example, instead of accessing these fields like this:

let trace_path = air_private_input_serializable.trace_path;
let memory_path = air_private_input_serializable.memory_path;

Shouldn't this also work?

let trace_path = air_private_input_serializable.get_trace_path();
let memory_path = air_private_input_serializable.get_memory_path();

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before being able to call the getter, you need to construct the sturct from the json:
fn deserialize_inputs<'a>( public_input_string: &'a str, private_input_string: &'a str, ) -> Result<(PublicInput<'a>, PrivateInput), VmImportError> { { Ok(( sonic_rs::from_str(public_input_string)?, sonic_rs::from_str(private_input_string)?, )) } #[cfg(not(feature = "std"))] { Ok(( serde_json::from_str(public_input_string)?, serde_json::from_str(private_input_string)?, )) }

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, but if you make trace_path and memory_path public, wouldn't you also need to construct the struct from the json?

#[serde(skip_serializing_if = "Option::is_none")]
pedersen: Option<Vec<PrivateInput>>,
#[serde(skip_serializing_if = "Option::is_none")]
Expand Down
Loading