A comparison of transaction costs for Layer2's four solutions

22-03-16 20:00
Read this article in 38 Minutes
总结 AI summary
View the summary 收起
Article title: Transaction Cost Comparison of Four Layer2 Solutions
Author: Xiang, W3.Hitchhiker
Hitchhiker, Marina, Evelyn, W3

With the rise of Ethereum, we have seen the rapid growth of decentralized finance (DeFi) and now the explosive growth of non-homogeneous tokens (NFT). However, Ethereum can only process less than 20 transactions per second (TPS), and gas fees have increased significantly due to congestion on the Ethereum network. Higher throughput and lower costs will undoubtedly be required before these networks can be more widely and effectively adopted. However, it will take time to scale up ETH 2.0, and in the short to medium term, Layer 2 solutions can address the inefficiencies faced by major networks while still maintaining the integrity of the Ethereum blockchain.


At Layer 2, the reasons for concern are as follows:


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

- Participate in the incentive of Layer 2 network in advance and get rewards;

- Under the expectation of the development of Layer 2, users can migrate assets to Layer 2 network, and there will be a high probability of airdrop;


Therefore, Layer 2 is one of the most important things to watch this year. For users, in addition to experience comfort, the biggest concern is transaction costs. This paper compares the transaction costs of various Solutions of Layer 2, so that readers can have a clearer understanding of the advantages and disadvantages of each solution.


1. Expansion technology of Layer 2


L2BEAT data shows that layer 2 currently has 19 projects and the total TVL has grown from $48.2m at the beginning of 2021 to $5.63b, a 11580% increase in total TVL. The rapid growth of Layer 2 is closely related to the influx of capital and the adjustment of technical solutions behind it.


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



Gas costs for each solution



Each of the four plans has its own costs


[The above calculation is based on the current Eth price of 2500U, block GASlimit of 30000000, gas cost of 30Gwei, and average block production time of 13 seconds. Limit TPS means that the corresponding operating environment occupies all ethereum block space (500,000 gas for proof and verification), normal TPS means that the corresponding operating environment occupies 1/3 of all Ethereum block space.


Calculation method



As shown in the figure above, eth transfer requires about 112 bytes, ZK is compressed to 12 bytes, op is compressed to 78.4 bytes (not fixed, assuming 30% space compression), suppose swap transfer requires about 180 bytes, ZK is compressed to 14 bytes. The OP system is compressed to 126 bytes.


On the existing Ethereum chain, gas is capped at 30 million, 16 gas per non-zero byte of Calldata and 4 gas per zero byte of calldata in a transaction. If ZK occupies all of ethereum's block space (spending 500K gas on proof verification), ignore the number of 0 bytes.


Then the batch can have (29.5 million / 16) = 1,843,750 bytes of data. As shown above, the ETH transfer summary for each user operation takes only 12 bytes, meaning that the batch can contain up to 153,645 transactions. At an average block generation time of 13 seconds, this translates to ~11,818 TPS (compared to 13 million / 21000/13 ~= 101 TPS for ETH transmitted directly on Ethernet).


由上可知 ZK Rollup 转账 eth 的可扩展性提高了 100 + 倍,而 zk 最大优势不在于转账 eth,相比转账 erc20 的合约 Token ,与 uniswap 交易来算,主网消耗的 gaslimit 的更多,ZK Rollup 压缩的性价比也越高,ZK Rollup 相比主网的 uniswap 交易拓展可提高 400+倍。


Similarly, the extensibility and limit TPS of Optimistic systems can be calculated.


Note: IP-4488, IP-4844 will significantly reduce rollup costs.


1. Transaction costs of ZK Rollup


In zkSync, the cost per transaction has two components:


Off-chain part (storage + prover cost) : cost of state storage and SNARK generation.


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


On-chain portion (GAS cost) : For each zkSync block, the verifier must pay Ethereum gas to validate the SNARK, plus an additional payment of approximately 0.4 K gas per transaction to publish the status.


The on-chain portion is a variable that depends on the current gas price in the Ethereum network. However, this part is several orders of magnitude cheaper than a normal ETH/ERC20 transfer.)



