Skip to content

Commit 20a37e1

Browse files
committed
fix large erigon fees pricing
1 parent e097efe commit 20a37e1

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

turbo/jsonrpc/eth_receipts.go

+7-6
Original file line numberDiff line numberDiff line change
@@ -808,7 +808,7 @@ func (api *APIImpl) GetERCBlockReceipts(ctx context.Context, to rpc.BlockNumber,
808808
blocks := make([]map[string]interface{}, 0)
809809
for ; start <= end; start++ {
810810
var (
811-
totalFees uint64
811+
totalFees = big.NewInt(0)
812812
)
813813

814814
blockNum, hash, _, err := rpchelper.GetBlockNumber(rpc.BlockNumberOrHashWithNumber(rpc.BlockNumber(start)), tx, api.filters)
@@ -842,15 +842,16 @@ func (api *APIImpl) GetERCBlockReceipts(ctx context.Context, to rpc.BlockNumber,
842842

843843
// Gas Fee Calculation
844844
txn := block.Transactions()[receipt.TransactionIndex]
845-
effectiveGasPrice := uint64(0)
845+
var effectiveGasPrice *big.Int
846846
if !chainConfig.IsLondon(block.NumberU64()) {
847-
effectiveGasPrice = txn.GetPrice().Uint64()
847+
effectiveGasPrice = txn.GetPrice().ToBig()
848848
} else {
849849
baseFee, _ := uint256.FromBig(block.BaseFee())
850850
gasPrice := new(big.Int).Add(block.BaseFee(), txn.GetEffectiveGasTip(baseFee).ToBig())
851-
effectiveGasPrice = gasPrice.Uint64()
851+
effectiveGasPrice = gasPrice
852852
}
853-
totalFees += effectiveGasPrice * receipt.GasUsed
853+
fee := new(big.Int).Mul(effectiveGasPrice, new(big.Int).SetUint64(receipt.GasUsed))
854+
totalFees = new(big.Int).Add(totalFees, fee)
854855
}
855856

856857
if chainConfig.Bor != nil {
@@ -875,7 +876,7 @@ func (api *APIImpl) GetERCBlockReceipts(ctx context.Context, to rpc.BlockNumber,
875876
"gasUsed": hexutil.Uint64(block.GasUsed()),
876877
"miner": block.Coinbase(),
877878
"issuance": issuance.Issuance,
878-
"totalFees": hexutil.Uint64(totalFees),
879+
"totalFees": hexutil.EncodeBig(totalFees),
879880
"transactions": result,
880881
})
881882
}

0 commit comments

Comments
 (0)