A Comparative Analysis of Transaction Costs of the Four Major Layer 2 Solutions

W3.Hitchhiker
2022-03-16 21:27:51
Collection
Compare the transaction costs of various Layer 2 solutions to understand the advantages and disadvantages of each solution.

Author: Xiang|W3.Hitchhiker

Revised by: Marina, Evelyn|W3.Hitchhiker

With the rise of Ethereum, we have witnessed the rapid development of decentralized finance (DeFi) and the explosive growth of non-fungible tokens (NFTs). However, Ethereum can only process less than 20 transactions per second (TPS), and the gas fees have surged due to network congestion. Before these networks can be effectively adopted on a larger scale, higher throughput and lower costs are undoubtedly required. However, the scalability of ETH 2.0 will take time, and in the medium to short term, Layer 2 solutions can address the inefficiencies faced by the main network while still maintaining the integrity of the Ethereum blockchain.

Here are the reasons why Layer 2 is worth paying attention to:

  • Layer 2 networks will be faster and cheaper, allowing more users to enter the Ethereum ecosystem;

  • Early participation in Layer 2 networks can yield rewards;

  • With the anticipated development of Layer 2, users can migrate their assets to the second-layer network, which has a high probability of receiving airdrops;

Therefore, Layer 2 is also one of the most important highlights this year. For users, aside from a comfortable experience, the most concerning aspect is still the transaction cost. This article starts from comparing the transaction costs of various Layer 2 solutions, making it easier for readers to understand the advantages and disadvantages of each solution more clearly.

1. Layer 2 Scaling Technologies

According to data from L2BEAT, there are currently 19 Layer 2 projects, with total TVL growing from $48.2M at the beginning of 2021 to $5.63B, an increase of 11,580%. The rapid growth of Layer 2 is closely related to capital influx and adjustments in the underlying technology solutions.

Currently, there are four main technical solutions: Optimistic Rollup, ZK Rollup, Plasma, and Validium.

Comparison of Transaction Costs for Four Major Layer 2 Solutions

2. Gas Fees for Each Solution

Comparison of Transaction Costs for Four Major Layer 2 Solutions

Costs of the Four Major Solutions

【The above calculations assume the current ETH price is $2500, block gas limit is 30,000,000, gas fee is 30 Gwei, and average block time is 13 seconds. The maximum TPS refers to the scenario where the corresponding operating environment occupies all Ethereum block space (spending 500,000 gas on proof verification), while the normal TPS refers to the scenario where the corresponding operating environment occupies one-third of all Ethereum block space.】

▶️ Calculation Method

Comparison of Transaction Costs for Four Major Layer 2 Solutions

As shown in the figure above, a normal ETH transfer requires about 112 bytes, ZK compresses it to 12 bytes, and OP series compresses it to 78.4 bytes (not fixed, assuming a 30% space reduction). Assuming a swap transfer requires about 180 bytes, ZK compresses it to 14 bytes, and OP series compresses it to 126 bytes.

On the existing Ethereum chain, the gas limit is 30 million, and each non-zero byte of calldata in a transaction requires 16 gas, while zero bytes require 4 gas. If ZK occupies all of Ethereum's block space (spending 500k gas on proof verification), ignoring the number of zero bytes.

Then this batch can have (29,500,000 / 16) = 1,843,750 bytes of data. As shown, each ETH transfer operation only requires 12 bytes, which means this batch can contain up to 153,645 transactions. Under the average block time of 13 seconds, this translates to ~11,818 TPS (in contrast, transferring ETH directly on Ethereum itself results in 13,000,000 / 21,000 / 13 ~= 101 TPS).

From this, it can be seen that the scalability of ZK Rollup for transferring ETH has increased by over 100 times, and the maximum advantage of ZK is not in transferring ETH. Compared to transferring ERC20 contract tokens, the gas limit consumed on the mainnet is higher, making the cost-effectiveness of ZK Rollup even greater. The scalability of ZK Rollup compared to Uniswap transactions on the mainnet can improve by over 400 times.

Similarly, the scalability and maximum TPS of the Optimistic series can also be calculated.

Note: EIP-4488 and EIP-4844 will significantly reduce the costs of rollups.

1. Transaction Fees of ZK Rollup

In zkSync, the cost of each transaction consists of two components:

  • Off-chain part (storage + prover cost): The cost of state storage and SNARK (zero-knowledge proof) generation.

    (This part depends on the use of hardware resources, so it is constant. Our baseline estimate is about $0.001 per transfer.)

  • On-chain part (gas cost): For each zkSync block, the verifier must pay Ethereum gas to verify the SNARK, and additionally, each transaction pays about 0.4k gas to publish the state ∆.

    (The on-chain part is a variable, depending on the current gas price on the Ethereum network. However, this part is several orders of magnitude cheaper than the cost of regular ETH/ERC20 transfers.)

Comparison of Transaction Costs for Four Major Layer 2 Solutions

(1) Transaction Fee Floor Price

The transaction floor price of ZK rollup depends on the gas fees of the ETH mainnet.

On-chain gas fee = price per wei * transaction size * gas cost * token risk factor

