Mantle 백서

Mantle

원문

bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 37쪽 중 5쪽

uish it from Ethereum's fees. As Mantle Network continuously enhances its EVM compatibility, dApps can conveniently adapt to any changes with minimal modifications. Let's explore the two sources of transaction costs on Mantle: 1. [**L2 Execution Fee**](#the-l2-execution-fee) * Cost of executing transactions on L2 2. [**L1 Rollup Fee**](#the-l1-rollup-fee) * Cost of submitting rollup state root to L1 (distributed equally among users whose transactions are included in the batch) * Write data credentials submitted to the DA contract on L1 ### The L2 Execution Fee[​](https://docs-v2.mantle.xyz/devs/concepts/tx-fee/overviews#the-l2-execution-fee) <a href="#the-l2-execution-fee" id="the-l2-execution-fee"></a> Similar to Ethereum, transactions on Mantle Network must pay the gas fee for the computational and storage resources used. Each L2 transaction incurs some execution fees, calculated as the product of the gas used and the gas price associated with the transaction. Mathematically, this is represented as: $$ L2ExecutionFee=L2GasPrice∗L2GasUsed $$ This fee reflects the computational and execution costs of completing transactions on the L2 network. The L2 execution fee paid by users is directly proportional to the computational and network resources consumed by their transactions. ### The L1 Rollup Fee[​](https://docs-v2.mantle.xyz/devs/concepts/tx-fee/overviews#the-l1-rollup-fee) <a href="#the-l1-rollup-fee" id="the-l1-rollup-fee"></a> All state roots generated on L2 due to transaction execution are published to Ethereum. This step is crucial for the security properties of L2, ensuring that all the latest block data from the L2 network is consistently available on Ethereum L1 for sync nodes. L2 aggregates states and essential transaction data into batches, publishing them to Ethereum, with the cost distributed among users whose transactions are included in the batch. The L1 rollup Fee is calculated based on factors such as: * The current gas price on Ethereum * A fixed `overhead` (a fixed cost for committing data to L1, auto-adjusted and set into gas oracle) * The scaling factor `scalar` * Parameters related to the size of the transaction are stored as calldata in L1 called `rollupDataGas` {% hint style="info" %} Values such as `overhead` and `scalar` can be obtained through the [`BVM_GasPriceOracle`](/network/system-information/off-chain-system/key-l2-contract-address) contract or [`SystemConfigProxy`](/network/system-information/off-chain-system/key-l2-contract-address) contract. **We highly recommend fetching the `overhead` and `scalar` from the** [**`BVM_GasPriceOracle`**](/network/system-information/off-chain-system/key-l2-contract-address) **contract.** L1 Contracts may be subject to update delays. {% endhint %} Mathematically, this is represented as: $$ L1RollupFee=(rollupDataGas+overhead)∗L1gasPrice∗scalar $$ This fee covers the computational costs of integrating and submitting transaction batches from L2 to L1, including the gas needed for data storage and additional overhead. The L1 rollup fee is a crucial component ensuring the overall system's secure operation and also affects the overall transaction costs. {% hint style="info" %} For a more in-depth understanding, it is highly recommended to read the Mantle research team's study on fees in Rollups: [Transaction Fees on Rollups](https://www.mantle.xyz/blog/research/transaction-fees-on-rollups) {% endhint %} ## Understanding Fees on Mantle v2[​](https://docs-v2.mantle.xyz/devs/concepts/tx-fee/overviews#understanding-fees-on-mantle-v2-tectonic) <a href="#understanding-fees-on-mantle-v2-tectonic" id="understanding-fees-on-mantle-v2-tectonic"></a> In Mantle v2, the introduction of Mantle's native token design incorporates a [`tokenRatio`](#control-of-tokenratio) parameter to adjust the fee: $$ L2ExecutionFee=L2gasPrice∗L2gasUsed∗tokenRatio $$ $$ L1RollupFee=(rollupDataGas+overhead)∗L1gasPrice∗tokenRatio∗scalar $$ ### L2 Execution Fee in Mantle v2[​](https://docs-v2.mantle.xyz/devs/concepts/tx-fee/overviews#l2-execution-fee-in-mantle-v2-tectonic) <a href="#l2-execution-fee-in-mantle-v2-tectonic" id="l2-execution-fee-in-mantle-v2-tectonic"></a> The size of the L2 Execution Fee is primarily influenced by two key factors that directly shape the cost of executing transactions on L2. $$ L2ExecutionFee=L2gasPrice∗L2gasUsed∗tokenRatio $$ Let's delve into these factors: #### **L2 gasUsed - Complexity of Transaction Execution**[**​**](https://docs-v2.mantle.xyz/devs/concepts/tx-fee/overviews#l2-gasused---complexity-of-transaction-execution) L2 gasUsed is the amount of gas consumed to execute a transaction on layer 2. This value is directly related to the complexity of the transaction and reflects the amount of work involved in executing the contract, computing, and processing the data. As a result, more complex transactions typically require more gas to complete, directly affecting the size of the L2 execution fee. This factor ensures that the transaction fee is proportional to the actual computational resources used. #### **L2 gasPrice - Depends on the transaction type**[**​**](https://docs-v2.mantle.xyz/devs/concepts/tx-fee/overviews#l2-gasprice---depends-on-the-transaction-type) L2 gasPrice is the unit price of gas used on L2, which depends on the specific transaction type chosen. L2 gasPrice is calculated differently for different transaction types: * **For** [**EIP-1559 transaction types**](/network/more/glossary#eip-1559-transaction), L2 gasPrice is affected by the `GasTipCap` parameter, which is a parameter that is issued as a reward to sequencers and can be set to `0` by the user and does not affect the packing of transactions. * **For** [**legacy transaction types**](/network/more/glossary#legacy-transaction), `GasTipCap` takes the default value (0.1 GWEI). In this case, `eth_gasPrice` is equal to the sum of `GasTipCap` and `BASEFEE`. This mechanism ensures the relative stability of the transaction costs, while providing the user with default values and simplifying the setup of the transaction parameters. Due to EVM compatibility, transactions on Mantle Network generally have similar `gasUsed` to Ethereum. Gas prices fluctuate with time and congestion, but you can always check the current estimated L2 Gas prices on the public Mantle dashboard. Moreover, as gas fees on Mantle Network are denominated in `$MNT`, transaction costs remain significantly lower than other L2 networks using $ETH as the gas token, even at the same gas price. {% hint style="info" %} The ordering of transactions is influenced by various factors. Here are examples illustrating the role of `GasTipCap` and transaction submission order: 1. Suppose Alice initiates a Legacy-type transfer transaction `tx_A`, followed by Bob initiating another Legacy-type transfer transaction `tx_B`. Since `tx_B` comes after `tx_A`, their order follows the First come first serve (FCFS) principle. 2. Suppose Alice initiates an EIP-1559-type transfer transaction `tx_A` and, before it is packed, initiates another `tx_B` with a higher Priority Fee (GasTipCap) than `tx_A`. Due to nonce conflict, the Sequencer rejects `tx_A` with the lower GasTipCap and prioritizes packing `tx_B`. {% endhint %} ### L1 Rollup Fee in Mantle v2[​](https://docs-v2.mantle.xyz/devs/concepts/tx-fee/overviews#l1-rollup-fee-in-mantle-v2-tectonic) <a href="#l1-rollup-fee-in-mantle-v2-tectonic" id="l1-rollup-fee-in-mantle-v2-tectonic"></a> Since the cost of transaction on L1 is much higher than that of transaction on L2, this is the largest part of the total transaction cost, and calculating the cost of L1 is a complex task due to the volatility of gasPrice in L1. $$ L1RollupFee=(rollupDataGas+overhead)∗L1gasPrice∗tokenRatio∗scalar $$ Let's delve into these factors: #### **`rollupDataGas`Calculation**[**​**](https://docs-v2.mantle.xyz/devs/concepts/tx-fee/overviews#rollupdatagas-calculation) The major portion of the L1 gas fee is `rollupDataGas`, which relates to the size of the transaction stored as calldata in L1, and typically accounts for more than 85% of the L1 GasUsed. Mantle v2 Tectonic chooses the Op Stack's rollupDataGas calculation, which counts the number of zero bytes and non-zero bytes in the transaction data, with each zero byte costing 4 Gas and each non-zero byte costing 16 Gas, thus: $$ rollupDataGas=count\_​zero\_​bytes(tx\_​data)∗4+count\_​non\_​zero\_​bytes(tx\_​data)∗16 $$ {% hint style="info" %} With the EigenDA module online with Mantle Mainnet, only state roots and a limited amount of necessary transaction data are sent to L1, while the transaction batch data is posted to the DA network. For dApps with high gas consumption, they can be executed at the same cost as an ordinary transaction (like a transfer), and the L1 fee will not increase with the complexity of L2 transaction execution. As a result, for transactions with high complexity, this can even save up to more than **90%** of the cost compared to the original L1 rollup fee. {% endhint %} #### **Fetch`overhead`and`scalar`**[**​**](https://docs-v2.mantle.xyz/devs/concepts/tx-fee/overviews#fetch-overhead-and-scalar) `overhead` and `scalar` are currently loaded from configurations, not supporting dynamic changes, you can fetch them from the [`BVM_GasPriceOracle`](/network/system-information/off-chain-system/key-l2-contract-address) contract, while `L1gasPrice` needs to be read from L1 blocks. #### **Control of tokenRatio**[**​**](https://docs-v2.mantle.xyz/devs/concepts/tx-fee/overviews#control-of-tokenratio) `tokenRatio` is a parameter adjusting fees in Mantle. By obtaining prices for ETH and MNT from multiple price oracles and calculating their exchange rate (`eth_price/mnt_price`), Mantle v2 Tectonic limits the value of the current `tokenRatio` to the interval of the previous `tokenRatio` to prevent sudden and significant fluctuations in gasPrice caused by abrupt changes in the exchange rate. Mantle v2 Tectonic introduces a [`BVM_GasPriceOracle`](/network/system-information/off-chain-system/key-l2-contract-address) contract in Layer 2 to manage permissions for setting and updating `tokenRatio`. Users with permission (a multi-signature address managed through [HSM](/network/more/glossary#hardware-security-module-hsm)) can update `tokenRatio` through an L2 transaction, dynamically adjusting gas fees. ## Fee Optimization[​](https://docs-v2.mantle.xyz/devs/concepts/tx-fee/overviews#fee-optimization) <a href="#fee-optimization" id="fee-optimization"></a> Compared to Mantle v1, Mantle v2 Tectonic has made improvements and optimizations in fee design, including: * **EIP-1559 Support**: Mantle v2 Tectonic will support various transaction types, including EIP-1559, freeing users from the constraints of old transaction structures. For more details, refer to [this](/network/system-information/fee-mechanism/eip-1559-support).&#x20; {% hint style="info" %} **We highly recommend you to set the `baseFee` to `0.02 gwei` and `priorityfee` to `0` in your L2 transaction.** Refer to [this](/network/for-developers/optimize-your-transaction-fees) for more details. {% endhint %} * **Fee Estimation**: The `estimateGas` API in Mantle v1 only returns the L2 gas cost, the L1 gas estimation needs to be calculated separately, while in Mantle v2 Tectonic it will support returning the total gas of the user's transaction directly. Developers also need to be mindful of the impact this optimization may have on transaction construction. For more details about how to calculate the gas fee, refer to [this](/network/system-information/fee-mechanism/estimate-fees). ### Mantle v2 Fee Showcase[​](https://docs-v2.mantle.xyz/devs/concepts/tx-fee/overviews#mantle-v2-tectonic-fee-showcase) <a href="#mantle-v2-tectonic-fee-showcase" id="mantle-v2-tectonic-fee-showcase"></a> | | Mantle v2 Tectonic | Mantle v1 Alpha | | ------------------------------ | ---------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------- | | **Token Transfer** | [0.0047 MNT](https://mantlescan.xyz/tx/0xba6ed5537f2eae416e0874a98f1523c70e3087225d21a2240864e0f720136b9e) | [0.3715 MNT](https://mantlescan.xyz/tx/0xc05fe72e047b8cdfa2ea6e31c26b0940844d4d7efbaadd9ffa3b2db9db20a139) | | **ERC-20 Contract Deployment** | [0.1088 MNT](https://mantlescan.xyz/tx/0x84c4ecb184fd198faa44fcbf57c8a0d4512c2993f2dc68d44d3cfd77595ca5b9) | [0.1304 MNT](https://mantlescan.xyz/tx/0xc4562d9622a9a5cc20a8c8aaa0df3b35e92066345835bd5fe95e94cd11fade7b) | # Native Token Migration Mantle v2 Tectonic, as a significant version update, focuses on optimizing and improving various aspects, including a transformation in the system's native token. In Mantle v2 Tectonic, $MNT will serve as the native token for the system. This change aims to provide users with a more flexible and efficient transaction experience, laying a solid foundation for the ecosystem's future development. ## Why Mantle v2 Tectonic Requires a Change[​](https://docs-v2.mantle.xyz/devs/concepts/native#why-mantle-v2-tectonic-requires-a-change) <a href="#why-mantle-v2-tectonic-requires-a-change" id="why-mantle-v2-tectonic-requires-a-change"></a> In Mantle v2 Tectonic, the decision to change the native token from an ERC-20-based scheme to one using Ether Gas stems from several reasons: ### 1. Closer Alignment With Native Ethereum Design[​](https://docs-v2.mantle.xyz/devs/concepts/native#1-closer-alignment-with-native-ethereum-design) <a href="#id-1-closer-alignment-with-native-ethereum-design" id="id-1-closer-alignment-with-native-ethereum-design"></a> Unlike Mantle v1, where we opted for ERC-20 tokens as the native token, Mantle v2 Tectonic aims for closer alignment with Ethereum's native design. This not only simplifies the development and maintenance processes, but also integrates Mantle v2 more naturally into the Ethereum ecosystem. ### 2. Facilitating Rollup Node Upgrades in Sync With the Mainnet[​](https://docs-v2.mantle.xyz/devs/concepts/native#2-facilitating-l2-node-upgrades-in-sync-with-the-mainnet) <a href="#id-2-facilitating-l2-node-upgrades-in-sync-with-the-mainnet" id="id-2-facilitating-l2-node-upgrades-in-sync-with-the-mainnet"></a> This new native token makes it easier for Rollup nodes to synchronize with mainnet code upgrades. This consistency helps ensure the seamless collaboration of the entire Mantle Network across different levels and better support potential future EIPs. ### 3. Empowering MNT Token Further[​](https://docs-v2.mantle.xyz/devs/concepts/native#3-empowering-mnt-token-further) <a href="#id-3-empowering-mnt-token-further" id="id-3-empowering-mnt-token-further"></a> Mantle v2 Tectonic introduces support for [EIP-1559-type transactions](/network/more/glossary#eip-1559-transaction). This update allows the MNT token to serve as a `GasTipCap` token in such transactions, controlling transaction priority. This enhancement not only provides users with more flexibility, but also empowers MNT Token with additional utility and potential, further enhancing the Mantle ecosystem. ## Changes Post-New Solution[​](https://docs-v2.mantle.xyz/devs/concepts/native#changes-post-new-solution) <a href="#changes-post-new-solution" id="changes-post-new-solution"></a> ### Transition in Ledger Storage Method: From Contract Accounts to System Accounts[​](https://docs-v2.mantle.xyz/devs/concepts/native#transition-in-ledger-storage-method-from-contract-accounts-to-system-accounts) <a href="#transition-in-ledger-storage-method-from-contract-accounts-to-system-accounts" id="transition-in-ledger-storage-method-from-contract-accounts-to-system-accounts"></a> In Mantle v2 Tectonic, a significant change involves transitioning the storage method of the MNT ledger from contract accounts to system accounts. This shift from centralized storage (in a single contract account) to decentralized storage (balances correspond one-to-one with addresses, dispersed in address accounts) enhances system maintainability and aligns better with the decentralized design of the overall network. ### Achieving Identical Flow Paths for MNT and ETH[​](https://docs-v2.mantle.xyz/devs/concepts/native#achieving-identical-flow-paths-for-mnt-and-eth) <a href="#achieving-identical-flow-paths-for-mnt-and-eth" id="achieving-identical-flow-paths-for-mnt-and-eth"></a> With the modification of the native token, Mantle Network successfully achieves identical flow paths for MNT and ETH. This change elevates the position of MNT in Mantle Network, providing it with an equal and convenient standing in the system. Users can now enjoy a user experience similar to ETH without the need for MNT to adopt different flow paths, as is the case with ERC-20 assets. These changes not only positively impact the overall performance and user experience of the Mantle system, but also establish a solid foundation for future expansions and ecosystem development. # EIP-1559 Support [EIP-1559](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1559.md) is an upgrade proposal put forth by the Ethereum community, aiming to address network security issues by adjusting the structure of transaction fees. The core idea of this proposal is to burn transaction fees while providing miners (or proof-of-stake validators) with a more reliable permanent block reward, thus creating a more effective incentive mechanism. ## Analysis of Factors Affecting Fees[​](https://docs-v2.mantle.xyz/devs/concepts/tx-fee/eip-1559#analysis-of-factors-affecting-fees) <a href="#analysis-of-factors-affecting-fees" id="analysis-of-factors-affecting-fees"></a> In EIP-1559, the composition of transaction fees undergoes significant changes with the introduction of `BASEFEE` and `GasTipCap` (or `MaxPriorityFeePerGas`), along with the addition of `GasFeeCap` to ensure transaction security. The Ethereum protocol dynamically adjusts `BASEFEE` based on network congestion, resolving potential security risks associated with external price discovery in transaction packing by burning all `BASEFEE`. ## Why Was EIP-1559 Introduced[​](https://docs-v2.mantle.xyz/devs/concepts/tx-fee/eip-1559#why-was-eip-1559-introduced) <a href="#why-was-eip-1559-introduced" id="why-was-eip-1559-introduced"></a> The introduction of EIP-1559 aims to address the following issues: * **Inefficient price auctions**: The use of price auctions for different network congestion scenarios leads to inefficiency, and fee estimation is highly inaccurate. * **Inconsistent block utilization**: The native fee design results in inconsistent block utilization. EIP-1559 allows for the adjustment of block utilization, enabling a longer-term average block size limit. * **Enhancing network security**: Additional incentives (`GasTipCap`) help eliminate validators' dependence on block rewards, thereby strengthening network security. ## Application of EIP-1559 in Mantle v2[​](https://docs-v2.mantle.xyz/devs/concepts/tx-fee/eip-1559#application-of-eip-1559-in-mantle-v2-tectonic) <a href="#application-of-eip-1559-in-mantle-v2-tectonic" id="application-of-eip-1559-in-mantle-v2-tectonic"></a> In Mantle v2, we have made the following adjustments to `BASEFEE` and `GasTipCap`: * **`BASEFEE` Adjustment Mechanism**: * The `BASEFEE` for Mantle is a system parameter set through the [`SystemConfig`](/network/system-information/on-chain-system/contract-introduction#systemconfigproxy) contract on Ethereum L1 and synchronized to Mantle. You can check it [here](https://etherscan.io/address/0x427Ea0710FA5252057F0D88274f7aeb308386cAf#readProxyContract#F3) - currently, the Rollup BaseFee is fixed at 20,000,000 wei (0.02 gwei). * `BASEFEE` will no longer burn and will be collected in [BaseFeeVault](https://github.com/mantlenetworkio/mantle-v2/blob/develop/specs/predeploys.md#basefeevault) while supporting withdrawal to L1. * **`GasTipCap` Adjustment
프로젝트로 돌아가기