@@ -1545,11 +1545,15 @@ func WriteExecutionChartSeriesForDay(day int64) error {
1545
1545
totalTxSavings := decimal .NewFromInt (0 )
1546
1546
totalTxFees := decimal .NewFromInt (0 )
1547
1547
totalBurned := decimal .NewFromInt (0 )
1548
+ totalBurnedBlob := decimal .NewFromInt (0 )
1548
1549
totalGasUsed := decimal .NewFromInt (0 )
1550
+ totalBlobGasUsed := decimal .NewFromInt (0 )
1551
+ totalBlobCount := decimal .NewFromInt (0 )
1549
1552
1550
1553
legacyTxCount := int64 (0 )
1551
1554
accessListTxCount := int64 (0 )
1552
1555
eip1559TxCount := int64 (0 )
1556
+ blobTxCount := int64 (0 )
1553
1557
failedTxCount := int64 (0 )
1554
1558
successTxCount := int64 (0 )
1555
1559
@@ -1616,7 +1620,20 @@ func WriteExecutionChartSeriesForDay(day int64) error {
1616
1620
// totalMinerTips = totalMinerTips.Add(tipFee.Mul(gasUsed))
1617
1621
txFees = baseFee .Mul (gasUsed ).Add (tipFee .Mul (gasUsed ))
1618
1622
totalTxSavings = totalTxSavings .Add (maxFee .Mul (gasUsed ).Sub (baseFee .Mul (gasUsed ).Add (tipFee .Mul (gasUsed ))))
1619
- // TODO: Handle type 3?
1623
+
1624
+ case 3 :
1625
+ // priority fee is capped because the base fee is filled first
1626
+ tipFee = decimal .Min (prioFee , maxFee .Sub (baseFee ))
1627
+ blobTxCount += 1
1628
+ // totalMinerTips = totalMinerTips.Add(tipFee.Mul(gasUsed))
1629
+ txFees = baseFee .Mul (gasUsed ).Add (tipFee .Mul (gasUsed ))
1630
+ totalTxSavings = totalTxSavings .Add (maxFee .Mul (gasUsed ).Sub (baseFee .Mul (gasUsed ).Add (tipFee .Mul (gasUsed ))))
1631
+
1632
+ blobGasUsed := decimal .NewFromBigInt (new (big.Int ).SetUint64 (tx .BlobGasUsed ), 0 )
1633
+ totalBlobGasUsed = totalBlobGasUsed .Add (blobGasUsed )
1634
+ totalBurnedBlob = blobGasUsed .Mul (decimal .NewFromBigInt (new (big.Int ).SetBytes (tx .BlobGasPrice ), 0 ))
1635
+ totalBlobCount = totalBlobCount .Add (decimal .NewFromInt (int64 (len (tx .BlobVersionedHashes ))))
1636
+
1620
1637
default :
1621
1638
logger .Fatalf ("error unknown tx type %v hash: %x" , tx .Status , tx .Hash )
1622
1639
}
@@ -1633,7 +1650,7 @@ func WriteExecutionChartSeriesForDay(day int64) error {
1633
1650
logger .Fatalf ("error unknown status code %v hash: %x" , tx .Status , tx .Hash )
1634
1651
}
1635
1652
totalGasUsed = totalGasUsed .Add (gasUsed )
1636
- totalBurned = totalBurned .Add (baseFee .Mul (gasUsed ))
1653
+ totalBurned = totalBurned .Add (baseFee .Mul (gasUsed )). Add ( totalBurnedBlob )
1637
1654
if blk .Number < 12244000 {
1638
1655
totalTips = totalTips .Add (gasUsed .Mul (gasPrice ))
1639
1656
} else {
@@ -1657,22 +1674,35 @@ func WriteExecutionChartSeriesForDay(day int64) error {
1657
1674
logger .Infof ("consensus rewards: %v" , totalConsensusRewards )
1658
1675
1659
1676
logger .Infof ("Exporting BURNED_FEES %v" , totalBurned .String ())
1660
- _ , err = WriterDb . Exec ( "INSERT INTO chart_series (time, indicator, value) VALUES ($1, ' BURNED_FEES', $2) on conflict (time, indicator) do update set time = excluded.time, indicator = excluded.indicator, value = excluded.value" , dateTrunc , totalBurned .String ())
1677
+ err = SaveChartSeriesPoint ( dateTrunc , " BURNED_FEES" , totalBurned .String ())
1661
1678
if err != nil {
1662
1679
return fmt .Errorf ("error calculating BURNED_FEES chart_series: %w" , err )
1663
1680
}
1664
1681
1682
+ logger .Infof ("Exporting BURNED_BLOB_FEES %v" , totalBurnedBlob .String ())
1683
+ err = SaveChartSeriesPoint (dateTrunc , "BURNED_BLOB_FEES" , totalBurnedBlob .String ())
1684
+ if err != nil {
1685
+ return fmt .Errorf ("error calculating BURNED_BLOB_FEES chart_series: %w" , err )
1686
+ }
1687
+
1665
1688
logger .Infof ("Exporting NON_FAILED_TX_GAS_USAGE %v" , totalGasUsed .Sub (totalFailedGasUsed ).String ())
1666
1689
err = SaveChartSeriesPoint (dateTrunc , "NON_FAILED_TX_GAS_USAGE" , totalGasUsed .Sub (totalFailedGasUsed ).String ())
1667
1690
if err != nil {
1668
1691
return fmt .Errorf ("error calculating NON_FAILED_TX_GAS_USAGE chart_series: %w" , err )
1669
1692
}
1693
+
1670
1694
logger .Infof ("Exporting BLOCK_COUNT %v" , blockCount )
1671
1695
err = SaveChartSeriesPoint (dateTrunc , "BLOCK_COUNT" , blockCount )
1672
1696
if err != nil {
1673
1697
return fmt .Errorf ("error calculating BLOCK_COUNT chart_series: %w" , err )
1674
1698
}
1675
1699
1700
+ logger .Infof ("Exporting BLOB_COUNT %v" , blockCount )
1701
+ err = SaveChartSeriesPoint (dateTrunc , "BLOB_COUNT" , totalBlobCount )
1702
+ if err != nil {
1703
+ return fmt .Errorf ("error calculating BLOB_COUNT chart_series: %w" , err )
1704
+ }
1705
+
1676
1706
// convert microseconds to seconds
1677
1707
logger .Infof ("Exporting BLOCK_TIME_AVG %v" , avgBlockTime .Div (decimal .NewFromInt (1e6 )).Abs ().String ())
1678
1708
err = SaveChartSeriesPoint (dateTrunc , "BLOCK_TIME_AVG" , avgBlockTime .Div (decimal .NewFromInt (1e6 )).String ())
@@ -1697,7 +1727,7 @@ func WriteExecutionChartSeriesForDay(day int64) error {
1697
1727
1698
1728
if totalGasPrice .GreaterThan (decimal .NewFromInt (0 )) && decimal .NewFromInt (legacyTxCount ).Add (decimal .NewFromInt (accessListTxCount )).GreaterThan (decimal .NewFromInt (0 )) {
1699
1729
logger .Infof ("Exporting AVG_GASPRICE" )
1700
- _ , err = WriterDb . Exec ( "INSERT INTO chart_series (time, indicator, value) VALUES($1, ' AVG_GASPRICE', $2) on conflict (time, indicator) do update set time = excluded.time, indicator = excluded.indicator, value = excluded.value" , dateTrunc , totalGasPrice .Div ((decimal .NewFromInt (legacyTxCount ).Add (decimal .NewFromInt (accessListTxCount )))).String ())
1730
+ err = SaveChartSeriesPoint ( dateTrunc , " AVG_GASPRICE" , totalGasPrice .Div ((decimal .NewFromInt (legacyTxCount ).Add (decimal .NewFromInt (accessListTxCount )))).String ())
1701
1731
if err != nil {
1702
1732
return fmt .Errorf ("error calculating AVG_GASPRICE chart_series err: %w" , err )
1703
1733
}
@@ -1717,6 +1747,12 @@ func WriteExecutionChartSeriesForDay(day int64) error {
1717
1747
return fmt .Errorf ("error calculating TOTAL_GASUSED chart_series: %w" , err )
1718
1748
}
1719
1749
1750
+ logger .Infof ("Exporting TOTAL_BLOB_GASUSED %v" , totalBlobGasUsed .String ())
1751
+ err = SaveChartSeriesPoint (dateTrunc , "TOTAL_BLOB_GASUSED" , totalBlobGasUsed .String ())
1752
+ if err != nil {
1753
+ return fmt .Errorf ("error calculating TOTAL_BLOB_GASUSED chart_series: %w" , err )
1754
+ }
1755
+
1720
1756
if blockCount > 0 {
1721
1757
logger .Infof ("Exporting AVG_GASLIMIT %v" , totalGasLimit .Div (decimal .NewFromInt (blockCount )))
1722
1758
err = SaveChartSeriesPoint (dateTrunc , "AVG_GASLIMIT" , totalGasLimit .Div (decimal .NewFromInt (blockCount )))
0 commit comments