Gas and fees
Arbitrum uses gas to track the execution cost on an Arbitrum Nitro chain. It works the same as Ethereum gas, in the sense that every EVM instruction costs the same amount of gas as it would on Ethereum.
There are two parties a user pays when submitting a transaction:
- Poster: If reimbursable, covers the parent chain resources such as the parent chain calldata needed to post the transaction.
- Network fee account: Covers the child chain's resources, including computation, storage, and other burdens that child chain nodes must bear to service transactions.
The parent chain component is the product of the transaction's estimated contribution to its batch's size—computed using Brotli on the transaction alone—and the child chain's view of the parent chain data price. This value dynamically adjusts over time to ensure the batch poster is ultimately fairly compensated.
The child chain component consists of the traditional fees Geth would pay to bonders in a vanilla parent chain, such as the computation and storage charges that apply to the State Transition Function (STF). ArbOS charges additional fees for executing its child-chain-specific precompiles, whose fees are dynamically priced based on the resources used during execution.
The following sections detail how parent and child chain fees are calculated. For a practical guide on estimating gas for your transactions, see How to estimate gas in Arbitrum.
Parent chain gas pricing
ArbOS dynamically prices the parent chain gas, with the price adjusting to ensure that the amount collected in the parent chain gas fees is as close as possible to the costs that must be covered, over time.
Challenges in pricing parent chain resources
There are two main challenges in accurately pricing parent chain resources:
1. Apportioning batch costs among transactions
- Compression complexity: The data posted to the parent chain is compressed using a general-purpose compression algorithm (Brotli). The effectiveness of compression depends on shared patterns among transactions in a batch.
- Contribution estimation: It's difficult to determine how much a specific transaction contributes to the batch's overall compressibility.
- Ideal vs. practical: Ideally, transactions that enhance compressibility would get charged less, but there's no efficient way to calculate this precisely within the constraints of the STF.
2. Assessing parent chain fees at sequencing time
- Determinism requirement: The parent chain fee for a transaction must be known when the transaction is sequenced to maintain the STF's determinism.
- Future uncertainty: At sequencing time, the actual cost of the batch is unknown because it depends on the parent chain base fee at the future time of batch posting and the remaining contents of the batch (which affect its size and compressibility).
- Impossibility of exact charges: Charging based on future information is not feasible, so the system must rely on estimations.
Nitro's approach
To overcome these challenges, Arbitrum Nitro implements a two-fold strategy:
- Estimated relative footprint: An estimated size is calculated for each transaction, measured in data units, to approximate its impact on batch size.
- Adaptive fee per data unit: A dynamic fee per data unit adjusts over time to align collected fees with actual costs.
Parent chain costs
There are two types of parent chain costs: batch posting costs and rewards.
Batch posting costs reflect the actual cost a batch poster pays to post batch data on the parent chain. Whenever a batch is posted, the parent chain contract that records it will send a special "batch posting report" message to the child chain ArbOS, reporting who paid for the batch and the parent chain basefee at the time. This message is placed in the chain's delayed inbox so that it will be delivered to the child chain ArbOS after some delay.
When a batch posting report message arrives at the child chain, ArbOS computes the cost of the referenced batch by multiplying the reported basefee by the batch's data cost. (ArbOS retrieves the batch's data from its inbox state and computes the parent chain gas the batch would have used by counting the number of zero bytes and non-zero bytes in the batch.) The pricer records the resulting cost as funds due to the party who is reported to have submitted the batch.
The second type of parent chain cost is an optional (per chain) per-unit reward for handling transaction calldata. In general, the reward might be paid to the Sequencer, or to members of the Data Availability Committee in an AnyTrust chain, or to anyone else who incurs per-calldata-byte costs on behalf of the chain. The reward is a fixed number of wei per data unit, and is paid to a single address.
The parent chain pricer keeps track of funds due to the reward address based on the number of data units processed so far. This amount is updated whenever a batch posting report arrives at the child chain.
Apportioning costs among transactions
To approximate each transaction's contribution to parent chain costs:
- Each transaction is individually compressed using the Brotli compressor at its lowest compression level (fastest setting). This reduces computational overhead within the STF.
- The size of the compressed transaction is multiplied by 16 (since Ethereum charges 16 gas per non-zero byte). This product represents the transaction's estimated footprint in data units.
- While not exact, this method approximates the transaction's size after full batch compression and is computationally efficient for real-time processing.
Parent chain calldata fees
The parent chain calldata fees exist because the Sequencer, or the batch poster that posts the Sequencer's transaction batches on Ethereum, incurs parent chain gas costs to post transactions on Ethereum as calldata. Funds collected in the parent chain calldata fees are credited to the batch poster to cover its costs.
Every transaction that comes in through the Sequencer will pay a parent chain calldata fee. Transactions that come in through the delayed inbox do not pay this fee because they don't add to batch posting costs—but these transactions pay gas fees to Ethereum when they are put into the delayed inbox.
The parent chain pricing algorithm assigns a parent chain calldata fee to each Sequencer transaction. First, it computes the transaction's size, an estimate of how many bytes the transaction will add to the compressed batch it is in; the formula includes an estimate of the transaction's compressibility.
Second, it multiplies the computed size estimate by the current price per estimated byte to determine the transaction's parent chain calldata cost in wei. Finally, it divides this cost by the current child chain basefee to convert the fee into child chain gas units. The result is reported as the "poster fee" for the transaction.
The price per estimated byte is set by a dynamic algorithm that compares the total parent-chain calldata fees collected to the total fees actually paid by batch posters and tries to bring the two as close to equality as possible. If batch poster costs are less than fee receipts, the price will increase; if they exceed fee receipts, the price will decrease.
Adaptive pricing algorithm
To align collected fees with actual costs, Arbitrum uses an adaptive algorithm with two primary goals:
- Cost alignment: Minimize the long-term difference between collected fees and the Sequencer's parent chain costs.
- Stability: Avoid sudden fluctuations in the data price, ensuring a stable fee environment.
Pricer components
The pricer module within ArbOS tracks:
- Amount owed to the Sequencer: The cumulative parent chain costs incurred by the Sequencer for batch posting.
- Reimbursement fund: Collects all funds charged to transactions for parent chain fees. Acts as a pool to reimburse the Sequencer.
- Data unit count: The total number of recent data units processed, which increases with each transaction's estimated data units.
- Current parent chain data unit price: The adaptive fee per data unit expressed in
wei.
Algorithm for price adjustment
When the Sequencer posts a batch to the parent chain inbox:
-
Batch posting report generation: The parent chain inbox inserts a "batch posting report" transaction into the chain's Delayed Inbox. After a delay, this report is processed by ArbOS's pricer module.
-
Processing the batch posting report:
-
Compute batch cost: ArbOS calculates the actual cost of posting the batch by retrieving the batch data from the inbox state and counting zero and non-zero bytes to determine parent chain gas usage. The cost is added to the amount owed to the Sequencer.
-
Update data units: Calculate the data units assigned to this update :
Where is total recent data units, is the current time, is the time when the update occurred, and is the time of the previous update. Subtract from the total .
-
Reimburse the Sequencer: Pay the Sequencer from the reimbursement fund. The amount paid is the lesser of the amount owed or the fund balance. Deduct the paid amount from both the reimbursement fund and the amount owed.
-
Compute surplus and derivative:
Surplus ():
Derivative of surplus ():
where is the surplus at the previous update.
-
Compute derivative goal (): Establish a target derivative to eliminate surplus over time:
-