core, internal: expose effectiveGasPrice in receipts (#23050)

This commit is contained in:
Daniel Liu 2024-05-28 10:32:18 +08:00
parent dbdca11501
commit b02922fc53
5 changed files with 18 additions and 6 deletions

View file

@ -553,7 +553,7 @@ func (pool *TxPool) Pending(enforceTips bool) (map[common.Address]types.Transact
// If the miner requests tip enforcement, cap the lists now
if enforceTips && !pool.locals.contains(addr) {
for i, tx := range txs {
if tx.EffectiveTipIntCmp(pool.gasPrice, pool.priced.urgent.baseFee) < 0 {
if tx.EffectiveGasTipIntCmp(pool.gasPrice, pool.priced.urgent.baseFee) < 0 {
txs = txs[:i]
break
}

View file

@ -385,8 +385,8 @@ func (tx *Transaction) EffectiveGasTipCmp(other *Transaction, baseFee *big.Int)
return tx.EffectiveGasTipValue(baseFee).Cmp(other.EffectiveGasTipValue(baseFee))
}
// EffectiveTipIntCmp compares the effective gasTipCap of a transaction to the given gasTipCap.
func (tx *Transaction) EffectiveTipIntCmp(other *big.Int, baseFee *big.Int) int {
// EffectiveGasTipIntCmp compares the effective gasTipCap of a transaction to the given gasTipCap.
func (tx *Transaction) EffectiveGasTipIntCmp(other *big.Int, baseFee *big.Int) int {
if baseFee == nil {
return tx.GasTipCapIntCmp(other)
}

View file

@ -2194,7 +2194,17 @@ func (s *PublicTransactionPoolAPI) GetTransactionReceipt(ctx context.Context, ha
"logsBloom": receipt.Bloom,
"type": hexutil.Uint(tx.Type()),
}
// Assign the effective gas price paid
if !s.b.ChainConfig().IsEIP1559(bigblock) {
fields["effectiveGasPrice"] = hexutil.Uint64(tx.GasPrice().Uint64())
} else {
header, err := s.b.HeaderByHash(ctx, blockHash)
if err != nil {
return nil, err
}
gasPrice := new(big.Int).Add(header.BaseFee, tx.EffectiveGasTipValue(header.BaseFee))
fields["effectiveGasPrice"] = hexutil.Uint64(gasPrice.Uint64())
}
// Assign receipt status or post state.
if len(receipt.PostState) > 0 {
fields["root"] = hexutil.Bytes(receipt.PostState)

File diff suppressed because one or more lines are too long

View file

@ -3814,7 +3814,9 @@ var outputTransactionReceiptFormatter = function (receipt){
receipt.transactionIndex = utils.toDecimal(receipt.transactionIndex);
receipt.cumulativeGasUsed = utils.toDecimal(receipt.cumulativeGasUsed);
receipt.gasUsed = utils.toDecimal(receipt.gasUsed);
if(receipt.effectiveGasPrice !== undefined) {
receipt.effectiveGasPrice = utils.toBigNumber(receipt.effectiveGasPrice);
}
if(utils.isArray(receipt.logs)) {
receipt.logs = receipt.logs.map(function(log){
return outputLogFormatter(log);