Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add check to assert proofs are attached if required #1095

Merged
merged 2 commits into from
Aug 30, 2023

Conversation

Trivo25
Copy link
Member

@Trivo25 Trivo25 commented Aug 29, 2023

If the developer forgot to invoke await tx.prove() but the transaction/account update expected a proof, sending said transaction resulted in an ugly OCaml assertion error that didn't indicate what was wrong with it. This is an edge case that only impacted proofs, missing signatures are already handled elsewhere and produce an understandable error message.

Assert_failure src/lib/transaction_logic/zkapp_command_logic.ml:1266:17
      at raise_error (../../../../home/gregor/.opam/4.14.0/lib/js_of_ocaml-compiler/runtime/jsoo_runtime.ml:110:3)
      at apply_json_transaction (../../../../workspace_root/src/lib/snarky_js_bindings/lib/snarky_js_bindings_lib.ml:2933:11)
      at caml_call_gen (../../../../builtin/+stdlib.js:32:12)
      at Object.applyJsonTransaction (../../../../builtin/+jslib.js:289:12)
      at Object.sendTransaction (node_modules/snarkyjs/src/lib/mina.ts:436:16)
      at sendTransaction (node_modules/snarkyjs/src/lib/mina.ts:1021:10)
      at Object.send (node_modules/snarkyjs/src/lib/mina.ts:299:14)
      at Object.<anonymous> (src/lending/Lender.test.ts:427:20)

new error message:

Error: The actual authorization does not match the expected authorization kind.
            Did you forget to invoke `await tx.prove();`?
    at Object.sendTransaction (snarkyjs/src/lib/mina.ts:472:17)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at null.sendTransaction (snarkyjs/src/lib/mina.ts:1184:10)
    at Object.send (snarkyjs/src/lib/mina.ts:325:16)
    at async file:///home/trivo/Development/snarkyjs/src/examples/simple_zkapp.tmp.js:71:1

closes #808

Copy link
Member

@mitschabaude mitschabaude left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved with one comment!

src/lib/mina.ts Outdated
if (kindIsProof && !authIsProof) {
throw Error(
`The actual authorization does not match the expected authorization kind.
Did you forget to invoke \`await tx.prove();\`?`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you remove the white space at the start of this line? So that it doesn't show up in the error?

@Trivo25 Trivo25 merged commit 8cb0cf8 into main Aug 30, 2023
13 checks passed
@Trivo25 Trivo25 deleted the fix-signature-contract branch August 30, 2023 20:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Better error message for not invoking AccountUpdate.requireSignature()
2 participants