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

fix(nargo): correct inconsistent file extension for ACIR hashes #994

Conversation

ilitteri
Copy link
Contributor

Related issue(s)

Resolves #993

Description

Summary of changes

  • Made save_and_preprocess_program public for the crate.
  • Renamed the extension for the ACIR hash that is being stored (json.sha256 -> json.checksum). For this point, I have a doubt about which you prefer and I think that it'd be nice to have a constant for this extension in order to avoid the same problem in the future.
  • Add integration test that test this flow:
    • nargo compile <circuit_name>.
    • nargo prove <proof_name> <circuit_name>.
    • nargo verify <proof_name> <circuit_name>.
  • Added a test helper function for the bullet above.

Dependency additions / changes

Test additions / changes

  • Add integration test that test this flow:
    • nargo compile <circuit_name>.
    • nargo prove <proof_name> <circuit_name>.
    • nargo verify <proof_name> <circuit_name>.
  • Added a test helper function for the bullet above.

Checklist

  • I have tested the changes locally.
  • I have formatted the changes with Prettier and/or cargo fmt with default settings.
  • I have linked this PR to the issue(s) that it resolves.
  • I have reviewed the changes on GitHub, line by line.
  • I have ensured all changes are covered in the description.

Documentation needs

  • This PR requires documentation updates when merged.

Additional context

By "cached use case flow" I mean the user proving and verifying over a circuit that was compiled using `nargo compile <circuit_name>`
@ilitteri ilitteri marked this pull request as draft March 16, 2023 16:04
@TomAFrench TomAFrench self-requested a review March 16, 2023 16:22
@ilitteri
Copy link
Contributor Author

I'm merging both integration tests into one (noir_integration) because there is a problem when running them in parallel.

@ilitteri ilitteri marked this pull request as ready for review March 16, 2023 16:40
@TomAFrench
Copy link
Member

I think we can avoid doing that. Currently reviewing.

@ilitteri ilitteri changed the title Fix error when proving/verifying a pre compiled program fix: error when proving/verifying a pre compiled program Mar 16, 2023
@ilitteri ilitteri changed the title fix: error when proving/verifying a pre compiled program fix(nargo): error when proving/verifying a pre compiled program Mar 16, 2023
@ilitteri
Copy link
Contributor Author

I think we can avoid doing that. Currently reviewing.

Thanks!

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.

Thanks for catching this @ilitteri, sorry this slipped through.

My main concern with the current PR is that we could get a minor combinatorial explosion of different paths through the compilation->proving->verification flow if we add more integration tests for cases like this, e.g. Proving and verifying can either automatically generate the ACIR from source or use a build artifact, verification may read a proof from a file or get passed it directly, etc.

If we run integration tests across all of test_data for each potential path we'd end up making CI unnecessarily slow. I think it would be best to have a more focused test just to check that fetch_pk_and_vk will always be able to recover the keys saved by save_and_preprocess_program if you pass in the same circuit.

crates/nargo/src/cli/mod.rs Outdated Show resolved Hide resolved
crates/nargo/src/cli/fs/program.rs Outdated Show resolved Hide resolved
@ilitteri
Copy link
Contributor Author

ilitteri commented Mar 16, 2023

Thanks for catching this @ilitteri, sorry this slipped through.

My main concern with the current PR is that we could get a minor combinatorial explosion of different paths through the compilation->proving->verification flow if we add more integration tests for cases like this, e.g. Proving and verifying can either automatically generate the ACIR from source or use a build artifact, verification may read a proof from a file or get passed it directly, etc.

If we run integration tests across all of test_data for each potential path we'd end up making CI unnecessarily slow. I think it would be best to have a more focused test just to check that fetch_pk_and_vk will always be able to recover the keys saved by save_and_preprocess_program if you pass in the same circuit.

I like the idea of just checking fetch_pk_and_vk. Another alternative (the one that I was trying right now) is using a Mutex. It actually works but it's being polished. If the time is not better, I will go for the fetch_pk_and_vk test.

EDIT: I got 1.5x doing this. I'll go for the unit test.

@ilitteri ilitteri requested a review from TomAFrench March 16, 2023 17:57
@ilitteri
Copy link
Contributor Author

@TomAFrench ready! Do you want me to file an issue for unit testing the other fs submodule functions?

Now it also checks that the keys it returns are the ones that we saved

Co-authored-by: Tom French <15848336+TomAFrench@users.noreply.github.com>
@TomAFrench
Copy link
Member

Do you want me to file an issue for unit testing the other fs submodule functions?

Yeah we should roll these out to get more coverage on this submodule, I've added one here #995

Thanks again for this :)

@TomAFrench
Copy link
Member

Sorry, that suggestion was semi-pseudocode. I'll fix up any issues and merge.

@ilitteri
Copy link
Contributor Author

@TomAFrench ready! Do you want me to file an issue for unit testing the other fs submodule functions?

Sorry, that suggestion was semi-pseudocode. I'll fix up any issues and merge.

Oh sorry, my bad.

@ilitteri
Copy link
Contributor Author

Sorry, that suggestion was semi-pseudocode. I'll fix up any issues and merge.

I have the fix ready to push, let me know if you're working on it too.

@TomAFrench
Copy link
Member

I have the fix ready to push, let me know if you're working on it too.

I've got it ready but github won't let me push to the fork branch for some reason. Feel free to push.

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.

Awesome, LGTM.

@TomAFrench TomAFrench changed the title fix(nargo): error when proving/verifying a pre compiled program fix(nargo): correct inconsistent file extension for ACIR hashes Mar 16, 2023
@TomAFrench TomAFrench enabled auto-merge March 16, 2023 19:40
@TomAFrench TomAFrench disabled auto-merge March 16, 2023 19:43
@TomAFrench TomAFrench added this pull request to the merge queue Mar 16, 2023
Merged via the queue into noir-lang:master with commit 23c22d7 Mar 16, 2023
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.

Error when trying to nargo prove a compiled circuit
2 participants