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

Cache verification key in CLI [Do Not Merge Until New Published Version of SnarkyJS is Added] #233

Merged
merged 24 commits into from
Aug 12, 2022

Conversation

ymekuria
Copy link
Collaborator

@ymekuria ymekuria commented Jul 14, 2022

Description
Addresses #158

Background

Currently every time the zk deploy command is run, the contract is compiled to generate a verification key which takes 10-30s. This leads to a poor experience when a developer goes through the deploy flow multiple times.

Approach

A hash of the contract's circuit can be quickly computed using the SmartContract.digest() method from SnarkyJS. This digest hash, along with the corresponding verification key that is generated, is stored in a cache the first time 'zk deploy' is run on a contract. When zk deploy is run in the future, if the contract digest matches the stored digest, the cached verification key is used. The contract is only recompiled if the digest changes. See the discussion here for more details.

Status

Currently SmartContract.digest() isn't available on the published version SnarkyJS. Don't merge this PR until the new version of SnarkyJS is published with SmartContract.digest().

Copy link
Contributor

@mitschabaude mitschabaude left a comment

Choose a reason for hiding this comment

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

left some comments!

src/lib/deploy.js Outdated Show resolved Hide resolved
src/lib/deploy.js Outdated Show resolved Hide resolved
src/lib/deploy.js Outdated Show resolved Hide resolved
src/lib/deploy.js Outdated Show resolved Hide resolved
src/lib/deploy.js Outdated Show resolved Hide resolved
src/lib/deploy.js Outdated Show resolved Hide resolved
src/lib/deploy.js Outdated Show resolved Hide resolved
@jasongitmail
Copy link
Contributor

Looks great! Assuming it all works whether build dir exists or not, like Gregor mentioned.

ymekuria and others added 7 commits August 12, 2022 00:07
…improvements [Do Not Merge Until New Published Version of SnarkyJS is Added] (#238)

* feat: add update method precondition to template

* feat: sudoku preconditions

* fix: add static from method to invoke original sudoku constructor

* refactor: replace invoking construtor with from method invocations

* fix: update setpermissions api on tictactoe example

* feat: add gameDone state precondition

* feat: add tictactoe nextplayer state precondition

* feat: add tictactoe board state precondition

* chore: bump snarkyjs version to 0.5.0

* chore: bump template snarkyjs peerdependency version to 0.5.0

* chore: update package.json

* fix: update tictactoe run.ts with new account fields

* refactor: replace static from method with constructor
* fix: update increment nonce

* chore: bump version to 4.12
@ymekuria ymekuria force-pushed the feature/verification-key-cache branch from ff32c2f to 06bfe24 Compare August 12, 2022 08:27
@ymekuria ymekuria merged commit d7d73b0 into main Aug 12, 2022
@ymekuria ymekuria deleted the feature/verification-key-cache branch November 30, 2022 10:01
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