internal/ethapi, graphql: correct comments about gas price logic (#27752)

This commit is contained in:
Christopher Harrison 2023-08-05 00:08:53 +01:00 committed by GitHub
parent 5c30541c2a
commit 60070fe5c6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View File

@ -277,7 +277,7 @@ func (t *Transaction) GasPrice(ctx context.Context) hexutil.Big {
case types.DynamicFeeTxType: case types.DynamicFeeTxType:
if block != nil { if block != nil {
if baseFee, _ := block.BaseFeePerGas(ctx); baseFee != nil { if baseFee, _ := block.BaseFeePerGas(ctx); baseFee != nil {
// price = min(tip, gasFeeCap - baseFee) + baseFee // price = min(gasTipCap + baseFee, gasFeeCap)
return (hexutil.Big)(*math.BigMin(new(big.Int).Add(tx.GasTipCap(), baseFee.ToInt()), tx.GasFeeCap())) return (hexutil.Big)(*math.BigMin(new(big.Int).Add(tx.GasTipCap(), baseFee.ToInt()), tx.GasFeeCap()))
} }
} }

View File

@ -1428,7 +1428,7 @@ func newRPCTransaction(tx *types.Transaction, blockHash common.Hash, blockNumber
result.GasTipCap = (*hexutil.Big)(tx.GasTipCap()) result.GasTipCap = (*hexutil.Big)(tx.GasTipCap())
// if the transaction has been mined, compute the effective gas price // if the transaction has been mined, compute the effective gas price
if baseFee != nil && blockHash != (common.Hash{}) { if baseFee != nil && blockHash != (common.Hash{}) {
// price = min(tip, gasFeeCap - baseFee) + baseFee // price = min(gasTipCap + baseFee, gasFeeCap)
price := math.BigMin(new(big.Int).Add(tx.GasTipCap(), baseFee), tx.GasFeeCap()) price := math.BigMin(new(big.Int).Add(tx.GasTipCap(), baseFee), tx.GasFeeCap())
result.GasPrice = (*hexutil.Big)(price) result.GasPrice = (*hexutil.Big)(price)
} else { } else {