o1-labs / o1js

TypeScript framework for zk-SNARKs and zkApps
https://docs.minaprotocol.com/en/zkapps/how-to-write-a-zkapp
Apache License 2.0
502 stars 111 forks source link

Broken `ZkProgram` Examples #1697

Closed harrysolovay closed 1 month ago

harrysolovay commented 3 months ago

The following examples are broken

(running with Node.js v21.7.3)

https://github.com/o1-labs/o1js/blob/1588ee566d15a6e5ef6a1a611386c7da578ab48a/src/examples/zkprogram/program.ts

program digest Promise { <pending> }
compiling MyProgram...
/Users/harrysolovay/Desktop/mina-fungible-token/node_modules/o1js/src/lib/provable/core/provable-context.ts:105
    let finish = Snarky.run.enterConstraintSystem();
                        ^

TypeError: Cannot read properties of undefined (reading 'run')
    at Object.constraintSystem (o1js/src/lib/provable/core/provable-context.ts:105:25)
    at analyzeMethods (o1js/src/lib/proof-system/zkprogram.ts:483:45)
    at Object.compile (o1js/src/lib/proof-system/zkprogram.ts:508:23)
    at <anonymous> (/Users/harrysolovay/Desktop/mina-fungible-token/examples/proof-counting.eg.ts:33:27)

https://github.com/o1-labs/o1js/blob/1588ee566d15a6e5ef6a1a611386c7da578ab48a/src/examples/zkprogram/program-with-input.ts

program digest Promise { <pending> }
compiling MyProgram...
/Users/harrysolovay/Desktop/mina-fungible-token/node_modules/o1js/src/lib/provable/core/provable-context.ts:105
    let finish = Snarky.run.enterConstraintSystem();
                        ^

TypeError: Cannot read properties of undefined (reading 'run')
    at Object.constraintSystem (o1js/src/lib/provable/core/provable-context.ts:105:25)
    at analyzeMethods (o1js/src/lib/proof-system/zkprogram.ts:483:45)
    at Object.compile (o1js/src/lib/proof-system/zkprogram.ts:508:23)
    at <anonymous> (/Users/harrysolovay/Desktop/mina-fungible-token/examples/proof-counting.eg.ts:33:27)

https://github.com/o1-labs/o1js/blob/1588ee566d15a6e5ef6a1a611386c7da578ab48a/src/examples/zkprogram/dynamic-keys-merkletree.ts

Module '"o1js"' has no exported member 'FeatureFlags'.ts(2305)
mitschabaude commented 3 months ago

The first two are missing an await in front of digest() (fixed in a draft PR), and the third one should actually work on the main branch (where examples are expected to work) but uses a yet unreleased feature

mitschabaude commented 1 month ago

Solved