Gas Price Oracle
This service is responsible for updating the
OVM_GasPriceOracle.solcontract, so the Sequencer can fetch the latest
gasPriceand update the L2 gas over time.
- 1.Make sure dependencies are installed - run
yarnin the base directory
The L2 gas fee is
gasFee = gasPrice * gasLimit
GAS PRICE The gas price is fixed and is equal to 1 GWei. Notably, the way fees are calculated on L2 differ from what you might be used to on L1, where the gas price can be adjusted e.g. to ensure faster mining. Since there is no mining on L2, the gas price is fixed.
GAS LIMIT On L2, we vary the gas limit to accommodate the ever-changing costs of running the L2. This can be confusing, since on L1, the gas limits are constants that depend only on the type of transaction - e.g. on L1, a standard ETH transfer requires a gas limit of 21,000 units of gas.
GAS LIMIT SETTINGS You could use the maximum gas limit. The estimated gas limit is based on
rollup_gasPrices, which is composed of
L2GasPricebased on the following expression:
estimatedGasLimit = L1SecurityFee / L2GasPrice + L2EstimatedExecutionGasLimit
L1SecurityFeechanges gradually to reflect our service cost, primarily, the cost of writing state roots into L1, and the significant cost of relaying messages from L1 to L2 (e.g. deposits) and back from L2 to L1 (e.g. exits). Unlike other L2's, we include the cost of relaying messages in our gas limits, so you do not have to pay two different fees or have to worry about relaying your messages.
The L1 security fee is for the cost of submitting the state roots and tx roots to L1. It's calculated via
L1BasePrice * scalar * (overhead + dataLength)
x%percentage of the average gas usage of the L1 txs that submitting the state and tx roots within last 1000 blocks. We adjust
xbased on our operation cost.