forked from cerc-io/laconicd-deprecated
rpc: geth v1.10.8 changes (#585)
This commit is contained in:
parent
b42e187060
commit
bbb54a6d17
@ -13,6 +13,7 @@ import (
|
|||||||
"github.com/cosmos/cosmos-sdk/server"
|
"github.com/cosmos/cosmos-sdk/server"
|
||||||
authtx "github.com/cosmos/cosmos-sdk/x/auth/tx"
|
authtx "github.com/cosmos/cosmos-sdk/x/auth/tx"
|
||||||
"github.com/ethereum/go-ethereum/accounts/keystore"
|
"github.com/ethereum/go-ethereum/accounts/keystore"
|
||||||
|
"github.com/ethereum/go-ethereum/params"
|
||||||
tmrpctypes "github.com/tendermint/tendermint/rpc/core/types"
|
tmrpctypes "github.com/tendermint/tendermint/rpc/core/types"
|
||||||
|
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
@ -43,6 +44,7 @@ type Backend interface {
|
|||||||
GetBlockByNumber(blockNum types.BlockNumber, fullTx bool) (map[string]interface{}, error)
|
GetBlockByNumber(blockNum types.BlockNumber, fullTx bool) (map[string]interface{}, error)
|
||||||
GetBlockByHash(hash common.Hash, fullTx bool) (map[string]interface{}, error)
|
GetBlockByHash(hash common.Hash, fullTx bool) (map[string]interface{}, error)
|
||||||
GetTendermintBlockByNumber(blockNum types.BlockNumber) (*tmrpctypes.ResultBlock, error)
|
GetTendermintBlockByNumber(blockNum types.BlockNumber) (*tmrpctypes.ResultBlock, error)
|
||||||
|
CurrentHeader() *ethtypes.Header
|
||||||
HeaderByNumber(blockNum types.BlockNumber) (*ethtypes.Header, error)
|
HeaderByNumber(blockNum types.BlockNumber) (*ethtypes.Header, error)
|
||||||
HeaderByHash(blockHash common.Hash) (*ethtypes.Header, error)
|
HeaderByHash(blockHash common.Hash) (*ethtypes.Header, error)
|
||||||
PendingTransactions() ([]*sdk.Tx, error)
|
PendingTransactions() ([]*sdk.Tx, error)
|
||||||
@ -58,6 +60,8 @@ type Backend interface {
|
|||||||
EstimateGas(args evmtypes.CallArgs, blockNrOptional *types.BlockNumber) (hexutil.Uint64, error)
|
EstimateGas(args evmtypes.CallArgs, blockNrOptional *types.BlockNumber) (hexutil.Uint64, error)
|
||||||
RPCGasCap() uint64
|
RPCGasCap() uint64
|
||||||
RPCMinGasPrice() int64
|
RPCMinGasPrice() int64
|
||||||
|
ChainConfig() *params.ChainConfig
|
||||||
|
SuggestGasTipCap() (*big.Int, error)
|
||||||
GetFilteredBlocks(from int64, to int64, filter [][]filters.BloomIV, filterAddresses bool) ([]int64, error)
|
GetFilteredBlocks(from int64, to int64, filter [][]filters.BloomIV, filterAddresses bool) ([]int64, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -274,9 +278,16 @@ func (e *EVMBackend) EthBlockFromTendermint(
|
|||||||
ConsAddress: sdk.ConsAddress(block.Header.ProposerAddress).String(),
|
ConsAddress: sdk.ConsAddress(block.Header.ProposerAddress).String(),
|
||||||
}
|
}
|
||||||
|
|
||||||
res, err := e.queryClient.ValidatorAccount(e.ctx, req)
|
ctx := types.ContextWithHeight(block.Height)
|
||||||
|
|
||||||
|
res, err := e.queryClient.ValidatorAccount(ctx, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
e.logger.Debug("failed to query validator operator address", "cons-address", req.ConsAddress, "error", err.Error())
|
e.logger.Debug(
|
||||||
|
"failed to query validator operator address",
|
||||||
|
"height", block.Height,
|
||||||
|
"cons-address", req.ConsAddress,
|
||||||
|
"error", err.Error(),
|
||||||
|
)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -287,7 +298,7 @@ func (e *EVMBackend) EthBlockFromTendermint(
|
|||||||
|
|
||||||
validatorAddr := common.BytesToAddress(addr)
|
validatorAddr := common.BytesToAddress(addr)
|
||||||
|
|
||||||
gasLimit, err := types.BlockMaxGasFromConsensusParams(types.ContextWithHeight(block.Height), e.clientCtx)
|
gasLimit, err := types.BlockMaxGasFromConsensusParams(ctx, e.clientCtx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
e.logger.Error("failed to query consensus params", "error", err.Error())
|
e.logger.Error("failed to query consensus params", "error", err.Error())
|
||||||
}
|
}
|
||||||
@ -308,6 +319,12 @@ func (e *EVMBackend) EthBlockFromTendermint(
|
|||||||
return formattedBlock, nil
|
return formattedBlock, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CurrentHeader returns the latest block header
|
||||||
|
func (e *EVMBackend) CurrentHeader() *ethtypes.Header {
|
||||||
|
header, _ := e.HeaderByNumber(types.EthLatestBlockNumber)
|
||||||
|
return header
|
||||||
|
}
|
||||||
|
|
||||||
// HeaderByNumber returns the block header identified by height.
|
// HeaderByNumber returns the block header identified by height.
|
||||||
func (e *EVMBackend) HeaderByNumber(blockNum types.BlockNumber) (*ethtypes.Header, error) {
|
func (e *EVMBackend) HeaderByNumber(blockNum types.BlockNumber) (*ethtypes.Header, error) {
|
||||||
height := blockNum.Int64()
|
height := blockNum.Int64()
|
||||||
@ -716,6 +733,22 @@ func (e *EVMBackend) RPCMinGasPrice() int64 {
|
|||||||
return ethermint.DefaultGasPrice
|
return ethermint.DefaultGasPrice
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ChainConfig return the ethereum chain configuration
|
||||||
|
func (e *EVMBackend) ChainConfig() *params.ChainConfig {
|
||||||
|
params, err := e.queryClient.Params(e.ctx, &evmtypes.QueryParamsRequest{})
|
||||||
|
if err != nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return params.Params.ChainConfig.EthereumConfig(e.chainID)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SuggestGasTipCap returns the suggested tip cap
|
||||||
|
func (e *EVMBackend) SuggestGasTipCap() (*big.Int, error) {
|
||||||
|
// TODO: implement
|
||||||
|
return big.NewInt(1), nil
|
||||||
|
}
|
||||||
|
|
||||||
// GetFilteredBlocks returns the block height list match the given bloom filters.
|
// GetFilteredBlocks returns the block height list match the given bloom filters.
|
||||||
func (e *EVMBackend) GetFilteredBlocks(
|
func (e *EVMBackend) GetFilteredBlocks(
|
||||||
from int64,
|
from int64,
|
||||||
|
@ -47,7 +47,7 @@ func (e *EVMBackend) setTxDefaults(args types.SendTxArgs) (types.SendTxArgs, err
|
|||||||
}
|
}
|
||||||
|
|
||||||
if len(input) == 0 {
|
if len(input) == 0 {
|
||||||
return args, errors.New(`contract creation without any data provided`)
|
return args, errors.New("contract creation without any data provided")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -152,6 +152,15 @@ func (api *PrivateAccountAPI) UnlockAccount(_ context.Context, addr common.Addre
|
|||||||
// able to decrypt the key it fails.
|
// able to decrypt the key it fails.
|
||||||
func (api *PrivateAccountAPI) SendTransaction(_ context.Context, args rpctypes.SendTxArgs, pwrd string) (common.Hash, error) {
|
func (api *PrivateAccountAPI) SendTransaction(_ context.Context, args rpctypes.SendTxArgs, pwrd string) (common.Hash, error) {
|
||||||
api.logger.Debug("personal_sendTransaction", "address", args.To.String())
|
api.logger.Debug("personal_sendTransaction", "address", args.To.String())
|
||||||
|
|
||||||
|
addr := sdk.AccAddress(args.From.Bytes())
|
||||||
|
|
||||||
|
// check if the key is on the keyring
|
||||||
|
_, err := api.clientCtx.Keyring.KeyByAddress(addr)
|
||||||
|
if err != nil {
|
||||||
|
return common.Hash{}, err
|
||||||
|
}
|
||||||
|
|
||||||
return api.backend.SendTransaction(args)
|
return api.backend.SendTransaction(args)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@ import (
|
|||||||
"github.com/cosmos/cosmos-sdk/client"
|
"github.com/cosmos/cosmos-sdk/client"
|
||||||
|
|
||||||
evmtypes "github.com/tharsis/ethermint/x/evm/types"
|
evmtypes "github.com/tharsis/ethermint/x/evm/types"
|
||||||
|
feemarkettypes "github.com/tharsis/ethermint/x/feemarket/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
// QueryClient defines a gRPC Client used for:
|
// QueryClient defines a gRPC Client used for:
|
||||||
@ -19,6 +20,7 @@ import (
|
|||||||
type QueryClient struct {
|
type QueryClient struct {
|
||||||
tx.ServiceClient
|
tx.ServiceClient
|
||||||
evmtypes.QueryClient
|
evmtypes.QueryClient
|
||||||
|
FeeMarket feemarkettypes.QueryClient
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewQueryClient creates a new gRPC query client
|
// NewQueryClient creates a new gRPC query client
|
||||||
@ -26,6 +28,7 @@ func NewQueryClient(clientCtx client.Context) *QueryClient {
|
|||||||
return &QueryClient{
|
return &QueryClient{
|
||||||
ServiceClient: tx.NewServiceClient(clientCtx),
|
ServiceClient: tx.NewServiceClient(clientCtx),
|
||||||
QueryClient: evmtypes.NewQueryClient(clientCtx),
|
QueryClient: evmtypes.NewQueryClient(clientCtx),
|
||||||
|
FeeMarket: feemarkettypes.NewQueryClient(clientCtx),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user