The operating costs of the layer 2 system mainly include: off-chain server resources and on-chain gas consumption, of which the latter takes the lion's share.
These costs will eventually go into the users' cost of use. Therefore, reducing operating costs is critical.
In the ZK Rollup scenario, there are mainly two on-chain operations:
- 1.Commit a block (commitblock), which contains the data of the layer-2 block and the layer-2 transaction information.
- 2.Verify a block (verifyblock), which is to verify the zero-knowledge proof on the chain. In the plonk proof system, 0.5 to 0.6m gas needs to be consumed.
In order to reduce the gas consumption of verifying zero-knowledge proofs on the chain, EdgeSwap introduces the
aggregate recursive proof technology, which verifies the proofs of multiple layer 2 blocks by verifying one aggregate proof. Specifically, the proof verification process of layer 2 blocks is realized through a circuit. In order to reduce the number of pairing circuit gates in the verification process, the pairing calculations are aggregated and then verified in the contract, so that only one proof need to be verified when verifying the proofs of multiple blocks.
We support verifying the zero-knowledge proofs of up to 36 layer 2 blocks. In order to balance the on-chain gas consumption and the on-chain confirmation time of layer 2 transactions, we set the maximum number of aggregate blocks for zero-knowledge proof to 18 blocks, reducing the cost of the proving process to 1/15 of the original.
Verification gas consumption (18 blocks)
At the same time, we have also realized the software optimization and hardware acceleration of the aggregate proof, thereby reducing the proving speed to 1/2 of the original, or even lower. The gas consumption per transaction in L1-DEX is 200,000. After actual calculation, the gas consumption per transaction in EdgeSwap is shown in the table below.
Swap (without amortization)
Swap (with amortization)
Through the above work, we have reduced the cost of each transaction to about a few tenths of a percent of that for layer 1 transaction in Ethereum.