(1) Transaction cost floor price


The transaction floor price of ZK Rollup is dependent on the cost of ETH main network gas.


链上 gas fee = 每 wei 的价格 * 交易大小 * gas 的费用 * Token 的风险系数



Does ZK Rollup cost less when used more OP and AR have similar mechanisms? The number of users' states is updated, and the more users use it, the Gas cost paid by ZK to layer1 will be relatively less, but it is not evenly distributed to users.


Below the chain:  Cost of SNARK (Zero knowledge proof) generation. This part depends on the use of hardware resources and is therefore constant. Our estimate is about $0.001 per transfer basis.


Actual size = (zkp_cost_chunk * OP_chunks) * token_usd_risk;

Off-chain gas cost for normal transactions = 0.001 * 2 * 1 = 0.002 U

The cost of off-chain gas with the transaction receiver as the new address = 0.001 * 6 * 1 = 0.006U

The off-chain gas cost of swap =0.001 * 5 * 1 = 0.005U


Refer to the following code block for the verification process:



On-chain portion (gas cost): For each   zkSync  Block, the verifier must pay Ethereum Gas to validate SNARK, plus an additional payment of approximately 0.4 K gas per transaction to publish the status. The on-chain portion is a variable that depends on the current gas price in the Ethereum network. However, this part is several orders of magnitude cheaper than the cost of a normal ETH/ERC20 transfer.


实际大小= 每 wei 的价格 * 交易大小 * gas 的费用 * 当前 gas 价格 * Token

Risk factor of

= wei_price_usd*gas_tx_amount*scale_gas_price*token_usd_risk


Assume the ETH price is 2500U and the current gas price is 30Gwei


On-chain gas cost for normal transactions = 2500/10^18*(0+300+2002)(30*10^9)1.31 = 0.068U

The cost of on-chain gas with the transaction receiver as the new address = 2500/10^18*(0+940+2006) (30*10^9)1.31 = 0.20865 U


Assume the ETH price is 2500U and the current gas price is 30Gwei


The on-chain gas cost of a normal transaction = 2500/10^18*(0+300+200*2)* (30*10^9)*1.3*1 = 0.068U

The cost of on-chain gas with the transaction receiver as the new address = 2500/10^18*(0+940+200*6)* (30*10^9)*1.3*1 = 0.20865 U


Swap gas_tx_amount = on-chain validation cost + commit cost + Chunk * swap Chunk parameter (0 + 710 + 200*5)

The swap chain cost = 2500 / (10 ^ 18) * (0 + 710 + 200 * 5) * 30 * 10 ^ (9) * 1.3 * 1 = 0.1667 u


The verification process is as follows:



Total cost = up chain + down chain

General transaction total cost = 0.002 + 0.068 = 0.07U

Total cost of transaction receiver for new address = 0.005 + 0.20865 = 0.21365 U

Total swap cost = 0.005 + 0.1667 = 0.1672 U


(2) The factor that affects floor price


The transaction floor price of Rollup depends on the fee of calldata on ETH main network.


The EIP related to ETH gas in the draft stage is mainly EIP4488. This scheme reduces the calldata non-zero byte data from 16gas to 3 gas, which has a great impact on layer2 TPS and is good for layer2 Rollup. The transaction cost of Rollup main network can be greatly reduced. Non-zero byte data can be reduced to less than 1/5 of the current cost, and zero byte data can also be slightly reduced (AB, OP, ZK, etc., are expected to be reduced to 1/5 of the current fee).


(3) Payment method


zkSync 中的转账天然支持「无气体交易」:用户在被转账的 Token 中支付交易费用。因此,例如,如果您想交易 DAI 稳定币,您无需拥有 ETH 或任何其他 Token 。只需支付一小部分 DAI 的费用。


2. Transaction costs of zkPorter


Github currently has no code for zkPorter, which is expected to be significantly cheaper as zkPorter does not require on-chain data availability.


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



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



The 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.


The only significant difference from the user's point of view is the 100-fold reduction in fees for the zkPorter account.


