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
475 stars 105 forks source link

Payload Too Large error is thrown on devnet for transactions involving 3 zkApp accounts #1607

Closed dfstio closed 2 months ago

dfstio commented 2 months ago

The following error is thrown on devnet with o1js 0.18.0:

Error: Transaction failed with errors:
- {"statusCode":413,"statusText":"Payload Too Large"}
    at Object.send (/Users/mike/Documents/DeFi/MinaNFT/minanft-lib/node_modules/o1js/dist/node/index.cjs:20902:15)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at sendTx (/Users/mike/Documents/DeFi/MinaNFT/minanft-lib/experimental/payload.issue.test.ts:640:14)
    at Object.<anonymous> (/Users/mike/Documents/DeFi/MinaNFT/minanft-lib/experimental/payload.issue.test.ts:601:5)

The same code works as intended on the local blockchain and Zeko. It occurs only on tx that include three zkApp accounts:

The code to reproduce the issue: https://github.com/dfstio/minanft-lib/blob/master/experimental/payload.issue.test.ts

It may be related to https://github.com/o1-labs/o1js/issues/1245#issuecomment-1972951258

dfstio commented 2 months ago

The tx that is causing this error: payload-issue.json

shimkiv commented 2 months ago

Hey @dfstio thanks for the issue reported! I noticed that you save txn payload into the file before txn gets proved that most likely will include additional "weight" to the request. I also noticed that you're using the Mina Explorer's Proxy to broadcast the transaction (send payload). Most likely that proxy has some request payload size limits. Can you please confirm if the issue happens to you using other broadcasting services as well (maybe your own node with graphql endpoint enabled, or the Lightnet)?

dfstio commented 2 months ago

I've tested, in addition, the https://api.minascan.io/node/devnet/v1/graphql endpoint and Lightnet; the error is being thrown only when using https://proxy.devnet.minaexplorer.com/graphql.

I've moved the code that serializes the tx after tx.prove(); below are the files that were produced for all three endpoints: payload-issue-lightnet.json payload-issue-minaexplorer.json payload-issue-minascan.json

dfstio commented 2 months ago

Discussion on discord: https://discord.com/channels/484437221055922177/583400552487059546/1232023018276917349

shimkiv commented 2 months ago

the error is being thrown only when using https://proxy.devnet.minaexplorer.com/graphql.

Thank you! I think we also need to check with other public txns broadcasting services if they have request size limits. We are going to raise it.

dfstio commented 2 months ago

The issue is resolved by increasing the limit on https://proxy.devnet.minaexplorer.com/graphql and tx is now successful: https://devnet.minaexplorer.com/transaction/5JuoKLjxvdYCHtByWmFR43uZXTgwtDUJvxhpu5N3qjpZrUZV8kMh