From ff7ca942dc7c25c8406d6772bada10051132fb02 Mon Sep 17 00:00:00 2001 From: sudeepdino008 Date: Mon, 1 Jul 2024 13:18:01 +0530 Subject: [PATCH] respond to comments --- cmd/evm/internal/t8ntool/transition.go | 113 ++++++------------ core/state_transition.go | 3 +- core/types/access_list_tx.go | 4 +- core/types/blob_tx_wrapper.go | 2 +- core/types/dynamic_fee_tx.go | 8 +- core/types/legacy_tx.go | 4 +- core/types/set_code_tx.go | 4 +- core/types/transaction.go | 4 +- erigon-lib/txpool/txpoolcfg/txpoolcfg.go | 1 + erigon-lib/types/txn.go | 2 +- turbo/jsonrpc/eth_api.go | 141 ++++++++++------------- 11 files changed, 114 insertions(+), 172 deletions(-) diff --git a/cmd/evm/internal/t8ntool/transition.go b/cmd/evm/internal/t8ntool/transition.go index 575ae8774bd..a0deef87959 100644 --- a/cmd/evm/internal/t8ntool/transition.go +++ b/cmd/evm/internal/t8ntool/transition.go @@ -392,101 +392,79 @@ func getTransaction(txJson jsonrpc.RPCTransaction) (types.Transaction, error) { var chainId *uint256.Int if txJson.Value != nil { - value, overflow = uint256.FromBig((*big.Int)(txJson.Value)) + value, overflow = uint256.FromBig(txJson.Value.ToInt()) if overflow { return nil, fmt.Errorf("value field caused an overflow (uint256)") } } if txJson.GasPrice != nil { - gasPrice, overflow = uint256.FromBig((*big.Int)(txJson.GasPrice)) + gasPrice, overflow = uint256.FromBig(txJson.GasPrice.ToInt()) if overflow { return nil, fmt.Errorf("gasPrice field caused an overflow (uint256)") } } if txJson.ChainID != nil { - chainId, overflow = uint256.FromBig((*big.Int)(txJson.ChainID)) + chainId, overflow = uint256.FromBig(txJson.ChainID.ToInt()) if overflow { return nil, fmt.Errorf("chainId field caused an overflow (uint256)") } } - switch txJson.Type { - case types.LegacyTxType, types.AccessListTxType: - var toAddr = libcommon.Address{} - if txJson.To != nil { - toAddr = *txJson.To - } - legacyTx := types.NewTransaction(uint64(txJson.Nonce), toAddr, value, uint64(txJson.Gas), gasPrice, txJson.Input) - legacyTx.V.SetFromBig(txJson.V.ToInt()) - legacyTx.S.SetFromBig(txJson.S.ToInt()) - legacyTx.R.SetFromBig(txJson.R.ToInt()) + commonTx := types.CommonTx{ + Nonce: uint64(txJson.Nonce), + To: txJson.To, + Value: value, + Gas: uint64(txJson.Gas), + Data: txJson.Input, + } - if txJson.Type == types.AccessListTxType { - accessListTx := types.AccessListTx{ - LegacyTx: *legacyTx, - ChainID: chainId, - AccessList: *txJson.Accesses, - } + commonTx.V.SetFromBig(txJson.V.ToInt()) + commonTx.R.SetFromBig(txJson.R.ToInt()) + commonTx.S.SetFromBig(txJson.S.ToInt()) + if txJson.Type == types.LegacyTxType || txJson.Type == types.AccessListTxType { + legacyTx := types.LegacyTx{ + CommonTx: commonTx, + GasPrice: gasPrice, + } - return &accessListTx, nil - } else { - return legacyTx, nil + if txJson.Type == types.LegacyTxType { + return &legacyTx, nil } - case types.DynamicFeeTxType: + return &types.AccessListTx{ + LegacyTx: legacyTx, + ChainID: chainId, + AccessList: *txJson.Accesses, + }, nil + } else if txJson.Type == types.DynamicFeeTxType || txJson.Type == types.SetCodeTxType { var tip *uint256.Int var feeCap *uint256.Int if txJson.Tip != nil { - tip, overflow = uint256.FromBig((*big.Int)(txJson.Tip)) + tip, overflow = uint256.FromBig(txJson.Tip.ToInt()) if overflow { return nil, fmt.Errorf("maxPriorityFeePerGas field caused an overflow (uint256)") } } if txJson.FeeCap != nil { - feeCap, overflow = uint256.FromBig((*big.Int)(txJson.FeeCap)) + feeCap, overflow = uint256.FromBig(txJson.FeeCap.ToInt()) if overflow { return nil, fmt.Errorf("maxFeePerGas field caused an overflow (uint256)") } } dynamicFeeTx := types.DynamicFeeTransaction{ - CommonTx: types.CommonTx{ - Nonce: uint64(txJson.Nonce), - To: txJson.To, - Value: value, - Gas: uint64(txJson.Gas), - Data: txJson.Input, - }, + CommonTx: commonTx, ChainID: chainId, Tip: tip, FeeCap: feeCap, AccessList: *txJson.Accesses, } - dynamicFeeTx.V.SetFromBig(txJson.V.ToInt()) - dynamicFeeTx.S.SetFromBig(txJson.S.ToInt()) - dynamicFeeTx.R.SetFromBig(txJson.R.ToInt()) - - return &dynamicFeeTx, nil - - case types.SetCodeTxType: - var tip *uint256.Int - var feeCap *uint256.Int - if txJson.Tip != nil { - tip, overflow = uint256.FromBig((*big.Int)(txJson.Tip)) - if overflow { - return nil, fmt.Errorf("maxPriorityFeePerGas field caused an overflow (uint256)") - } - } - - if txJson.FeeCap != nil { - feeCap, overflow = uint256.FromBig((*big.Int)(txJson.FeeCap)) - if overflow { - return nil, fmt.Errorf("maxFeePerGas field caused an overflow (uint256)") - } + if txJson.Type == types.DynamicFeeTxType { + return &dynamicFeeTx, nil } auths := make([]types.Authorization, 0) @@ -494,30 +472,11 @@ func getTransaction(txJson jsonrpc.RPCTransaction) (types.Transaction, error) { auths = append(auths, auth.ToAuthorization()) } - setCodeTx := types.SetCodeTransaction{ - DynamicFeeTransaction: types.DynamicFeeTransaction{ - CommonTx: types.CommonTx{ - Nonce: uint64(txJson.Nonce), - To: txJson.To, - Value: value, - Gas: uint64(txJson.Gas), - Data: txJson.Input, - }, - ChainID: chainId, - Tip: tip, - FeeCap: feeCap, - AccessList: *txJson.Accesses, - }, - Authorizations: auths, - } - - setCodeTx.V.SetFromBig(txJson.V.ToInt()) - setCodeTx.S.SetFromBig(txJson.S.ToInt()) - setCodeTx.R.SetFromBig(txJson.R.ToInt()) - - return &setCodeTx, nil - - default: + return &types.SetCodeTransaction{ + DynamicFeeTransaction: dynamicFeeTx, + Authorizations: auths, + }, nil + } else { return nil, nil } } diff --git a/core/state_transition.go b/core/state_transition.go index bc6d3f882d6..69269ec33cd 100644 --- a/core/state_transition.go +++ b/core/state_transition.go @@ -101,6 +101,7 @@ type Message interface { } // IntrinsicGas computes the 'intrinsic gas' for a message with the given data. +// TODO: convert the input to a struct func IntrinsicGas(data []byte, accessList types2.AccessList, isContractCreation bool, isHomestead, isEIP2028, isEIP3860 bool, authorizationsLen uint64) (uint64, error) { // Zero and non-zero bytes are priced differently dataLen := uint64(len(data)) @@ -383,7 +384,7 @@ func (st *StateTransition) TransitionDb(refunds bool, gasBailout bool) (*evmtype defer st.state.SetCode(authority, nil) // reset code after execution // 6. add authority account to accesses_addresses - if !accessTuples.IsPresent(authority) { + if !accessTuples.HasAddr(authority) { accessTuples = append(accessTuples, types2.AccessTuple{Address: authority, StorageKeys: nil}) } diff --git a/core/types/access_list_tx.go b/core/types/access_list_tx.go index 2e34f8df069..efbc86eb856 100644 --- a/core/types/access_list_tx.go +++ b/core/types/access_list_tx.go @@ -446,13 +446,13 @@ func (tx *AccessListTx) WithSignature(signer Signer, sig []byte) (Transaction, e cpy.ChainID = signer.ChainID() return cpy, nil } -func (tx *AccessListTx) FakeSign(address libcommon.Address) (Transaction, error) { +func (tx *AccessListTx) FakeSign(address libcommon.Address) Transaction { cpy := tx.copy() cpy.R.Set(u256.Num1) cpy.S.Set(u256.Num1) cpy.V.Set(u256.Num4) cpy.from.Store(address) - return cpy, nil + return cpy } // Hash computes the hash (but not for signatures!) diff --git a/core/types/blob_tx_wrapper.go b/core/types/blob_tx_wrapper.go index 39af053876f..664c8b29a2c 100644 --- a/core/types/blob_tx_wrapper.go +++ b/core/types/blob_tx_wrapper.go @@ -312,7 +312,7 @@ func (txw *BlobTxWrapper) WithSignature(signer Signer, sig []byte) (Transaction, return txw.Tx.WithSignature(signer, sig) } -func (txw *BlobTxWrapper) FakeSign(address libcommon.Address) (Transaction, error) { +func (txw *BlobTxWrapper) FakeSign(address libcommon.Address) Transaction { return txw.Tx.FakeSign(address) } diff --git a/core/types/dynamic_fee_tx.go b/core/types/dynamic_fee_tx.go index 7ddffbd3ea9..8d263282971 100644 --- a/core/types/dynamic_fee_tx.go +++ b/core/types/dynamic_fee_tx.go @@ -167,13 +167,13 @@ func (tx *DynamicFeeTransaction) WithSignature(signer Signer, sig []byte) (Trans return cpy, nil } -func (tx *DynamicFeeTransaction) FakeSign(address libcommon.Address) (Transaction, error) { +func (tx *DynamicFeeTransaction) FakeSign(address libcommon.Address) Transaction { cpy := tx.copy() cpy.R.Set(u256.Num1) cpy.S.Set(u256.Num1) cpy.V.Set(u256.Num4) cpy.from.Store(address) - return cpy, nil + return cpy } // MarshalBinary returns the canonical encoding of the transaction. @@ -256,10 +256,10 @@ func (tx *DynamicFeeTransaction) encodePayload(w io.Writer, b []byte, payloadSiz func (tx *DynamicFeeTransaction) EncodeRLP(w io.Writer) error { payloadSize, nonceLen, gasLen, accessListLen := tx.payloadSize() // size of struct prefix and TxType - envelopSize := 1 + rlp2.ListPrefixLen(payloadSize) + payloadSize + envelopeSize := 1 + rlp2.ListPrefixLen(payloadSize) + payloadSize var b [33]byte // envelope - if err := rlp.EncodeStringSizePrefix(envelopSize, w, b[:]); err != nil { + if err := rlp.EncodeStringSizePrefix(envelopeSize, w, b[:]); err != nil { return err } // encode TxType diff --git a/core/types/legacy_tx.go b/core/types/legacy_tx.go index b3f21f1c50e..2412fdaf43c 100644 --- a/core/types/legacy_tx.go +++ b/core/types/legacy_tx.go @@ -376,13 +376,13 @@ func (tx *LegacyTx) WithSignature(signer Signer, sig []byte) (Transaction, error return cpy, nil } -func (tx *LegacyTx) FakeSign(address libcommon.Address) (Transaction, error) { +func (tx *LegacyTx) FakeSign(address libcommon.Address) Transaction { cpy := tx.copy() cpy.R.Set(u256.Num1) cpy.S.Set(u256.Num1) cpy.V.Set(u256.Num4) cpy.from.Store(address) - return cpy, nil + return cpy } // Hash computes the hash (but not for signatures!) diff --git a/core/types/set_code_tx.go b/core/types/set_code_tx.go index def59b43124..92fbb145585 100644 --- a/core/types/set_code_tx.go +++ b/core/types/set_code_tx.go @@ -74,13 +74,13 @@ func (tx *SetCodeTransaction) WithSignature(signer Signer, sig []byte) (Transact return cpy, nil } -func (tx *SetCodeTransaction) FakeSign(address libcommon.Address) (Transaction, error) { +func (tx *SetCodeTransaction) FakeSign(address libcommon.Address) Transaction { cpy := tx.copy() cpy.R.Set(u256.Num1) cpy.S.Set(u256.Num1) cpy.V.Set(u256.Num4) cpy.from.Store(address) - return cpy, nil + return cpy } func (tx *SetCodeTransaction) MarshalBinary(w io.Writer) error { diff --git a/core/types/transaction.go b/core/types/transaction.go index 65bcdf2eee1..083b90e5f3b 100644 --- a/core/types/transaction.go +++ b/core/types/transaction.go @@ -72,7 +72,7 @@ type Transaction interface { GetAuthorizations() []Authorization AsMessage(s Signer, baseFee *big.Int, rules *chain.Rules) (Message, error) WithSignature(signer Signer, sig []byte) (Transaction, error) - FakeSign(address libcommon.Address) (Transaction, error) + FakeSign(address libcommon.Address) Transaction Hash() libcommon.Hash SigningHash(chainID *big.Int) libcommon.Hash GetData() []byte @@ -496,4 +496,4 @@ func DecodeSSZ(data []byte, dest codec.Deserializable) error { func EncodeSSZ(w io.Writer, obj codec.Serializable) error { return obj.Serialize(codec.NewEncodingWriter(w)) -} \ No newline at end of file +} diff --git a/erigon-lib/txpool/txpoolcfg/txpoolcfg.go b/erigon-lib/txpool/txpoolcfg/txpoolcfg.go index 4eeefb75ad7..3a7f85d609d 100644 --- a/erigon-lib/txpool/txpoolcfg/txpoolcfg.go +++ b/erigon-lib/txpool/txpoolcfg/txpoolcfg.go @@ -183,6 +183,7 @@ func (r DiscardReason) String() string { } // CalcIntrinsicGas computes the 'intrinsic gas' for a message with the given data. +// TODO: move input data to a struct func CalcIntrinsicGas(dataLen, dataNonZeroLen, authorizationsLen uint64, accessList types.AccessList, isContractCreation, isHomestead, isEIP2028, isShanghai bool) (uint64, DiscardReason) { // Set the starting gas for the raw transaction var gas uint64 diff --git a/erigon-lib/types/txn.go b/erigon-lib/types/txn.go index 7fbbb18a05e..2116ea87d0c 100644 --- a/erigon-lib/types/txn.go +++ b/erigon-lib/types/txn.go @@ -986,7 +986,7 @@ func (al AccessList) StorageKeys() int { return sum } -func (al AccessList) IsPresent(addr common.Address) bool { +func (al AccessList) HasAddr(addr common.Address) bool { for _, tuple := range al { if tuple.Address == addr { return true diff --git a/turbo/jsonrpc/eth_api.go b/turbo/jsonrpc/eth_api.go index 22958f8d538..d5fd00e9526 100644 --- a/turbo/jsonrpc/eth_api.go +++ b/turbo/jsonrpc/eth_api.go @@ -393,88 +393,69 @@ 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, baseFee *big.Int) *RPCTransaction { +func NewRPCTransaction(txn 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 is used // because the return value of ChainId is zero for those transactions. chainId := uint256.NewInt(0) result := &RPCTransaction{ - Type: hexutil.Uint64(tx.Type()), - Gas: hexutil.Uint64(tx.GetGas()), - Hash: tx.Hash(), - Input: hexutility.Bytes(tx.GetData()), - Nonce: hexutil.Uint64(tx.GetNonce()), - To: tx.GetTo(), - Value: (*hexutil.Big)(tx.GetValue().ToBig()), - } - if t, ok := tx.(*types.BlobTxWrapper); ok { - tx = &t.Tx - } - switch t := tx.(type) { - case *types.LegacyTx: - chainId = types.DeriveChainId(&t.V) + Type: hexutil.Uint64(txn.Type()), + Gas: hexutil.Uint64(txn.GetGas()), + Hash: txn.Hash(), + Input: hexutility.Bytes(txn.GetData()), + Nonce: hexutil.Uint64(txn.GetNonce()), + To: txn.GetTo(), + Value: (*hexutil.Big)(txn.GetValue().ToBig()), + } + if t, ok := txn.(*types.BlobTxWrapper); ok { + txn = &t.Tx + } + + v, r, s := txn.RawSignatureValues() + result.V = (*hexutil.Big)(v.ToBig()) + result.R = (*hexutil.Big)(r.ToBig()) + result.S = (*hexutil.Big)(s.ToBig()) + + if txn.Type() == types.LegacyTxType { + chainId = types.DeriveChainId(v) // if a legacy transaction has an EIP-155 chain id, include it explicitly, otherwise chain id is not included if !chainId.IsZero() { result.ChainID = (*hexutil.Big)(chainId.ToBig()) } - result.GasPrice = (*hexutil.Big)(t.GasPrice.ToBig()) - result.V = (*hexutil.Big)(t.V.ToBig()) - result.R = (*hexutil.Big)(t.R.ToBig()) - result.S = (*hexutil.Big)(t.S.ToBig()) - case *types.AccessListTx: - chainId.Set(t.ChainID) - result.ChainID = (*hexutil.Big)(chainId.ToBig()) - result.GasPrice = (*hexutil.Big)(t.GasPrice.ToBig()) - result.YParity = (*hexutil.Big)(t.V.ToBig()) - result.V = (*hexutil.Big)(t.V.ToBig()) - result.R = (*hexutil.Big)(t.R.ToBig()) - result.S = (*hexutil.Big)(t.S.ToBig()) - result.Accesses = &t.AccessList - case *types.DynamicFeeTransaction: - chainId.Set(t.ChainID) + result.GasPrice = (*hexutil.Big)(txn.GetPrice().ToBig()) + } else { + chainId.Set(txn.GetChainID()) result.ChainID = (*hexutil.Big)(chainId.ToBig()) - result.Tip = (*hexutil.Big)(t.Tip.ToBig()) - result.FeeCap = (*hexutil.Big)(t.FeeCap.ToBig()) - result.YParity = (*hexutil.Big)(t.V.ToBig()) - result.V = (*hexutil.Big)(t.V.ToBig()) - result.R = (*hexutil.Big)(t.R.ToBig()) - result.S = (*hexutil.Big)(t.S.ToBig()) - result.Accesses = &t.AccessList - result.GasPrice = computeGasPrice(tx, blockHash, baseFee) - case *types.BlobTx: - chainId.Set(t.ChainID) - result.ChainID = (*hexutil.Big)(chainId.ToBig()) - result.Tip = (*hexutil.Big)(t.Tip.ToBig()) - result.FeeCap = (*hexutil.Big)(t.FeeCap.ToBig()) - result.YParity = (*hexutil.Big)(t.V.ToBig()) - result.V = (*hexutil.Big)(t.V.ToBig()) - result.R = (*hexutil.Big)(t.R.ToBig()) - result.S = (*hexutil.Big)(t.S.ToBig()) - result.Accesses = &t.AccessList - result.GasPrice = computeGasPrice(tx, blockHash, baseFee) - result.MaxFeePerBlobGas = (*hexutil.Big)(t.MaxFeePerBlobGas.ToBig()) - result.BlobVersionedHashes = t.BlobVersionedHashes - case *types.SetCodeTransaction: - chainId.Set(t.ChainID) - result.ChainID = (*hexutil.Big)(chainId.ToBig()) - result.Tip = (*hexutil.Big)(t.Tip.ToBig()) - result.FeeCap = (*hexutil.Big)(t.FeeCap.ToBig()) - result.YParity = (*hexutil.Big)(t.V.ToBig()) - result.V = (*hexutil.Big)(t.V.ToBig()) - result.R = (*hexutil.Big)(t.R.ToBig()) - result.S = (*hexutil.Big)(t.S.ToBig()) - result.Accesses = &t.AccessList - result.GasPrice = computeGasPrice(tx, blockHash, baseFee) - ats := make([]types.JsonAuthorization, len(t.Authorizations)) - for i, a := range t.Authorizations { - ats[i] = types.JsonAuthorization{}.FromAuthorization(a) + result.YParity = (*hexutil.Big)(v.ToBig()) + acl := txn.GetAccessList() + result.Accesses = &acl + + if txn.Type() == types.AccessListTxType { + result.GasPrice = (*hexutil.Big)(txn.GetPrice().ToBig()) + } else { + result.GasPrice = computeGasPrice(txn, blockHash, baseFee) + result.Tip = (*hexutil.Big)(txn.GetTip().ToBig()) + result.FeeCap = (*hexutil.Big)(txn.GetFeeCap().ToBig()) + } + + if txn.Type() == types.BlobTxType { + txn.GetBlobGas() + blobTx := txn.(*types.BlobTx) + result.MaxFeePerBlobGas = (*hexutil.Big)(blobTx.MaxFeePerBlobGas.ToBig()) + result.BlobVersionedHashes = blobTx.BlobVersionedHashes + } else if txn.Type() == types.SetCodeTxType { + ats := make([]types.JsonAuthorization, len(txn.GetAuthorizations())) + for i, a := range txn.GetAuthorizations() { + ats[i] = types.JsonAuthorization{}.FromAuthorization(a) + } + result.Authorizations = &ats } - result.Authorizations = &ats } + signer := types.LatestSignerForChainID(chainId.ToBig()) var err error - result.From, err = tx.Sender(*signer) + result.From, err = txn.Sender(*signer) if err != nil { log.Warn("sender recovery", "err", err) } @@ -486,11 +467,11 @@ func NewRPCTransaction(tx types.Transaction, blockHash common.Hash, blockNumber return result } -func computeGasPrice(tx types.Transaction, blockHash common.Hash, baseFee *big.Int) *hexutil.Big { +func computeGasPrice(txn types.Transaction, blockHash common.Hash, baseFee *big.Int) *hexutil.Big { fee, overflow := uint256.FromBig(baseFee) if fee != nil && !overflow && blockHash != (common.Hash{}) { // price = min(tip + baseFee, gasFeeCap) - price := math.Min256(new(uint256.Int).Add(tx.GetTip(), fee), tx.GetFeeCap()) + price := math.Min256(new(uint256.Int).Add(txn.GetTip(), fee), txn.GetFeeCap()) return (*hexutil.Big)(price.ToBig()) } return nil @@ -498,19 +479,19 @@ func computeGasPrice(tx types.Transaction, blockHash common.Hash, baseFee *big.I // newRPCBorTransaction returns a Bor transaction that will serialize to the RPC // representation, with the given location metadata set (if available). -func newRPCBorTransaction(opaqueTx types.Transaction, txHash common.Hash, blockHash common.Hash, blockNumber uint64, index uint64, baseFee *big.Int, chainId *big.Int) *RPCTransaction { - tx := opaqueTx.(*types.LegacyTx) +func newRPCBorTransaction(opaqueTxn types.Transaction, txHash common.Hash, blockHash common.Hash, blockNumber uint64, index uint64, baseFee *big.Int, chainId *big.Int) *RPCTransaction { + txn := opaqueTxn.(*types.LegacyTx) result := &RPCTransaction{ - Type: hexutil.Uint64(tx.Type()), + Type: hexutil.Uint64(txn.Type()), ChainID: (*hexutil.Big)(new(big.Int)), - GasPrice: (*hexutil.Big)(tx.GasPrice.ToBig()), - Gas: hexutil.Uint64(tx.GetGas()), + GasPrice: (*hexutil.Big)(txn.GasPrice.ToBig()), + Gas: hexutil.Uint64(txn.GetGas()), Hash: txHash, - Input: hexutility.Bytes(tx.GetData()), - Nonce: hexutil.Uint64(tx.GetNonce()), + Input: hexutility.Bytes(txn.GetData()), + Nonce: hexutil.Uint64(txn.GetNonce()), From: common.Address{}, - To: tx.GetTo(), - Value: (*hexutil.Big)(tx.GetValue().ToBig()), + To: txn.GetTo(), + Value: (*hexutil.Big)(txn.GetValue().ToBig()), V: (*hexutil.Big)(big.NewInt(0)), R: (*hexutil.Big)(big.NewInt(0)), S: (*hexutil.Big)(big.NewInt(0)), @@ -525,12 +506,12 @@ func newRPCBorTransaction(opaqueTx types.Transaction, txHash common.Hash, blockH } // newRPCPendingTransaction returns a pending transaction that will serialize to the RPC representation -func newRPCPendingTransaction(tx types.Transaction, current *types.Header, config *chain.Config) *RPCTransaction { +func newRPCPendingTransaction(txn types.Transaction, current *types.Header, config *chain.Config) *RPCTransaction { var baseFee *big.Int if current != nil { baseFee = misc.CalcBaseFee(config, current) } - return NewRPCTransaction(tx, common.Hash{}, 0, 0, baseFee) + return NewRPCTransaction(txn, common.Hash{}, 0, 0, baseFee) } // newRPCRawTransactionFromBlockIndex returns the bytes of a transaction given a block and a transaction index.