forked from cerc-io/laconicd-deprecated
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:
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package keeper
|
||||
|
||||
import (
|
||||
"context"
|
||||
"math/big"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
|
||||
@@ -25,15 +24,15 @@ func (k Keeper) Params(c context.Context, _ *types.QueryParamsRequest) (*types.Q
|
||||
func (k Keeper) BaseFee(c context.Context, _ *types.QueryBaseFeeRequest) (*types.QueryBaseFeeResponse, error) {
|
||||
ctx := sdk.UnwrapSDKContext(c)
|
||||
|
||||
res := &types.QueryBaseFeeResponse{}
|
||||
baseFee := k.GetBaseFee(ctx)
|
||||
if baseFee == nil {
|
||||
// TODO: should this be 0? 1? error?
|
||||
baseFee = big.NewInt(0)
|
||||
|
||||
if baseFee != nil {
|
||||
aux := sdk.NewIntFromBigInt(baseFee)
|
||||
res.BaseFee = &aux
|
||||
}
|
||||
|
||||
return &types.QueryBaseFeeResponse{
|
||||
BaseFee: sdk.NewIntFromBigInt(baseFee),
|
||||
}, nil
|
||||
return res, nil
|
||||
}
|
||||
|
||||
// BlockGas implements the Query/BlockGas gRPC method
|
||||
|
||||
Generated
+45
-39
@@ -153,7 +153,7 @@ var xxx_messageInfo_QueryBaseFeeRequest proto.InternalMessageInfo
|
||||
|
||||
// BaseFeeResponse returns the EIP1559 base fee.
|
||||
type QueryBaseFeeResponse struct {
|
||||
BaseFee github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,1,opt,name=base_fee,json=baseFee,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"base_fee"`
|
||||
BaseFee *github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,1,opt,name=base_fee,json=baseFee,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"base_fee,omitempty"`
|
||||
}
|
||||
|
||||
func (m *QueryBaseFeeResponse) Reset() { *m = QueryBaseFeeResponse{} }
|
||||
@@ -287,34 +287,34 @@ func init() {
|
||||
|
||||
var fileDescriptor_71a07c1ffd85fde2 = []byte{
|
||||
// 450 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x53, 0xbf, 0x8f, 0xd3, 0x30,
|
||||
0x14, 0x8e, 0x29, 0xf4, 0x0e, 0xb3, 0x20, 0xd3, 0x3b, 0x9d, 0xc2, 0x91, 0x3b, 0x05, 0xe9, 0xc4,
|
||||
0xaf, 0xb3, 0x75, 0xc7, 0xca, 0x94, 0x01, 0xb8, 0x0d, 0xc2, 0xc6, 0x52, 0x39, 0xe5, 0x35, 0x8d,
|
||||
0xda, 0xc4, 0x69, 0xec, 0x56, 0x74, 0x85, 0x85, 0x81, 0x01, 0x89, 0x3f, 0x82, 0x7f, 0xa5, 0x63,
|
||||
0x25, 0x16, 0xc4, 0x50, 0xa1, 0x96, 0x3f, 0x04, 0xc5, 0x71, 0xda, 0x86, 0xb6, 0xd0, 0x29, 0xd6,
|
||||
0xcb, 0xe7, 0xef, 0xfb, 0xde, 0xf7, 0xfc, 0xb0, 0x0b, 0xaa, 0x03, 0x59, 0x1c, 0x25, 0x8a, 0xb5,
|
||||
0x01, 0x62, 0x9e, 0x75, 0x41, 0xb1, 0xe1, 0x05, 0xeb, 0x0f, 0x20, 0x1b, 0xd1, 0x34, 0x13, 0x4a,
|
||||
0x90, 0xc3, 0x05, 0x86, 0x2e, 0x30, 0x74, 0x78, 0x61, 0x37, 0x42, 0x11, 0x0a, 0x0d, 0x61, 0xf9,
|
||||
0xa9, 0x40, 0xdb, 0xc7, 0xa1, 0x10, 0x61, 0x0f, 0x18, 0x4f, 0x23, 0xc6, 0x93, 0x44, 0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0x05, 0x28, 0xb5, 0xde, 0xe2, 0x46, 0xb5, 0x6c, 0xc4, 0x9e, 0xe0,
|
||||
0xdd, 0x80, 0x4b, 0xb8, 0x6c, 0x01, 0x68, 0xb9, 0xeb, 0xde, 0xe9, 0xcf, 0xc9, 0xd1, 0x49, 0x18,
|
||||
0xa9, 0x76, 0x3f, 0xa0, 0x4d, 0x11, 0xb3, 0xa6, 0x90, 0xb1, 0x90, 0xe6, 0x73, 0x26, 0xdf, 0x75,
|
||||
0x98, 0x1a, 0xa6, 0x20, 0xe9, 0x8b, 0x44, 0xf9, 0x3b, 0x41, 0x41, 0xe7, 0xee, 0x97, 0xf4, 0x5d,
|
||||
0xd1, 0xec, 0x3c, 0xe3, 0xf3, 0x16, 0xef, 0xe3, 0xbd, 0xbf, 0xea, 0x46, 0xf7, 0x26, 0xae, 0x85,
|
||||
0xbc, 0xe8, 0xb0, 0xe6, 0xe7, 0xc7, 0x8b, 0x6f, 0x35, 0x7c, 0x4d, 0x63, 0xc9, 0x47, 0x84, 0xeb,
|
||||
0x45, 0x6f, 0xe4, 0x74, 0x53, 0xef, 0xab, 0x71, 0xda, 0x0f, 0xb6, 0xc2, 0x16, 0xfa, 0xee, 0xf1,
|
||||
0x87, 0xef, 0xbf, 0xbf, 0x5e, 0xb1, 0xc9, 0xc1, 0xd2, 0xe0, 0x60, 0x10, 0xe7, 0xc3, 0x2b, 0x82,
|
||||
0x24, 0x9f, 0x10, 0xde, 0x31, 0x69, 0x91, 0x7f, 0x53, 0x57, 0xa3, 0xb6, 0x1f, 0x6e, 0x07, 0x36,
|
||||
0x46, 0x5c, 0x6d, 0xe4, 0x90, 0xd8, 0xab, 0x46, 0xca, 0xc1, 0x90, 0xcf, 0x08, 0xef, 0x96, 0x09,
|
||||
0x92, 0xff, 0xd0, 0x57, 0x07, 0x60, 0x9f, 0x6d, 0x89, 0x36, 0x6e, 0xee, 0x6a, 0x37, 0x77, 0xc8,
|
||||
0xed, 0x35, 0x6e, 0x72, 0xec, 0x65, 0xc8, 0xa5, 0xf7, 0x7c, 0x34, 0x75, 0xd0, 0x78, 0xea, 0xa0,
|
||||
0x5f, 0x53, 0x07, 0x7d, 0x99, 0x39, 0xd6, 0x78, 0xe6, 0x58, 0x3f, 0x66, 0x8e, 0xf5, 0x86, 0x2e,
|
||||
0xbd, 0x1b, 0xd5, 0xe6, 0x99, 0x8c, 0x24, 0x5b, 0xac, 0xc8, 0xfb, 0x25, 0x52, 0xfd, 0x86, 0x82,
|
||||
0xba, 0x5e, 0x8f, 0x47, 0x7f, 0x02, 0x00, 0x00, 0xff, 0xff, 0x85, 0x23, 0x79, 0x71, 0xb8, 0x03,
|
||||
0x00, 0x00,
|
||||
}
|
||||
|
||||
@@ -575,16 +575,18 @@ func (m *QueryBaseFeeResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
_ = i
|
||||
var l int
|
||||
_ = l
|
||||
{
|
||||
size := m.BaseFee.Size()
|
||||
i -= size
|
||||
if _, err := m.BaseFee.MarshalTo(dAtA[i:]); err != nil {
|
||||
return 0, err
|
||||
if m.BaseFee != nil {
|
||||
{
|
||||
size := m.BaseFee.Size()
|
||||
i -= size
|
||||
if _, err := m.BaseFee.MarshalTo(dAtA[i:]); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
i = encodeVarintQuery(dAtA, i, uint64(size))
|
||||
}
|
||||
i = encodeVarintQuery(dAtA, i, uint64(size))
|
||||
i--
|
||||
dAtA[i] = 0xa
|
||||
}
|
||||
i--
|
||||
dAtA[i] = 0xa
|
||||
return len(dAtA) - i, nil
|
||||
}
|
||||
|
||||
@@ -685,8 +687,10 @@ func (m *QueryBaseFeeResponse) Size() (n int) {
|
||||
}
|
||||
var l int
|
||||
_ = l
|
||||
l = m.BaseFee.Size()
|
||||
n += 1 + l + sovQuery(uint64(l))
|
||||
if m.BaseFee != nil {
|
||||
l = m.BaseFee.Size()
|
||||
n += 1 + l + sovQuery(uint64(l))
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
@@ -959,6 +963,8 @@ func (m *QueryBaseFeeResponse) Unmarshal(dAtA []byte) error {
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
var v github_com_cosmos_cosmos_sdk_types.Int
|
||||
m.BaseFee = &v
|
||||
if err := m.BaseFee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user