Skip to content

Commit

Permalink
rpc: return effective gas price from receipt
Browse files Browse the repository at this point in the history
This will give us the correct result for fee currency txs. The old
approach was necessary when the code was written because receipts did
not contain the effective gas price back then.
This change could be upstreamed, if it works as expected.
  • Loading branch information
karlb committed Jan 16, 2024
1 parent eedca96 commit 6fd6cec
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions internal/ethapi/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -1648,9 +1648,8 @@ func newRPCTransaction(tx *types.Transaction, blockHash common.Hash, blockNumber
result.GasFeeCap = (*hexutil.Big)(tx.GasFeeCap())
result.GasTipCap = (*hexutil.Big)(tx.GasTipCap())
// if the transaction has been mined, compute the effective gas price
if baseFee != nil && blockHash != (common.Hash{}) {
// price = min(gasTipCap + baseFee, gasFeeCap)
result.GasPrice = (*hexutil.Big)(effectiveGasPrice(tx, baseFee))
if receipt != nil {
result.GasPrice = (*hexutil.Big)(receipt.EffectiveGasPrice)
} else {
result.GasPrice = (*hexutil.Big)(tx.GasFeeCap())
}
Expand Down

0 comments on commit 6fd6cec

Please sign in to comment.