There is already open issue where a SmartContract cannot be deployed if it's defined in a folder (https://github.com/o1-labs/zkapp-cli/issues/593). A similar issue exists when a SmartContract makes usage of a ZkProgram's Proof as an input, forcing developer to have everything in the top level folder (src)
Steps to Reproduce
Create a SmartContract in the root folder (ex. src/my-smart-contract.ts) that uses a proof generated by a ZkProgram that is defined in a file in a nested folder (ex. src/proofs/my-zk-program.ts).
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)
Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/home/emlautarom1/dev/myzkapp/build/src/my-zk-program.js' imported from /home/emlautarom1/.nvm/versions/node/v21.6.1/lib/node_modules/zkapp-cli/src/lib/deploy.js
Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/home/emlautarom1/dev/myzkapp/build/src/my-zk-program.js' imported from /home/emlautarom1/.nvm/versions/node/v21.6.1/lib/node_modules/zkapp-cli/src/lib/deploy.js
at finalizeResolution (node:internal/modules/esm/resolve:263:11)
at moduleResolve (node:internal/modules/esm/resolve:908:10)
at defaultResolve (node:internal/modules/esm/resolve:1131:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:390:12)
at ModuleLoader.resolve (node:internal/modules/esm/loader:359:25)
at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:234:38)
at ModuleLoader.import (node:internal/modules/esm/loader:322:34)
at importModuleDynamically (node:internal/modules/esm/translators:159:35)
at importModuleDynamicallyCallback (node:internal/modules/esm/utils:207:14)
at getZkProgram (file:///home/emlautarom1/.nvm/versions/node/v21.6.1/lib/node_modules/zkapp-cli/src/lib/deploy.js:767:28)
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) {
code: 'ERR_MODULE_NOT_FOUND',
url: 'file:///home/emlautarom1/dev/myzkapp/build/src/my-zk-program.js'
}
The whole process should be rewritten instead to use path.resolve without the need to append any path prefix (which should be done through path.join instead of interpolated strings with /)
Describe the bug
There is already open issue where a
SmartContract
cannot be deployed if it's defined in a folder (https://github.com/o1-labs/zkapp-cli/issues/593). A similar issue exists when aSmartContract
makes usage of aZkProgram
'sProof
as an input, forcing developer to have everything in the top level folder (src
)Steps to Reproduce
SmartContract
in the root folder (ex.src/my-smart-contract.ts
) that uses a proof generated by aZkProgram
that is defined in a file in a nested folder (ex.src/proofs/my-zk-program.ts
).zk config
command.zk deploy
command.You should get the following stack trace:
The issue lies in the following lines:
https://github.com/o1-labs/zkapp-cli/blob/c166e4a46430d89ec96af6ff496188054a7a2d61/src/lib/deploy.js#L741-L743
This function returns the file name (through
path.basename
) which then gets appended to a fixed path listed here:https://github.com/o1-labs/zkapp-cli/blob/c166e4a46430d89ec96af6ff496188054a7a2d61/src/lib/deploy.js#L761-L764
The whole process should be rewritten instead to use
path.resolve
without the need to append any path prefix (which should be done throughpath.join
instead of interpolated strings with/
)System Info
Severity
serious, but I can work around it
Additional Information
No response