Imagine an application scenario: Uniswap deployable their smart contract at the ZK Rollup end and zkPorter accounts can be swapped for less than $0.03. ZkPorter accounts can be exchanged thousands of times on Uniswap contracts, but only one update is published to Ethereum.


zkPorter 账户的数据可用性将由 zkSync Token 持有者(称为监护人)保护。他们将通过签署区块来跟踪 zkPorter 端的状态,以确认 zkPorter 帐户的数据可用性。


监护人使用 zkSync Token 参与权益证明 (PoS),因此任何数据可用性故障都将导致他们被削减。这为数据可用性提供了加密经济保证。需要注意的是,zkSync 中的 PoS 比侧链等其他系统中的 PoS 安全得多。这是因为 zkSync 监护人本质上是无法窃取资金。他们只能冻结 zkPorter 状态(冻结他们自己的权益)。每个用户都可以自由选择自己的安全阈值。任何想要所有链上可用数据的用户都可以完全留在 Rollup, 使用 ZK Rollup 账号。


Zksync2.0 Main network online time


ZkPorter will be available on the main network with ZKSync2.0 in 6 months, according to the official document on January 31, 2022.



3. Arbitrum Gas mechanism


Arbgas fees will vary according to the way users interact with Arbitrum, but the following table can be used as a general reference:



Part code:



4. Optimism Gas


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


(1) L2 execution fee


Just as on Ethereum, transactions on Optimism must pay gas for the amount of computation and storage they use. Each L2 transaction pays an execution fee equal to the amount of gas used in the transaction multiplied by the gas price attached to the transaction. That's how Ethereum charges.


Here's the (simple) formula:


l2_execution_fee = transaction_gas_price * l2_gas_used


The amount of L2 gas used depends on the particular transaction you're trying to send, and transactions typically use roughly the same amount of gas on Optimism as they do on Ethereum.


(2) L1 data fee


Optimism differs from Ethereum in that all transactions on Optimism are also published to Ethereum. This step is critical to the security attribute of Optimism, because it means that all the data needed to synchronize the Optimism nodes is always publicly available on Ethereum. That's what makes Optimism L2.


People on Optimism must pay a fee to submit transactions to Ethereum. Called the L1 data charge, this is the main difference between Optimism (and other L2S) and Ethereum. Since the cost of gas on Ethereum is very expensive, the L1 data charge usually accounts for the overall cost of the transaction in Optimism. The cost is based on four factors:


- Current gas price of Ethereum.

- Gas costs to publish transactions to Ethereum. The size (in bytes) of this transaction length is proportional.

- Fixed charges in gas terms. The current setting is 2100.

- A dynamic overhead fee with a fixed figure L1 fee. The current setting is 1.24.


Formula:


L1_data_fee = L1_gas_price * (tx_data_gas + fixed_overhead) * dynamic_overhead

Third, summary


As more and more applications connect to blockchain, user adoption and transactions will grow exponentially. From DeFi to NFT to DAOs, they will ultimately consume more throughput and generate more transaction costs on Ethereum, making it less of an experience to use, thus impeding the opportunity for blockchain to expand to a larger population.


L2s is currently the best solution for Ethereum expansion, taking advantage of the security of L1s while providing high throughput and lower cost. However, as Layer 2 expansion solutions are constantly updated and adjusted, each solution has its own advantages and disadvantages. In general, ZK rollup has lower transaction costs, faster limit/partial TPS, greatly improved maximum scalability and guaranteed security, followed by ZK Porter. Other solutions also have lower transaction costs, but they are less expensive than the ZK Rollup.


In the future, we will see many projects migrated or created on L2 to improve the user experience. As one of the hottest trends of 2022, L2s will continue to build a large and loyal user base, which will become one of ethereum's most important developments.


The original link


欢迎加入律动 BlockBeats 官方社群:

Telegram 订阅群:https://t.me/theblockbeats

Telegram 交流群:https://t.me/BlockBeats_App

Twitter 官方账号:https://twitter.com/BlockBeatsAsia

举报 Correction/Report
Choose Library
Add Library
Cancel
Finish
Add Library
Visible to myself only
Public
Save
Correction/Report
Submit