Comparison of Transaction Costs for Four Major Layer 2 Solutions

The more ZK Rollup is used, the lower the fees become. OP and AR have similar mechanisms. As the number of user state updates increases, the gas fees paid by ZK to Layer 1 will relatively decrease, but this is not distributed to users.

  • Off-chain part: The cost of generating SNARK (zero-knowledge proof). This part depends on the use of hardware resources, so it is constant. Our estimate is about $0.001 per transfer.

    Actual size = (zkpcostchunk * opchunks) * tokenusd_risk;
    Regular transaction off-chain gas cost = 0.001 * 2 * 1 = 0.002u
    Off-chain gas cost for transactions received by new addresses = 0.001 * 6 * 1 = 0.006u
    Off-chain gas cost for swaps = 0.001 * 5 * 1 = 0.005u

▶️ Verification process reference in the code block below:

Comparison of Transaction Costs for Four Major Layer 2 Solutions

Comparison of Transaction Costs for Four Major Layer 2 Solutions

Comparison of Transaction Costs for Four Major Layer 2 Solutions

Comparison of Transaction Costs for Four Major Layer 2 Solutions

  • On-chain part (gas cost): For each zkSync block, the verifier must pay Ethereum gas to verify the SNARK, and additionally, each transaction pays about 0.4k gas to publish the state. The on-chain part is a variable, depending on the current gas price on the Ethereum network. However, this part is several orders of magnitude cheaper than the cost of regular ETH/ERC20 transfers.

    Actual size = price per wei * transaction size * gas cost * current gas price * token risk factor
    = weipriceusd * gastxamount * scalegasprice * tokenusdrisk

    Assuming the ETH price is $2500 and the current gas price is 30 Gwei

    Regular transaction on-chain gas cost = 2500/10^18 * (0 + 300 + 2002)(30*10^9) * 1.31 = 0.068u
    On-chain gas cost for transactions received by new addresses = 2500/10^18 * (0 + 940 + 2006)(30*10^9) * 1.31 = 0.20865u

    Assuming the ETH price is $2500 and the current gas price is 30 Gwei

    Regular transaction on-chain gas cost = 2500/10^18 * (0 + 300 + 200*2) * (30*10^9) * 1.3 * 1 = 0.068u
    On-chain gas cost for transactions received by new addresses = 2500/10^18 * (0 + 940 + 200*6) * (30*10^9) * 1.3 * 1 = 0.20865u

    ▶️

    The gastxamount for swaps = on-chain verification cost + submission cost + Chunk * Swap Chunk parameters (0 + 710 + 200*5)
    The on-chain cost for swaps = 2500/(10^18) * (0 + 710 + 200*5) * (30*10^9) * 1.3 * 1 = 0.1667u

▶️ The verification process is as follows:

Comparison of Transaction Costs for Four Major Layer 2 Solutions

Comparison of Transaction Costs for Four Major Layer 2 Solutions

Comparison of Transaction Costs for Four Major Layer 2 Solutions

Comparison of Transaction Costs for Four Major Layer 2 Solutions

Comparison of Transaction Costs for Four Major Layer 2 Solutions

Comparison of Transaction Costs for Four Major Layer 2 Solutions

Comparison of Transaction Costs for Four Major Layer 2 Solutions

Comparison of Transaction Costs for Four Major Layer 2 Solutions

Comparison of Transaction Costs for Four Major Layer 2 Solutions

Comparison of Transaction Costs for Four Major Layer 2 Solutions

Comparison of Transaction Costs for Four Major Layer 2 Solutions

Total cost = On-chain + Off-chain

Regular transaction total cost = 0.002 + 0.068 = 0.07 u

Total cost for transactions received by new addresses = 0.005 + 0.20865 = 0.21365 u

Total cost for swaps = 0.005 + 0.1667 = 0.1672 u

(2) Factors Affecting the Floor Price

The transaction floor price of Rollup depends on the gas fees of the ETH mainnet calldata.

The relevant EIPs for ETH gas that are in draft stage mainly include EIP4488, which will reduce the gas cost of non-zero byte calldata from 16 gas to 3 gas, significantly impacting Layer 2 TPS, benefiting Layer 2 Rollups, and greatly reducing the transaction costs of Rollups on the mainnet. The cost of non-zero byte data can be reduced to less than 1/5 of the current cost, and zero bytes can also be slightly reduced (ab, op, zk, etc. are expected to drop to the current 1/5 of the fees).

(3) Fee Payment Methods

Transfers in zkSync naturally support "gasless transactions": users pay transaction fees in the tokens being transferred. Therefore, for example, if you want to trade DAI stablecoin, you do not need to hold ETH or any other tokens. You only need to pay a small fee in DAI.

2. Transaction Fees of zkPorter

Currently, there is no zkPorter-related code on GitHub, and since zkPorter does not require on-chain data availability, the costs are expected to be significantly lower.

Mainly off-chain costs, transactions can be controlled at a constant fee of 1 to 3 cents. Quoted from the official documentation.

Comparison of Transaction Costs for Four Major Layer 2 Solutions

