core/types: add EffectiveGasPrice in Receipt (#26713)
This change adds a struct field EffectiveGasPrice in types.Receipt. The field is present in RPC responses, but not in the Go struct, and thus can't easily be accessed via ethclient. Co-authored-by: PulsarAI <dev@pulsar-systems.fi>
This commit is contained in:
+4
-11
@@ -1621,6 +1621,7 @@ func (s *TransactionAPI) GetTransactionReceipt(ctx context.Context, hash common.
|
||||
// as per specification.
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
receipts, err := s.b.GetReceipts(ctx, blockHash)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -1648,18 +1649,9 @@ func (s *TransactionAPI) GetTransactionReceipt(ctx context.Context, hash common.
|
||||
"logs": receipt.Logs,
|
||||
"logsBloom": receipt.Bloom,
|
||||
"type": hexutil.Uint(tx.Type()),
|
||||
"effectiveGasPrice": (*hexutil.Big)(receipt.EffectiveGasPrice),
|
||||
}
|
||||
// Assign the effective gas price paid
|
||||
if !s.b.ChainConfig().IsLondon(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)
|
||||
@@ -1669,6 +1661,7 @@ func (s *TransactionAPI) GetTransactionReceipt(ctx context.Context, hash common.
|
||||
if receipt.Logs == nil {
|
||||
fields["logs"] = []*types.Log{}
|
||||
}
|
||||
|
||||
// If the ContractAddress is 20 0x0 bytes, assume it is not a contract creation
|
||||
if receipt.ContractAddress != (common.Address{}) {
|
||||
fields["contractAddress"] = receipt.ContractAddress
|
||||
|
||||
Reference in New Issue
Block a user