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
500 stars 110 forks source link

Error using offchain state from factory contract #1684

Closed mitschabaude closed 1 week ago

mitschabaude commented 3 months ago

link to report on discord: https://discord.com/channels/484437221055922177/1247852410739621918/1250561197170884638

getActions: endActionState not found.

      at Object.getActions (o1js/src/lib/mina/local-blockchain.ts:395:29)
      at Object.fetchActions (o1js/src/lib/mina/local-blockchain.ts:367:19)
      at Module.fetchActions (o1js/src/lib/mina/mina-instance.ts:202:31)
      at fetchMerkleMap (o1js/src/lib/mina/actions/offchain-state-serialization.ts:262:27)
      at merkleMaps (o1js/src/lib/mina/actions/offchain-state.ts:161:41)
      at node_modules/o1js/src/lib/mina/actions/offchain-state.ts:195:26
      at node_modules/o1js/src/lib/provable/types/witness.ts:68:21
      at existsAsync (o1js/src/lib/provable/core/exists.ts:70:16)
      at Object.witnessAsync (o1js/src/lib/provable/types/witness.ts:67:14)
      at get (o1js/src/lib/mina/actions/offchain-state.ts:194:17)
      at Object.get (o1js/src/lib/mina/actions/offchain-state.ts:266:16)
      at Pool.createFirstDeposit (src/Pool.ts:107:21)
      at Pool.wrappedMethod (o1js/src/lib/mina/zkapp.ts:306:22)
      at src/Factory.test.ts:133:7
      at node_modules/o1js/src/lib/mina/transaction.ts:431:9
      at generateWitness (o1js/src/lib/provable/core/provable-context.ts:90:5)
      at Object.runUnchecked (o1js/src/lib/provable/provable.ts:191:5)
      at createTransaction (o1js/src/lib/mina/transaction.ts:430:7)
      at node_modules/o1js/src/lib/mina/local-blockchain.ts:334:18
      at Object.<anonymous> (src/Factory.test.ts:131:18)
boray commented 2 weeks ago

Are we sure this is an o1js bug and not related to the how it's used in the project mentioned on Discord?

mitschabaude commented 2 weeks ago

Are we sure this is an o1js bug and not related to the how it's used in the project mentioned on Discord?

no!

boray commented 1 week ago

The Pool contract is deployed manually with the vk in the Factory contract. The Pool contract is not initialized automatically, and the init method needs to be called explicitly. The error disappears once it is initialized.