-
Notifications
You must be signed in to change notification settings - Fork 180
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
stavbe: change AirPrivateInputSerializable fields to public #1900
Conversation
4205074
to
60912a7
Compare
Hi @Stavbe! You can convert fn get_pedersen(serializable: AirPrivateInputSerializable) -> Some(Vec<PrivateInput>>) {
let air_private_input: AirPrivateInput = serializable.into();
air_private_input.0.get(&BuiltinName::pedersen)
} With this, there's no need to make |
Hey :)
I actually need the trace and mem ...
…On Fri, Jan 3, 2025 at 5:54 PM Gabriel Bosio ***@***.***> wrote:
Hi @Stavbe <https://github.com/Stavbe>! You can convert
AirPrivateInputSerializable into an AirPrivateInput and then get each
builtin, for example to get Pedersen:
fn get_pedersen(serializable: AirPrivateInputSerializable) -> Some(Vec<PrivateInput>>) {
let air_private_input: AirPrivateInput = serializable.into();
air_private_input.0.get(&BuiltinName::pedersen)}
—
Reply to this email directly, view it on GitHub
<#1900 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/BISYNVSWEM2UIJFVJS6W53D2I2XDJAVCNFSM6AAAAABUEMDEAKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKNRZGQ2TGMBSGA>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Ok, I'm trying to get a bit more of context here so what's the use case? Because when calling cairo-vm/vm/src/air_private_input.rs Lines 154 to 158 in 259487e
|
?
…On Tue, Jan 7, 2025 at 3:40 PM Stav Beno ***@***.***> wrote:
The context is that I am trying to read the air_private_input.json, which
> contains the mem and trace values. I want to deserialize it into the
> same struct it was created from, instead of creating a similar one in our
> repository.Message ID: ***@***.***
> .com>
>
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I missed that response.
Yes, the JSON file (which was created after calling to_serializable
) contains the mem
and trace
.
Now, when trying to read it (private.json
), I need to define a new struct to use those fields, which is redundant.
For example, I read pub.json
into the pub struct PublicInput<'a>
.
Reviewable status: 0 of 2 files reviewed, all discussions resolved (waiting on @fmoletta, @gabrielbosio, @igaray, @juanbono, @Oppen, and @pefontana)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @Stavbe! Would exposing only trace_path
and memory_path
suffice? Or maybe we could add getter methods (i.e get_trace_path()
).
60912a7
to
3ad0c75
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. that could work. Fixed :)
Reviewable status: 0 of 2 files reviewed, all discussions resolved (waiting on @fmoletta, @gabrielbosio, @igaray, @juanbono, @noaov1, @Oppen, @pefontana, and @yuvalsw)
3ad0c75
to
d9d8e52
Compare
d9d8e52
to
61a1c75
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 2 files at r1, 1 of 1 files at r3, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @fmoletta, @gabrielbosio, @igaray, @juanbono, @noaov1, @Oppen, and @pefontana)
-- commits
line 5 at r3:
needs rebase?
Code quote:
New commits in r2 on 11/03/2025 at 18:49, probably rebased from r1:
- 61a1c75: stavbe: change AirPrivateInputSerializable fields to public
New commits in r3 on 16/03/2025 at 15:52:
- fda1f4c: Merge branch 'main' into stavbe/air-private-input-fields-to-pub
fda1f4c
to
61a1c75
Compare
Hey :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed all commit messages.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on @fmoletta, @gabrielbosio, @igaray, @juanbono, @noaov1, @Oppen, and @pefontana)
pub trace_path: String, | ||
pub memory_path: String, |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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();
There was a problem hiding this comment.
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)?, )) }
There was a problem hiding this comment.
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?
Change AirPrivateInputSerializable fields to be public, so I can use this struct.
This change is