We ensure the security of our L2 network by committing data to the L1, thus inheriting some of its underlying security properties. All data needed for syncing a Scroll node and verifying proofs are publicly available on Ethereum. Every transaction's data is committed to Ethereum, which incurs an additional transaction fee, referred to as the "L1 Fee".
For every transaction processed on Scroll, its transaction payload is committed to Ethereum L1. This is done to enable the reconstruction of the Scroll chain from L1 data.
Blocks of transaction data are grouped, and commitments are posted at the chunk level (eventually at the batch level). Note that a "chunk" is a collection of blocks that fits into a single zkEVM circuit for proof generation. However, the cost that an individual transaction contributes to the total cost can be easily computed based on the number of zero and non-zero bytes in its payload.
The data fee is based on multiple factors:
l1GasPrice- Current base fee on the L1
additionalTransactionBytes- Additional bytes on top of RLP Encoded unsigned transaction, constant of 16 * 74 bytes
l1CallDataGasSize- Gas size of the calldata to be committed as part of a transaction, 4 * zeroBytes(tx) + 16 * nonZeroBytes(tx) + additionalTransactionBytes
gasOverhead- Additional gas overhead of a data commitment transaction
scalingFactor- Difference used for accounting price spikes
Then, the final formula would be
l1Fee = (l1GasPrice * (l1CallDataGasSize + gasOverhead)) * scalingFactor
If a gas spike happens on the L1 after the transaction has been processed by the sequencer, it doesn’t affect what the user pays.
The transaction execution happens in a few steps:
- 1.Creation of transaction (Client side)
- 2.Emitting of the transaction (Client side)
- 3.Processing of the transaction (Sequencer)
- 4.Committing of the transaction (Sequencer)
Everything after the second step is the responsibility of the sequencer. Should the L1 gas cost increase (or decrease) between the processing and actual committing of a transaction, the user shouldn't be affected, and the sequencer will pay for all cost fluctuations.