Skip to content

Commit eeaac15

Browse files
committed
report: use effectiveGasPrice from receipt for EIP-1559 compatibility
1 parent de06605 commit eeaac15

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

cmd/report/report.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -529,11 +529,14 @@ func fetchBlockInfo(ctx context.Context, ec *ethrpc.Client, blockNum uint64, rat
529529
txHash, _ := txMap["hash"].(string)
530530
from, _ := txMap["from"].(string)
531531
to, _ := txMap["to"].(string)
532-
gasPrice := hexToUint64(txMap["gasPrice"])
533532
gasLimit := hexToUint64(txMap["gas"])
534533

535534
receipt := receipts[i]
536535
gasUsed := hexToUint64(receipt["gasUsed"])
536+
// Use effectiveGasPrice from receipt which works for both legacy and EIP-1559 transactions
537+
// For legacy txs: effectiveGasPrice = gasPrice
538+
// For EIP-1559 txs: effectiveGasPrice = baseFee + min(maxPriorityFeePerGas, maxFeePerGas - baseFee)
539+
gasPrice := hexToUint64(receipt["effectiveGasPrice"])
537540
gasUsedPercent := 0.0
538541
if blockInfo.GasLimit > 0 {
539542
gasUsedPercent = (float64(gasUsed) / float64(blockInfo.GasLimit)) * 100

0 commit comments

Comments
 (0)