Transaction fee
Overview
Wischain offers significantly lower fees compared to its underlying layer, making it an attractive option for both users and developers. While transaction fees on Wischain resemble those on the Ethereum mainnet, it is essential to understand that the fee displayed in a wallet does not represent the complete picture unless the software explicitly accounts for Wischain's fee calculations.
The transaction costs on Wischain are influenced by the fees associated with Layer 1 (L1), as Wischain is designed as an L2 rollup that leverages Ethereum’s security. This means that Wischain must factor in the expenses related to transaction data and proofs that must be stored and validated on the L1.
In contrast to the Ethereum mainnet, Wischain introduces additional considerations for calculating transaction fees. The total cost of a transaction comprises several components:
L2 Fee: This is calculated similarly to L1 fees, using the formula: [ \text{L2 Fee} = \text{gas_price} \times \text{gas_used} ]
L1 Fee: This supplementary fee accounts for the transmission of data to L1 for data availability. Transactions initiated on the L1 do not incur this fee. The L1 fee is determined based on the size of the transaction’s calldata. The cost in ETH is automatically deducted from the user's balance on Wischain.
In essence, the total transaction fee is computed as: [ \text{totalTxFee} = \text{L2 Fee} + \text{L1 Fee} ] All fees are denominated in ETH, which is the native gas token for the Wischain network.
Allocation of Transaction Fees
All transaction fees are aggregated into the L2WischainFeeVault
contract balance. This contract tracks the total amount withdrawn to L1 through the totalProcessed()
method (uint256).
Block producers do not receive direct rewards from transaction fees; instead, the COINBASE opcode directs rewards to the fee vault address.
L2 Fee Structure
Just like Ethereum, transactions on Wischain must cover the costs associated with executing computations and storing data.
Calculating the Execution Fee
The L2 execution fee can be determined by: [ \text{l2TransactionExecutionFee} = \text{l2TransactionGasUsed} \times \text{l2TransactionGasPrice} ] The total fee is contingent upon the specific operations executed by the transaction (i.e., l2TransactionGasUsed
) and the prevailing market conditions (i.e., l2TransactionGasPrice
). Users can set the gas price, while the gas usage is estimated by invoking the estimateGas
endpoint on a Wischain node.
This method of fee calculation mirrors that of Ethereum prior to EIP-1559.
L1 Fee Structure
Every transaction’s calldata must be committed to Ethereum, resulting in an additional transaction fee known as the "L1 Fee." Without this fee, Wischain could not be accurately reconstructed from L1 data.
Transactions are not committed individually; instead, they are batched together in blocks. The cost for each transaction is calculated based on the number of zero and non-zero bytes in its payload.
Estimating the L1 Data Fee
Wischain has deployed an L1GasPriceOracle at address:
0x......
, accessible on both Wischain Mainnet and Wischain Sepolia. This oracle provides a getL1Fee
method to estimate the L1 data fee for a given transaction’s raw data.
Handling Gas Price Fluctuations on L1
Once a transaction has been processed by the sequencer, the user's L1 fee becomes fixed, meaning subsequent fluctuations in gas prices will not affect their cost.
Due to Wischain's short block times, changes in L1 gas prices between a transaction’s submission and its inclusion in a block are generally minimal. The sequencer absorbs any variations in L1 gas costs during the period from when a transaction is included in a block to when the sequencer commits the data to L1.
Calculating the L1 Data Fee with the Gas Oracle
The L1GasPriceOracle provides estimates for the L1 gas fee based on raw transaction data. This is a push oracle, updated by a relayer managed by Wischain.
The data fee is influenced by various factors:
The count of zero and non-zero bytes in an RLP-encoded transaction, including its signature.
l1BaseFee
: The current base fee on L1.overhead
: The additional gas overhead for a data commitment transaction.scalingFactor
: A factor to adjust for price spikes.PRECISION
: A constant used to scale the final fee.
To compute the L1 data fee, follow these steps:
Retrieve the values for
l1BaseFee
,overhead
, andscalar
from the L1GasPriceOracle contract.Count the number of zero and non-zero bytes in the transaction.
Calculate the L1 data fee using the following formulas: [ l1Gas = \text{zeros} \times TX_DATA_ZERO_GAS + (\text{nonzeros} + 4) \times TX_DATA_NON_ZERO_GAS ] [ l1GasFee = \left(\frac{(l1Gas + overhead) \times l1BaseFee \times scalar}{PRECISION}\right) ]
L1 Originated Transactions
When sending messages from L1 to L2, the user incurs all transaction fees on L1. While the user pays L1 gas fees, they are exempt from the Wischain L1 Data Fee. However, they still need to account for L2 Execution Fees in their L1 transactions and must be aware of how much L2 gas to allocate.
Contracts on L1 can utilize an L2 Gas Price Oracle deployed on L1 to obtain gas fee estimates for specific transactions. The oracle also provides the current l2BaseFee
and estimated cross-domain message fees for given gas limits.
On the mainnet, the L2GasPriceOracle is available at :
0x......
On Sepolia, an upgraded version known as L1MessageQueueWithGasPriceOracle can be accessed at:
0x.....
.
Upgrade Notice Following the Bridge Upgrade scheduled for February 2024, the L2GasPriceOracle will be deprecated in favor of the L1MessageQueueWithGasPriceOracle, set to be available at:
0x.....
The upgrade is anticipated to be finalized on February 21, 2024, after a two-week timelock. Wischain Sepolia has already undergone this upgrade. More details can be found here.
Future Roadmap
Currently, the computational requirements for proof generation and the associated gas for proof verification on L1 are subsidized by Wischain and various proving partners, partially funded by setting a minimum for L2 Gas Prices.
As the prover network becomes increasingly decentralized, it will be necessary to incorporate incentives for proof generation within the protocol to ensure sustainability and scalability.
We anticipate that the final gas costs will explicitly reflect the expenses associated with proof generation. However, with further optimizations to the protocol, the cost for users should remain minimal, as each proof is designed to cover multiple transactions.
Last updated