From 688b28c5398e48e8b07649a0b431139608a1d791 Mon Sep 17 00:00:00 2001 From: Gregor Date: Tue, 2 May 2023 13:11:31 +0200 Subject: [PATCH 1/3] throw an error in deploy when no vk is found --- src/lib/zkapp.ts | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/lib/zkapp.ts b/src/lib/zkapp.ts index bf2e59829d..585ed903a3 100644 --- a/src/lib/zkapp.ts +++ b/src/lib/zkapp.ts @@ -728,14 +728,19 @@ class SmartContract { } = {}) { let accountUpdate = this.newSelf(); verificationKey ??= (this.constructor as any)._verificationKey; - if (verificationKey === undefined && !Mina.getProofsEnabled()) { - verificationKey = Pickles.dummyVerificationKey(); - } - if (verificationKey !== undefined) { - let { hash: hash_, data } = verificationKey; - let hash = typeof hash_ === 'string' ? Field(hash_) : hash_; - accountUpdate.account.verificationKey.set({ hash, data }); + if (verificationKey === undefined) { + if (!Mina.getProofsEnabled()) { + verificationKey = Pickles.dummyVerificationKey(); + } else { + throw Error( + `\`${this.constructor.name}.deploy()\` was called but no verification key was found.\n` + + `Try calling \`await ${this.constructor.name}.compile()\` first, this will cache the verification key in the background.` + ); + } } + let { hash: hash_, data } = verificationKey; + let hash = typeof hash_ === 'string' ? Field(hash_) : hash_; + accountUpdate.account.verificationKey.set({ hash, data }); accountUpdate.account.permissions.set(Permissions.default()); accountUpdate.sign(zkappKey); AccountUpdate.attachToTransaction(accountUpdate); From 01f30cf9809f9747452d7196eb022b2b18b4e593 Mon Sep 17 00:00:00 2001 From: Gregor Date: Tue, 2 May 2023 13:16:46 +0200 Subject: [PATCH 2/3] changelog --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index bed7097d0c..0bacbf8f4a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,11 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm - Support for fallback endpoints when making network requests, allowing users to provide an array of endpoints for GraphQL network requests. https://github.com/o1-labs/snarkyjs/pull/871 - Endpoints are checked for validity, and a "waterfall" approach is used to loop through fallback endpoints if needed. +### Fixed + +- `SmartContract.deploy()` throws an error when no verification key is found https://github.com/o1-labs/snarkyjs/pull/885 + - The old, confusing behaviour was to silently not update the verification key (but still update some permissions to "proof", breaking the zkApp) + ## [0.9.8](https://github.com/o1-labs/snarkyjs/compare/1a984089...97e393ed) ### Breaking Changes From ee0f4f09e81f665c5271fcb0a803204cd2e2a27a Mon Sep 17 00:00:00 2001 From: Gregor Date: Tue, 2 May 2023 13:57:14 +0200 Subject: [PATCH 3/3] fixup precondition test --- src/lib/precondition.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/precondition.test.ts b/src/lib/precondition.test.ts index 8c7aed342e..ad4cecbb23 100644 --- a/src/lib/precondition.test.ts +++ b/src/lib/precondition.test.ts @@ -27,7 +27,7 @@ let feePayerKey: PrivateKey; beforeAll(async () => { // set up local blockchain, create zkapp keys, deploy the contract await isReady; - let Local = Mina.LocalBlockchain(); + let Local = Mina.LocalBlockchain({ proofsEnabled: false }); Mina.setActiveInstance(Local); feePayerKey = Local.testAccounts[0].privateKey; feePayer = Local.testAccounts[0].publicKey;