celo-org / op-geth

GNU Lesser General Public License v3.0
0 stars 0 forks source link

L1 data fee and fee currencies #72

Closed palango closed 2 months ago

palango commented 1 year ago

Part of celo-org/optimism#6

Optimism has the concept of the l1 data fee. This part of the transaction fee pays for the fees related to L1 submission of L2 transactions, i.e. L1 data available. It is calculated as follows, wherel1_gas_price is an external input which needs to be made available.

l1_data_fee = l1_gas_price * (tx_data_gas + fixed_overhead) * dynamic_overhead

The total transaction fee can be calculated by adding the l1 data fee to the l2 execution fee.

Fee currencies

As the l1 data fee is denominated in ETH, there needs to be a way to convert it into the fee currency. If the fee currency is:

karlb commented 12 months ago

Since we know neither the eventual DA fee amount nor currency, we should consider postponing the full implementation of this and just assume an exchange rate of one (or a similar dummy value) for now.

palango commented 11 months ago

The L1 data fee is calculated here: https://github.com/celo-org/op-geth/blob/951ff889f567412ae1e88b6e26e56523511327d3/core/types/rollup_l1_cost.go#L77-L83

The formula includes a generic scalar factor, which can be set when the information about the latest known L1 block is updated. That should be enough for our purpose for now.

The data is stored in the L1Block contract on the L2: https://github.com/celo-org/optimism/blob/7d2655a60c27be3f1f4bfaead688e9d21c528d37/packages/contracts-bedrock/src/L2/L1Block.sol#L38-L39

karlb commented 2 months ago

Thanks to EigenDA our DA costs will be minuscule and we can work with L1cost of zero, so I think we can close this issue.

See also https://github.com/celo-org/celo-blockchain-planning/issues/513