-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Account for zero vs non-zero calldata bytes for L2 gas estimation #515
Copy link
Copy link
Closed
Labels
C-bugCategory: bugsCategory: bugs
Description
Describe the bug
Current Fee estimation logic:
optimism/l2geth/core/rollup_fee.go
Lines 16 to 19 in 41cfbd1
| dataLen := int64(ROLLUP_BASE_TX_SIZE + len(data)) | |
| // get the data fee | |
| dataFee := new(big.Int).Mul(dataPrice, big.NewInt(dataLen)) | |
| executionFee := new(big.Int).Mul(executionPrice, new(big.Int).SetUint64(gasUsed)) |
Rather than logic being gasPrice * dataLen + executionPrice * gasUsed, logic should be:
gasPrice * (4*zeroDataBytes + 16*nonZeroDataBytes + nonCallDataL1GasOverhead) + executionPrice * gasUsed
- dataPrice is currently the L1 gas price, not the price per byte of data. Non-zero data bytes cost 16 gas and zero data bytes cost 4 gas. We must iterate through the data, count # of zero, non-zero bytes, then calculate the cost.
- There is currently a non-calldata per tx overhead for batch submission. The naive solution is to have this parameterizable in the config. Ideally we can query the L1 CTC to find a running average of the tx batch size and use that to parameterize this added cost.
Non calldata cost per tx (Assuming each tx has its own batch context):
Batches of 10 txs:
9145 gas per tx
Batches of 50 txs:
5253 gas per tx
Batches of 200 txs:
2661 gas per tx
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
C-bugCategory: bugsCategory: bugs