Skip to content
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

Added file_utils to print not-found path in error #349

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

yuvalsw
Copy link
Collaborator

@yuvalsw yuvalsw commented Jan 12, 2025

This change is Reviewable

Copy link
Contributor

@ohad-starkware ohad-starkware left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewed 5 of 5 files at r1, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @giladchase)

Copy link

@giladchase giladchase left a comment

Choose a reason for hiding this comment

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

Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @yuvalsw)


stwo_cairo_prover/crates/prover/src/input/vm_import/mod.rs line 36 at r1 (raw file):

    public_input_json: &Path,
    private_input_json: &Path,
    dev_mode: bool,

Optional: will support both types via deref

Suggestion:

    public_input_json: &PathBuf,
    private_input_json: &PathBuf,

stwo_cairo_prover/crates/prover/src/input/vm_import/mod.rs line 42 at r1 (raw file):

    let public_input_string = read_to_string(public_input_json)?;
    let public_input: PublicInput<'_> = serde_json::from_str(&public_input_string)?;
    let private_input: PrivateInput = serde_json::from_str(&read_to_string(private_input_json)?)?;

Saves the tmp String alloc

Suggestion:

    
    let public_input: PublicInput<'_> = serde_json::from_reader(&open_file(public_input_string)?)?;
    let private_input: PrivateInput = serde_json::from_reader(&open_file(private_input_json)?)?;

stwo_cairo_prover/crates/utils/src/file_utils.rs line 10 at r1 (raw file):

    path: PathBuf,
}
impl serde::de::StdError for IoErrorWithPath {

StdError looks like a typedef to std::error? Does serde force us to this instead of impl std::Error?

Code quote:

impl serde::de::StdError for IoErrorWithPath {

stwo_cairo_prover/crates/utils/src/file_utils.rs line 27 at r1 (raw file):

/// A wrapper to `std::fs::read_to_string`, which, in case of failure, also logs the not-found path.
pub fn read_to_string(path: &Path) -> Result<String, IoErrorWithPath> {

Will support both types via deref

Suggestion:

pub fn read_to_string(path: &PathBuf) -> Result<String, IoErrorWithPath> {

Copy link

@giladchase giladchase left a comment

Choose a reason for hiding this comment

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

Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @yuvalsw)


stwo_cairo_prover/crates/prover/src/input/vm_import/mod.rs line 42 at r1 (raw file):

Previously, giladchase wrote…

Saves the tmp String alloc

I meant this for the private_input:

    let private_input: PrivateInput = serde_json::from_reader(&open_file(private_input_json)?)?;

srry

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants