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

feat(cli): Try Prover.json if Prover.toml is not present #7170

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

aakoshh
Copy link
Contributor

@aakoshh aakoshh commented Jan 23, 2025

Description

Problem*

Extracted from AztecProtocol/aztec-packages#11294

Summary*

The debug and execute CLI commands accept --program-dir and a --prover-name argument to specify where to look for the inputs for the circuit. The prover name is Prover by default, but we can't specify e.g. Prover.json to make it take a JSON file, it always tries to use Format::Toml to parse it, which determines the .toml extension.

The PR changes commands that read Prover.toml to try both Format::Toml and Format::Json (in that order), so that if Prover.toml is not present but Prover.json is, then we use the latter.

Additional Context

Ostensibly we could have a --format argument, but I found this useful when capturing the input witnesses from the TypeScript integration tests like here, and wanted to use it as-is to replicate the error like this, without having to go through more hoops.

Documentation*

Check one:

  • No documentation needed.
  • Documentation included in this PR.
  • [For Experimental Features] Documentation to be submitted in a separate PR.

PR Checklist*

  • I have tested the changes locally.
  • I have formatted the changes with Prettier and/or cargo fmt on default settings.

@aakoshh aakoshh changed the title feat(cli) Try Prover.json if Prover.toml is not present feat(cli): Try Prover.json if Prover.toml is not present Jan 23, 2025
@aakoshh aakoshh force-pushed the af/cli-accept-json branch from 1852697 to f75e052 Compare January 23, 2025 19:15
Copy link
Contributor

@vezenovm vezenovm left a comment

Choose a reason for hiding this comment

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

Let's add the change for the info command as well. We need it for profiling Brillig execution.

@aakoshh aakoshh force-pushed the af/cli-accept-json branch from f75e052 to 2d79656 Compare January 23, 2025 19:31
@vezenovm vezenovm enabled auto-merge January 23, 2025 19:33
@TomAFrench TomAFrench disabled auto-merge January 23, 2025 19:38
Copy link
Member

@TomAFrench TomAFrench left a comment

Choose a reason for hiding this comment

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

This conflicts with nargo check which will ignore json files.

@TomAFrench
Copy link
Member

If we're accepting this as a first class input format we then also need to support it in the profiler also, etc. etc.

@aakoshh
Copy link
Contributor Author

aakoshh commented Jan 23, 2025

I see that the check command can create an Prover.toml template file, but I don't see it reading the inputs, other than to verify they exist before accidentally overwriting them 👀

If that's all it does, then I don't think it necessarily conflicts, it just doesn't create a JSON template at the moment.

@TomAFrench
Copy link
Member

I think it conflicts if we're expecting users to have a Prover.json file but that then prevents them from running nargo check without their inputs being soft-overwritten by an empty template file.

@aakoshh
Copy link
Contributor Author

aakoshh commented Jan 23, 2025

Maybe I'm misunderstanding something, but the check command at the moment is hardcoded to write a Prover.toml file, nothing else, it will ignore any JSON, won't write over it.

@TomAFrench
Copy link
Member

Yeah but if you then try and execute your program afterwards then nargo will pick up the empty toml file over the json file you've been using previously.

@aakoshh
Copy link
Contributor Author

aakoshh commented Jan 23, 2025

Ah, by "soft overwrite" you meant shadowing, gotcha.

Thanks for pointing out the profiler, I updated that to handle both formats.

@aakoshh
Copy link
Contributor Author

aakoshh commented Jan 23, 2025

Updated check_cmd to check that any prover file with a format other than Format::Toml exists, and if so then ask for --overwrite to be used, even though it will not be deleted, just shadowed by the TOML template.

@aakoshh aakoshh requested a review from TomAFrench January 23, 2025 21:19
@aakoshh
Copy link
Contributor Author

aakoshh commented Jan 24, 2025

To highlight some of the differences with working with the different formats, I transformed this JSON witness to TOML with https://transform.tools/json-to-toml ; here's a part of it as it's opened in my editor:

Here's what a heavily hierarchical part looks like in JSON:
Screenshot 2025-01-24 at 09 45 37

The same in TOML as it's formatted by the tool:
Screenshot 2025-01-24 at 09 47 17

Luckily the tool indents the content to follow the nesting, but it's inconsistent: [previous_kernel_public_inputs.constants] is indented more than [previous_kernel_public_inputs.constants.historical_header.state.l1_to_l2_message_tree] below it.

When I save the TOML in VSCode it gets rid of all indentation. Tried a setting in the plugin but it didn't make a difference, but I don't expect a uniform setting for everyone.

Another thing I found work better in the JSON editing is the collapse of arrays. The TOML editor can collapse structs like thekey_validation_requests_and_generators here:

Screenshot 2025-01-24 at 09 55 22

But there is no wrapper for the note_hashes array below it, so those entries can only be collapsed individually, not as a whole group.

In JSON this is easy, so helps to explore the document and delete regions that aren't interesting for the test:
Screenshot 2025-01-24 at 10 01 55

To TOML's credit a collapsed record still shows its full path which is more useful than seeing those {} above note_hashes.

@aakoshh aakoshh requested a review from a team January 28, 2025 12:42
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark 'Test Suite Duration'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.20.

Benchmark suite Current: ce8ab2d Previous: fc75298 Ratio
noir-lang_noir_sort_ 1 s 0 s +∞
noir-lang_mimc_ 1 s 0 s +∞
AztecProtocol_aztec-packages_noir-projects_noir-protocol-circuits_crates_blob 61 s 50 s 1.22

This comment was automatically generated by workflow using github-action-benchmark.

CC: @TomAFrench

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