-
Notifications
You must be signed in to change notification settings - Fork 44
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
Add support to deploy smart contracts that verify ZkProgram proofs #547
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
… of the user-specified ZkProgram The function `findZkProgramFile` is added to the `deploy.js` file. This function takes in two parameters: `buildPath` and `zkProgramName`. It uses a glob pattern to find all files matching the `buildPath` pattern. It then searches for a specific pattern in each file to find the user-specified zkprogram. If a match is found, it returns the file name of the zkprogram. This function is useful for finding the file name of the zkprogram that needs to be compiled in the deployment process.
…mpiled zkprogram.
…amName the smart contract verifies
…m if smart contract to deploy verifies it
…able name assigned to the zkProgram with the matching name argument
…rogramFile function
… contract file verifies a zkprogram
… a smart contract that verifies it. The `deploy` function in `deploy.js` now compiles the specified `zkProgram` that the smart contract verifies before deployment.
… to zkProgramNameArg for clarity and improved semantics
…hens in getZkProgramNameArg function
…hens in findZkProgramFile function
… store the zk program for the contract
…r each deployed contract It modifies the deploy function to store the value of the zkProgramNameArg variable in the cache object for each deployed contract. This change allows for easy access to the zkProgramNameArg value when needed.
…o improve performance and reduce redundant computations
…ed by computing its digest and comparing it with the cached digest
…ecessary parameters for generating verification key
…riable from 'res' to 'networkResponse' for clarity
…separate function
…m build path and project root The getZkProgram function is added to the deploy.js file. This function is responsible for retrieving the zk program from the specified build path and project root. It takes in the build path, project root, and zk program name as arguments. This function will be used to find the file name of the smart contract to be deployed.
…rogram function By extracting this logic into a separate function, we improve code readability and maintainability. It also eliminates code duplication, as the same logic was previously duplicated in two places within the `generateVerificationKey` function.
…utput is not found
The findZkPrograms function was no longer being used in the deploy.js file. It was responsible for finding the user-specified name for every exported instance of `ZkProgram` in the build directory. Since it was not being used, it was removed to improve code readability and maintainability.
shimkiv
reviewed
Mar 5, 2024
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 was not able to deploy one used in target issue #377.
shimkiv
approved these changes
Mar 5, 2024
…tracts that verify ZkProgram proofs
…n Windows platform
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR adds the functionality to the
zkApp-CLI
to enable a user to deploy smart contracts that verifyZkProgram
proofs. Previously during the deploy flow, thezkApp-CLI
would compile the smart contract to be deployed, but was not able to detect and compile any ZkPrograms who's proofs are verified in the Smart contract.This issue blocked all users from deploying Smart contracts that verify ZkProgram proofs the
zkApp-CLI
. This feature has been increasingly requested by many people in the community as ZkProgram usage has increased, and will unlock the ability to more rapidly build and iterate withZkprogram
's.Solution
The CLI can now detect if a smart contract verifies a
ZkProgram
proof, and compiles the necessaryZkProgram
. Additionaly,ZkProgram
compile caching was added so the CLI only compiles when necessary, improving the deploy speed and overall DX. This was accomplished by computing theZkProgram
digest and adding it to the cache to determine when it is necessary to recompile. Computing the digest is much less expensive and time consuming than compiling theZkProgram
.Closes #377
Testing
The improvements introduced in this PR have been by tested by generating and deploying smart contracts that verify
ZkProgram
proofszkapp-CLI
and running the full e2e testing suite.