mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-22 19:50:36 +00:00
RPC: eip1559 in getTxByHash (#2436)
This commit is contained in:
parent
a36a613e61
commit
d58752f67d
@ -393,7 +393,6 @@ func testGetBlockBodies(t *testing.T, protocol uint) {
|
||||
}
|
||||
|
||||
// Tests that the transaction receipts can be retrieved based on hashes.
|
||||
func TestGetBlockReceipts64(t *testing.T) { testGetBlockReceipts(t, 64) }
|
||||
func TestGetBlockReceipts65(t *testing.T) { testGetBlockReceipts(t, 65) }
|
||||
func TestGetBlockReceipts66(t *testing.T) { testGetBlockReceipts(t, 66) }
|
||||
|
||||
@ -464,8 +463,8 @@ func testGetBlockReceipts(t *testing.T, protocol uint) {
|
||||
|
||||
m.StreamWg.Wait()
|
||||
|
||||
// Send the hash request and verify the response
|
||||
m.ReceiveWg.Add(1)
|
||||
// Send the hash request and verify the response
|
||||
for _, err = range m.Send(&sentry.InboundMessage{Id: eth.ToProto[eth.ETH66][eth.GetReceiptsMsg], Data: b, PeerId: m.PeerId}) {
|
||||
require.NoError(t, err)
|
||||
}
|
||||
|
@ -889,7 +889,7 @@ type RPCTransaction struct {
|
||||
|
||||
// newRPCTransaction returns a transaction that will serialize to the RPC
|
||||
// representation, with the given location metadata set (if available).
|
||||
func newRPCTransaction(tx types.Transaction, blockHash common.Hash, blockNumber uint64, index uint64) *RPCTransaction {
|
||||
func newRPCTransaction(tx types.Transaction, blockHash common.Hash, blockNumber uint64, index uint64, baseFee *big.Int) *RPCTransaction {
|
||||
// Determine the signer. For replay-protected transactions, use the most permissive
|
||||
// signer, because we assume that signers are backwards-compatible with old
|
||||
// transactions. For non-protected transactions, the homestead signer signer is used
|
||||
@ -933,6 +933,14 @@ func newRPCTransaction(tx types.Transaction, blockHash common.Hash, blockNumber
|
||||
if len(t.AccessList) > 0 {
|
||||
result.Accesses = &t.AccessList
|
||||
}
|
||||
// if the transaction has been mined, compute the effective gas price
|
||||
if baseFee != nil && blockHash != (common.Hash{}) {
|
||||
// price = min(tip, gasFeeCap - baseFee) + baseFee
|
||||
price := math.BigMin(new(big.Int).Add(t.Tip.ToBig(), baseFee), t.FeeCap.ToBig())
|
||||
result.GasPrice = (*hexutil.Big)(price)
|
||||
} else {
|
||||
result.GasPrice = nil
|
||||
}
|
||||
}
|
||||
signer := types.LatestSignerForChainID(chainId.ToBig())
|
||||
result.From, _ = tx.Sender(*signer)
|
||||
@ -957,7 +965,7 @@ func newRPCTransactionFromBlockIndex(b *types.Block, index uint64) *RPCTransacti
|
||||
if index >= uint64(len(txs)) {
|
||||
return nil
|
||||
}
|
||||
return newRPCTransaction(txs[index], b.Hash(), b.NumberU64(), index)
|
||||
return newRPCTransaction(txs[index], b.Hash(), b.NumberU64(), index, b.BaseFee())
|
||||
}
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user