rpc: geth v1.10.9 changes (#624)

* rpc: geth v1.10.9 changes

* updates

* suggestGasTipCap

* update gRPC

* resend

* fixes

* rm unused func

* address TODO
This commit is contained in:
Federico Kunze Küllmer
2021-10-06 11:22:32 +00:00
committed by GitHub
parent 202bc5f1cd
commit bcdb982886
17 changed files with 427 additions and 221 deletions
+18 -1
View File
@@ -4,6 +4,7 @@ import (
"context"
"encoding/hex"
"encoding/json"
"math/big"
"net/http"
"strings"
@@ -15,6 +16,7 @@ import (
authrest "github.com/cosmos/cosmos-sdk/x/auth/client/rest"
rpctypes "github.com/tharsis/ethermint/rpc/ethereum/types"
feemarkettypes "github.com/tharsis/ethermint/x/feemarket/types"
"github.com/ethereum/go-ethereum/common"
)
@@ -79,6 +81,17 @@ func getEthTransactionByHash(clientCtx client.Context, hashHex string) ([]byte,
return nil, err
}
client := feemarkettypes.NewQueryClient(clientCtx)
res, err := client.BaseFee(context.Background(), &feemarkettypes.QueryBaseFeeRequest{})
if err != nil {
return nil, err
}
var baseFee *big.Int
if res.BaseFee != nil {
baseFee = res.BaseFee.BigInt()
}
blockHash := common.BytesToHash(block.Block.Header.Hash())
ethTx, err := rpctypes.RawTxToEthTx(clientCtx, tx.Tx)
@@ -87,7 +100,11 @@ func getEthTransactionByHash(clientCtx client.Context, hashHex string) ([]byte,
}
height := uint64(tx.Height)
rpcTx := rpctypes.NewTransaction(ethTx.AsTransaction(), blockHash, height, uint64(tx.Index))
rpcTx, err := rpctypes.NewRPCTransaction(ethTx.AsTransaction(), blockHash, height, uint64(tx.Index), baseFee)
if err != nil {
return nil, err
}
return json.Marshal(rpcTx)
}
+9 -9
View File
@@ -113,7 +113,7 @@ func (args *TransactionArgs) ToTransaction() *MsgEthereumTx {
GasFeeCap: &maxFeePerGas,
GasTipCap: &maxPriorityFeePerGas,
Amount: &value,
Data: args.data(),
Data: args.GetData(),
Accesses: al,
}
case args.AccessList != nil:
@@ -124,7 +124,7 @@ func (args *TransactionArgs) ToTransaction() *MsgEthereumTx {
GasLimit: gas,
GasPrice: &gasPrice,
Amount: &value,
Data: args.data(),
Data: args.GetData(),
Accesses: NewAccessList(args.AccessList),
}
default:
@@ -134,7 +134,7 @@ func (args *TransactionArgs) ToTransaction() *MsgEthereumTx {
GasLimit: gas,
GasPrice: &gasPrice,
Amount: &value,
Data: args.data(),
Data: args.GetData(),
}
}
@@ -162,7 +162,7 @@ func (args *TransactionArgs) ToMessage(globalGasCap uint64, baseFee *big.Int) (e
}
// Set sender address or use zero address if none specified.
addr := args.from()
addr := args.GetFrom()
// Set default gas & gas price if none were set
gas := globalGasCap
@@ -214,7 +214,7 @@ func (args *TransactionArgs) ToMessage(globalGasCap uint64, baseFee *big.Int) (e
if args.Value != nil {
value = args.Value.ToInt()
}
data := args.data()
data := args.GetData()
var accessList ethtypes.AccessList
if args.AccessList != nil {
accessList = *args.AccessList
@@ -223,16 +223,16 @@ func (args *TransactionArgs) ToMessage(globalGasCap uint64, baseFee *big.Int) (e
return msg, nil
}
// from retrieves the transaction sender address.
func (args *TransactionArgs) from() common.Address {
// GetFrom retrieves the transaction sender address.
func (args *TransactionArgs) GetFrom() common.Address {
if args.From == nil {
return common.Address{}
}
return *args.From
}
// data retrieves the transaction calldata. Input field is preferred.
func (args *TransactionArgs) data() []byte {
// GetData retrieves the transaction calldata. Input field is preferred.
func (args *TransactionArgs) GetData() []byte {
if args.Input != nil {
return *args.Input
}