From ae0c09d2c3b8e2761a2e8afcc7e55e63f9bc6125 Mon Sep 17 00:00:00 2001 From: Austin Roberts Date: Mon, 5 Jul 2021 10:43:01 -0500 Subject: [PATCH] Make sure EIP-1559 transactions have the right fields --- eth/filters/dropped_tx_subscription.go | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/eth/filters/dropped_tx_subscription.go b/eth/filters/dropped_tx_subscription.go index afa5bece028c..00494e4ec006 100644 --- a/eth/filters/dropped_tx_subscription.go +++ b/eth/filters/dropped_tx_subscription.go @@ -32,17 +32,16 @@ type rejectNotification struct { // newRPCTransaction returns a transaction that will serialize to the RPC // representation, with the given location metadata set (if available). func newRPCPendingTransaction(tx *types.Transaction) *ethapi.RPCTransaction { - if tx == nil { - return nil - } - var signer types.Signer = types.FrontierSigner{} + var signer types.Signer if tx.Protected() { - signer = types.NewEIP155Signer(tx.ChainId()) + signer = types.LatestSignerForChainID(tx.ChainId()) + } else { + signer = types.HomesteadSigner{} } from, _ := types.Sender(signer, tx) v, r, s := tx.RawSignatureValues() - result := ðapi.RPCTransaction{ + Type: hexutil.Uint64(tx.Type()), From: from, Gas: hexutil.Uint64(tx.Gas()), GasPrice: (*hexutil.Big)(tx.GasPrice()), @@ -55,6 +54,20 @@ func newRPCPendingTransaction(tx *types.Transaction) *ethapi.RPCTransaction { R: (*hexutil.Big)(r), S: (*hexutil.Big)(s), } + switch tx.Type() { + case types.AccessListTxType: + al := tx.AccessList() + result.Accesses = &al + result.ChainID = (*hexutil.Big)(tx.ChainId()) + case types.DynamicFeeTxType: + al := tx.AccessList() + result.Accesses = &al + result.ChainID = (*hexutil.Big)(tx.ChainId()) + result.GasFeeCap = (*hexutil.Big)(tx.GasFeeCap()) + result.GasTipCap = (*hexutil.Big)(tx.GasTipCap()) + // if the transaction has been mined, compute the effective gas price + result.GasPrice = nil + } return result }