Skip to content

Commit

Permalink
fix large erigon fees pricing
Browse files Browse the repository at this point in the history
  • Loading branch information
incizzle committed Apr 22, 2024
1 parent e097efe commit 20a37e1
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions turbo/jsonrpc/eth_receipts.go
Original file line number Diff line number Diff line change
Expand Up @@ -808,7 +808,7 @@ func (api *APIImpl) GetERCBlockReceipts(ctx context.Context, to rpc.BlockNumber,
blocks := make([]map[string]interface{}, 0)
for ; start <= end; start++ {
var (
totalFees uint64
totalFees = big.NewInt(0)
)

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

// Gas Fee Calculation
txn := block.Transactions()[receipt.TransactionIndex]
effectiveGasPrice := uint64(0)
var effectiveGasPrice *big.Int
if !chainConfig.IsLondon(block.NumberU64()) {
effectiveGasPrice = txn.GetPrice().Uint64()
effectiveGasPrice = txn.GetPrice().ToBig()
} else {
baseFee, _ := uint256.FromBig(block.BaseFee())
gasPrice := new(big.Int).Add(block.BaseFee(), txn.GetEffectiveGasTip(baseFee).ToBig())
effectiveGasPrice = gasPrice.Uint64()
effectiveGasPrice = gasPrice
}
totalFees += effectiveGasPrice * receipt.GasUsed
fee := new(big.Int).Mul(effectiveGasPrice, new(big.Int).SetUint64(receipt.GasUsed))
totalFees = new(big.Int).Add(totalFees, fee)
}

if chainConfig.Bor != nil {
Expand All @@ -875,7 +876,7 @@ func (api *APIImpl) GetERCBlockReceipts(ctx context.Context, to rpc.BlockNumber,
"gasUsed": hexutil.Uint64(block.GasUsed()),
"miner": block.Coinbase(),
"issuance": issuance.Issuance,
"totalFees": hexutil.Uint64(totalFees),
"totalFees": hexutil.EncodeBig(totalFees),
"transactions": result,
})
}
Expand Down

0 comments on commit 20a37e1

Please sign in to comment.