All SmartContracts can use ZkPrograms proofs as inputs, and ZkPrograms can use other ZkPrograms proofs as inputs. Currently, it's impossible to deploy a SmartContract that makes use of such dependency tree.
Steps to Reproduce
Create a basic ZkProgram with a single method. We'll call it Foo.
Create a second ZkProgram that has a single method that takes a Foo proof as input. We'll call it Bar.
Create a SmartContract that uses a Bar proof 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.
Debugger attached.
✖ Generate verification key (takes 10-30 sec)
Error: Bar.compile() depends on Foo, but we cannot find compilation output for Foo.
Try to run Foo.compile() first.
Error: Bar.compile() depends on Foo, but we cannot find compilation output for Foo.
Try to run Foo.compile() first.
at file:///home/emlautarom1/dev/my-zk-app/node_modules/o1js/dist/node/lib/proof-system.js:432:23
at Array.map (<anonymous>)
at picklesRuleFromFunction (file:///home/emlautarom1/dev/my-zk-app/node_modules/o1js/dist/node/lib/proof-system.js:425:36)
at file:///home/emlautarom1/dev/my-zk-app/node_modules/o1js/dist/node/lib/proof-system.js:299:53
at Array.map (<anonymous>)
at compileProgram (file:///home/emlautarom1/dev/my-zk-app/node_modules/o1js/dist/node/lib/proof-system.js:299:29)
at Object.compile (file:///home/emlautarom1/dev/my-zk-app/node_modules/o1js/dist/node/lib/proof-system.js:150:58)
at generateVerificationKey (file:///home/emlautarom1/.nvm/versions/node/v21.6.1/lib/node_modules/zkapp-cli/src/lib/deploy.js:551:23)
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)
On https://github.com/o1-labs/zkapp-cli/pull/547 support was added to deploy SmartContracts that use ZkPrograms proofs as inputs but it seems like there was no consideration for dependencies between ZkPrograms during the compilation process.
When testing this smart contract we don't face this issue since we're in control over the compilation order but this is not the case when using the CLI.
Thanks for all your feedback @emlautarom1. I agree the cli deploy needs to be updated to be flexible enough to handle dependency trees similar to what you mentioned.
Describe the bug
All
SmartContract
s can useZkProgram
s proofs as inputs, andZkProgram
s can use otherZkProgram
s proofs as inputs. Currently, it's impossible to deploy aSmartContract
that makes use of such dependency tree.Steps to Reproduce
ZkProgram
with a single method. We'll call itFoo
.ZkProgram
that has a single method that takes aFoo
proof as input. We'll call itBar
.SmartContract
that uses aBar
proof as input.zk config
command.zk deploy
command.You should get the following stack trace:
On https://github.com/o1-labs/zkapp-cli/pull/547 support was added to deploy
SmartContract
s that useZkProgram
s proofs as inputs but it seems like there was no consideration for dependencies betweenZkProgram
s during the compilation process.When testing this smart contract we don't face this issue since we're in control over the compilation order but this is not the case when using the CLI.
System Info
Severity
blocking all usage
Additional Information
No response