mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-17 18:30:45 +00:00
core, internal: expose effectiveGasPrice in receipts (#23050)
This commit is contained in:
parent
dbdca11501
commit
b02922fc53
5 changed files with 18 additions and 6 deletions
|
|
@ -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 the miner requests tip enforcement, cap the lists now
|
||||||
if enforceTips && !pool.locals.contains(addr) {
|
if enforceTips && !pool.locals.contains(addr) {
|
||||||
for i, tx := range txs {
|
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]
|
txs = txs[:i]
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -385,8 +385,8 @@ func (tx *Transaction) EffectiveGasTipCmp(other *Transaction, baseFee *big.Int)
|
||||||
return tx.EffectiveGasTipValue(baseFee).Cmp(other.EffectiveGasTipValue(baseFee))
|
return tx.EffectiveGasTipValue(baseFee).Cmp(other.EffectiveGasTipValue(baseFee))
|
||||||
}
|
}
|
||||||
|
|
||||||
// EffectiveTipIntCmp compares the effective gasTipCap of a transaction to the given gasTipCap.
|
// EffectiveGasTipIntCmp compares the effective gasTipCap of a transaction to the given gasTipCap.
|
||||||
func (tx *Transaction) EffectiveTipIntCmp(other *big.Int, baseFee *big.Int) int {
|
func (tx *Transaction) EffectiveGasTipIntCmp(other *big.Int, baseFee *big.Int) int {
|
||||||
if baseFee == nil {
|
if baseFee == nil {
|
||||||
return tx.GasTipCapIntCmp(other)
|
return tx.GasTipCapIntCmp(other)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2194,7 +2194,17 @@ func (s *PublicTransactionPoolAPI) GetTransactionReceipt(ctx context.Context, ha
|
||||||
"logsBloom": receipt.Bloom,
|
"logsBloom": receipt.Bloom,
|
||||||
"type": hexutil.Uint(tx.Type()),
|
"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.
|
// Assign receipt status or post state.
|
||||||
if len(receipt.PostState) > 0 {
|
if len(receipt.PostState) > 0 {
|
||||||
fields["root"] = hexutil.Bytes(receipt.PostState)
|
fields["root"] = hexutil.Bytes(receipt.PostState)
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -3814,7 +3814,9 @@ var outputTransactionReceiptFormatter = function (receipt){
|
||||||
receipt.transactionIndex = utils.toDecimal(receipt.transactionIndex);
|
receipt.transactionIndex = utils.toDecimal(receipt.transactionIndex);
|
||||||
receipt.cumulativeGasUsed = utils.toDecimal(receipt.cumulativeGasUsed);
|
receipt.cumulativeGasUsed = utils.toDecimal(receipt.cumulativeGasUsed);
|
||||||
receipt.gasUsed = utils.toDecimal(receipt.gasUsed);
|
receipt.gasUsed = utils.toDecimal(receipt.gasUsed);
|
||||||
|
if(receipt.effectiveGasPrice !== undefined) {
|
||||||
|
receipt.effectiveGasPrice = utils.toBigNumber(receipt.effectiveGasPrice);
|
||||||
|
}
|
||||||
if(utils.isArray(receipt.logs)) {
|
if(utils.isArray(receipt.logs)) {
|
||||||
receipt.logs = receipt.logs.map(function(log){
|
receipt.logs = receipt.logs.map(function(log){
|
||||||
return outputLogFormatter(log);
|
return outputLogFormatter(log);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue