diff --git a/db/bigtable_eth1.go b/db/bigtable_eth1.go index 82de36981b..790110c276 100644 --- a/db/bigtable_eth1.go +++ b/db/bigtable_eth1.go @@ -914,15 +914,18 @@ func CalculateTxFeesFromBlock(block *types.Eth1Block) *big.Int { func CalculateTxFeeFromTransaction(tx *types.Eth1Transaction, blockBaseFee *big.Int) *big.Int { // calculate tx fee depending on tx type txFee := new(big.Int).SetUint64(tx.GasUsed) - if tx.Type == uint32(2) { + switch tx.Type { + case 0, 1: + txFee.Mul(txFee, new(big.Int).SetBytes(tx.GasPrice)) + case 2, 3: // multiply gasused with min(baseFee + maxpriorityfee, maxfee) if normalGasPrice, maxGasPrice := new(big.Int).Add(blockBaseFee, new(big.Int).SetBytes(tx.MaxPriorityFeePerGas)), new(big.Int).SetBytes(tx.MaxFeePerGas); normalGasPrice.Cmp(maxGasPrice) <= 0 { txFee.Mul(txFee, normalGasPrice) } else { txFee.Mul(txFee, maxGasPrice) } - } else { - txFee.Mul(txFee, new(big.Int).SetBytes(tx.GasPrice)) + default: + logger.Errorf("unknown tx type %v", tx.Type) } return txFee } diff --git a/db/statistics.go b/db/statistics.go index c2310d0eac..c19ea5d6e1 100644 --- a/db/statistics.go +++ b/db/statistics.go @@ -1616,7 +1616,7 @@ func WriteExecutionChartSeriesForDay(day int64) error { // totalMinerTips = totalMinerTips.Add(tipFee.Mul(gasUsed)) txFees = baseFee.Mul(gasUsed).Add(tipFee.Mul(gasUsed)) totalTxSavings = totalTxSavings.Add(maxFee.Mul(gasUsed).Sub(baseFee.Mul(gasUsed).Add(tipFee.Mul(gasUsed)))) - + // TODO: Handle type 3? default: logger.Fatalf("error unknown tx type %v hash: %x", tx.Status, tx.Hash) }