If a SmartContract uses a proof generated by a ZkProgram it is possible for zk deploy to fail to find the ZkProgram.
Steps to Reproduce
Create a ZkProgram in the top level (ex. src/my-zk-program.ts). Ensure that the program uses " (double quotes) for its name (ex. const MyZkProgram = ZkProgram({ name: "MyZkProgram", ...)
Create a SmartContract that uses a proof generated by ZkProgram as input.
Configure the deployment of the contract using the zk config command.
Try to deploy the contract using the zk deploy command.
You should get the following stack trace:
✔ Build project
✔ Generate build.json
✔ Choose smart contract
The 'MySmartContract' smart contract will be used
for this deploy alias as specified in config.json.
✖ Generate verification key (takes 10-30 sec)
TypeError: Cannot destructure property 'zkProgramFile' of '(intermediate value)' as it is undefined.
TypeError: Cannot destructure property 'zkProgramFile' of '(intermediate value)' as it is undefined.
at getZkProgram (file:///home/emlautarom1/.nvm/versions/node/v21.6.1/lib/node_modules/zkapp-cli/src/lib/deploy.js:756:9)
at async generateVerificationKey (file:///home/emlautarom1/.nvm/versions/node/v21.6.1/lib/node_modules/zkapp-cli/src/lib/deploy.js:549:19)
at async file:///home/emlautarom1/.nvm/versions/node/v21.6.1/lib/node_modules/zkapp-cli/src/lib/deploy.js:274:7
at async step (file:///home/emlautarom1/.nvm/versions/node/v21.6.1/lib/node_modules/zkapp-cli/src/lib/helpers.js:17:20)
at async deploy (file:///home/emlautarom1/.nvm/versions/node/v21.6.1/lib/node_modules/zkapp-cli/src/lib/deploy.js:270:41)
at async Object.handler (file:///home/emlautarom1/.nvm/versions/node/v21.6.1/lib/node_modules/zkapp-cli/src/bin/index.js:130:30)
The regex used to find the proof is incomplete, only finding ZkPrograms where the name is between ' (single quotes) and not between " (double quotes).
I believe it's a terrible approach to try to do this regular expressions but if done like that then the regex should at least be flexible enough to accept all valid quotes in JavaScript, that is ', " and ` (single, double and backtick).
Describe the bug
If a
SmartContract
uses a proof generated by aZkProgram
it is possible forzk deploy
to fail to find theZkProgram
.Steps to Reproduce
ZkProgram
in the top level (ex.src/my-zk-program.ts
). Ensure that the program uses"
(double quotes) for its name (ex.const MyZkProgram = ZkProgram({ name: "MyZkProgram", ...
)SmartContract
that uses a proof generated byZkProgram
as input.zk config
command.zk deploy
command.You should get the following stack trace:
The issue lies in the following line:
https://github.com/o1-labs/zkapp-cli/blob/c166e4a46430d89ec96af6ff496188054a7a2d61/src/lib/deploy.js#L730-L734
The regex used to find the proof is incomplete, only finding
ZkProgram
s where the name is between'
(single quotes) and not between"
(double quotes).I believe it's a terrible approach to try to do this regular expressions but if done like that then the regex should at least be flexible enough to accept all valid quotes in JavaScript, that is
'
,"
and`
(single, double and backtick).System Info
Severity
annoyance
Additional Information
The hard part was figuring out that this was the error. As a workaround, change the
name
property in theZkProgram
to use'
instead.