In zkSync 2.0, the L2 state will be divided into two aspects: ZK Rollup with on-chain data availability and zkPorter with off-chain data availability.

Comparison of Transaction Costs for Four Major Layer 2 Solutions

These two parts will be composable and interoperable: contracts and accounts on the ZK Rollup side will be able to seamlessly interact with accounts on the zkPorter side.

From the user's perspective, the only obvious difference is that zkPorter accounts have reduced fees by 100 times.

Imagine an application scenario: Uniswap deploys their smart contracts on the ZK Rollup side, and zkPorter accounts can perform swaps for less than $0.03. zkPorter accounts can make thousands of swaps on the Uniswap contract but only need to publish one update to Ethereum.

The data availability of zkPorter accounts will be protected by zkSync token holders (referred to as guardians). They will track the state on the zkPorter side by signing blocks to confirm the data availability of zkPorter accounts.

Guardians participate in proof of stake (PoS) with zkSync tokens, so any data availability failure will result in their slashing. This provides cryptoeconomic guarantees for data availability. It is important to note that the PoS in zkSync is much more secure than in other systems like sidechains. This is because zkSync guardians are essentially unable to steal funds. They can only freeze the zkPorter state (freezing their own stake). Each user can freely choose their own security threshold. Any user who wants all on-chain available data can fully remain on Rollup and use a ZK Rollup account.

Launch Time of zkSync 2.0 Mainnet

According to the official documentation article from January 31, 2022, zkPorter will launch on the mainnet alongside zkSync 2.0 within 6 months.

Comparison of Transaction Costs for Four Major Layer 2 Solutions

3. Arbitrum Gas Mechanism

Arbgas fees will vary depending on how users interact with Arbitrum, but the table below can serve as a general reference:

Comparison of Transaction Costs for Four Major Layer 2 Solutions

▶️ Some Code:

Comparison of Transaction Costs for Four Major Layer 2 Solutions

Comparison of Transaction Costs for Four Major Layer 2 Solutions

Comparison of Transaction Costs for Four Major Layer 2 Solutions

Comparison of Transaction Costs for Four Major Layer 2 Solutions

Comparison of Transaction Costs for Four Major Layer 2 Solutions

4. Optimism Gas Mechanism

There are two cost sources in Optimism transactions: L2 execution fees and L1 data/security fees.

(1) L2 Execution Fees

Just like on Ethereum, transactions on Optimism must pay gas for the amount of computation and storage they use. Each L2 transaction pays a certain execution fee, equal to the amount of gas used multiplied by the gas price attached to the transaction. This is also the charging method on Ethereum.

This is the (simple) formula:

l2executionfee = transactiongasprice * l2gasused

The amount of L2 gas used depends on the specific transaction you are trying to send, and the amount of gas used for transactions on Optimism is generally similar to that on Ethereum.

(2) L1 Data Fees

Optimism differs from Ethereum because all transactions on Optimism are also published to Ethereum. This step is crucial for the security properties of Optimism, as it means that all data required to synchronize Optimism nodes is always publicly available on Ethereum. This is what makes Optimism an L2.

Users on Optimism must pay the fees for submitting transactions to Ethereum. This is called L1 data fees, which is the main difference between Optimism (and other L2s) and Ethereum. Since gas costs on Ethereum are very expensive, L1 data fees often account for a significant portion of the total cost of transactions on Optimism. This fee is based on four factors:

  • The current gas price on Ethereum.

  • The gas cost of publishing the transaction to Ethereum. This is proportional to the size of the transaction length (in bytes).

  • A fixed fee priced in gas. Currently set at 2100.

  • A dynamic indirect fee, paid as a fixed number of L1 fees. Currently set at 1.24.

Formula:

L1datafee = L1gasprice * (txdatagas + fixedoverhead) * dynamicoverhead

3. Conclusion

As more and more applications connect to the blockchain, user adoption and transaction volume will grow exponentially. From DeFi, NFTs to DAOs, they will ultimately consume more throughput on Ethereum and generate more transaction costs, reducing the user experience and hindering the opportunity for blockchain to expand to a larger population.

L2s are currently the best solution for scaling Ethereum, providing high throughput and cheaper fees while effectively leveraging the security of L1s. However, as Layer 2 scaling solutions continue to be updated and adjusted, each solution has its own advantages and disadvantages. Overall, ZK Rollup has lower transaction fees, faster maximum/partial TPS, significantly improved scalability, and guarantees in security, followed by zkPorter; other solutions also have reduced transaction fees, but are slightly inferior compared to ZK Rollup.

In the future, we will see many projects migrating to or creating on L2, thereby improving the user experience. As one of the hottest trends in 2022, L2s will continue to build a large and loyal user base, which will become one of the most important developments for Ethereum.

ChainCatcher reminds readers to view blockchain rationally, enhance risk awareness, and be cautious of various virtual token issuances and speculations. All content on this site is solely market information or related party opinions, and does not constitute any form of investment advice. If you find sensitive information in the content, please click "Report", and we will handle it promptly.
banner
ChainCatcher Building the Web3 world with innovators