zkopru-network / zkopru

Ethereum L2 scaling solution for private transactions using zk-SNARK and optimistic rollup.
https://zkopru.network
GNU General Public License v3.0
216 stars 28 forks source link

A limit of mass deposits in a single Propose transaction #382

Open sifnoc opened 2 years ago

sifnoc commented 2 years ago

Currently, the massDeposits which are not included are over 300 in testnet. That was accumulated by long periods of absent coordinators activity. That is a low possible scenario in zkopru protocol in production. Anyway, It happened in testnet and we should be considered that.

The error log shows what happens over the limit of size massDeposits can be included in one Propose tx.

[1647770286864] INFO (3505 on 51f58fd1afd8): Picked txs: 0
[1647770286864] INFO (3505 on 51f58fd1afd8): Pending txs: 0
[1647770286880] INFO (3505 on 51f58fd1afd8): Trying to create a child block of 0xa69837df7fd12f315b8c1fac35ec7146d9114c0a6ccbd0771e8755da5229fd07
[1647770286887] ERROR (3505 on 51f58fd1afd8): Uncaught error in task
[1647770286888] ERROR (3505 on 51f58fd1afd8): Exceeds the given buffer size
    Error: Exceeds the given buffer size
        at hexToBuffer (/src/packages/utils/dist/index.js:123:15)
        at Object.numToBuffer (/src/packages/utils/dist/index.js:174:12)
        at serializeMassDeposits (/src/packages/core/dist/block/utils.js:128:39)
        at Object.serializeBody (/src/packages/core/dist/block/utils.js:157:9)
        at Coordinator.<anonymous> (/src/packages/coordinator/dist/coordinator.js:286:24)
        at Generator.next (<anonymous>)
        at fulfilled (/src/packages/coordinator/dist/coordinator.js:5:58)
[1647770286898] ERROR (3505 on 51f58fd1afd8): coordinator/coordinator.ts - Error occurred during block proposing: Error: Exceeds the given buffer size

Only 255 massDeposits can be included in a single Propose transaction.

https://github.com/zkopru-network/zkopru/blob/fd3b7183861e80d575d773900889b504daa5a3e6/packages/core/src/block/utils.ts#L141

That is possible to happen error in withdrawals MassMigrations. I am not calculating yet. the one inflow, two outflows type of zktxs maximally included around 222, https://github.com/zkopru-network/zkopru/issues/343#issuecomment-996815844 That means it possibly over 255 withdrawals zkTx if all zktx has massmigration with 1 inflow 1 outflow type in single propose transaction.

sifnoc commented 2 years ago

We should running the coordinator with maxBytes as 65536(= 64 * 1024, 64kb), half of value in current, before fixing calculation of tx size in properly. the remains is for massMigration space in propose tx.