rpc

package
v0.4.9-rc9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 5, 2024 License: Apache-2.0 Imports: 78 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultGethNodeConfig

func DefaultGethNodeConfig() *node.Config

DefaultConfig returns the default configuration for the provider.

func GetAPIs

func GetAPIs(clientCtx client.Context, serverCtx *server.Context, wsClient *rpcclient.WSClient, logger log.Logger, apiBackend *BackendImpl) []rpc.API

func NewNode

func NewNode(config *node.Config) (types.NetworkingStack, error)

Node creates a new NetworkingStack instance.

Types

type ArtelaService

type ArtelaService struct {
	// contains filtered or unexported fields
}

func NewArtelaService

func NewArtelaService(
	ctx *server.Context,
	clientCtx client.Context,
	wsClient *rpcclient.WSClient,
	cfg *Config,
	stack types.NetworkingStack,
	logger log.Logger,
	db db.DB,
) *ArtelaService

func (*ArtelaService) APIs

func (art *ArtelaService) APIs() []rpc.API

func (*ArtelaService) Shutdown

func (art *ArtelaService) Shutdown() error

func (*ArtelaService) Start

func (art *ArtelaService) Start() error

Start start the ethereum JsonRPC service

type BackendImpl

type BackendImpl struct {
	// contains filtered or unexported fields
}

backend represents the backend for the JSON-RPC service.

func NewBackend

func NewBackend(
	ctx *server.Context,
	clientCtx client.Context,
	artela *ArtelaService,
	extRPCEnabled bool,
	cfg *Config,
	logger log.Logger,
	db db.DB,
) *BackendImpl

NewBackend create the backend implements

func (*BackendImpl) Accounts

func (b *BackendImpl) Accounts() []common.Address

func (*BackendImpl) ArtBlockByNumber

func (b *BackendImpl) ArtBlockByNumber(_ context.Context, number rpc.BlockNumber) (*rpctypes.Block, error)

func (*BackendImpl) ArtBlockByNumberOrHash

func (b *BackendImpl) ArtBlockByNumberOrHash(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) (*rpctypes.Block, error)

func (*BackendImpl) BaseFee

func (b *BackendImpl) BaseFee(blockRes *tmrpctypes.ResultBlockResults) (*big.Int, error)

func (*BackendImpl) BlockBloom

func (b *BackendImpl) BlockBloom(blockRes *tmrpctypes.ResultBlockResults) (ethtypes.Bloom, error)

func (*BackendImpl) BlockByHash

func (b *BackendImpl) BlockByHash(_ context.Context, hash common.Hash) (*rpctypes.Block, error)

func (*BackendImpl) BlockByNumber

func (b *BackendImpl) BlockByNumber(ctx context.Context, number rpc.BlockNumber) (*ethtypes.Block, error)

BlockByNumber for OracleBackend, should not use it anywhere, unless you know about the block hash diffs. Use ArtBlockByNumber instead.

func (*BackendImpl) BlockByNumberOrHash

func (b *BackendImpl) BlockByNumberOrHash(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) (*ethtypes.Block, error)

BlockByNumberOrHash for OracleBackend, should not use it anywhere, unless you know about the block hash diffs. Use ArtBlockByNumberOrHash instead.

func (*BackendImpl) BlockFromCosmosBlock

func (b *BackendImpl) BlockFromCosmosBlock(resBlock *tmrpctypes.ResultBlock, blockRes *tmrpctypes.ResultBlockResults) (*rpctypes.Block, error)

func (*BackendImpl) BlockNumber

func (b *BackendImpl) BlockNumber() (hexutil.Uint64, error)

func (*BackendImpl) BlockTimeByNumber

func (b *BackendImpl) BlockTimeByNumber(blockNum int64) (uint64, error)

func (*BackendImpl) BloomStatus

func (b *BackendImpl) BloomStatus() (uint64, uint64)

func (*BackendImpl) ChainConfig

func (b *BackendImpl) ChainConfig() *params.ChainConfig

func (*BackendImpl) ChainDb

func (b *BackendImpl) ChainDb() ethdb.Database

func (*BackendImpl) ClientVersion

func (b *BackendImpl) ClientVersion() string

ClientVersion returns the current client version.

func (*BackendImpl) CosmosBlockByHash

func (b *BackendImpl) CosmosBlockByHash(blockHash common.Hash) (*tmrpctypes.ResultBlock, error)

func (*BackendImpl) CosmosBlockByNumber

func (b *BackendImpl) CosmosBlockByNumber(blockNum rpc.BlockNumber) (*tmrpctypes.ResultBlock, error)

func (*BackendImpl) CosmosBlockResultByNumber

func (b *BackendImpl) CosmosBlockResultByNumber(height *int64) (*tmrpctypes.ResultBlockResults, error)

func (*BackendImpl) CurrentBlock

func (b *BackendImpl) CurrentBlock() *rpctypes.Block

func (*BackendImpl) CurrentHeader

func (b *BackendImpl) CurrentHeader() (*ethtypes.Header, error)

func (*BackendImpl) DBCompact

func (b *BackendImpl) DBCompact(start []byte, limit []byte) error

func (*BackendImpl) DBProperty

func (b *BackendImpl) DBProperty(property string) (string, error)

func (*BackendImpl) DoCall

func (*BackendImpl) Engine

func (b *BackendImpl) Engine() consensus.Engine

func (*BackendImpl) EstimateGas

func (b *BackendImpl) EstimateGas(ctx context.Context, args rpctypes.TransactionArgs, blockNrOrHash *rpc.BlockNumberOrHash) (hexutil.Uint64, error)

func (*BackendImpl) EthMsgsFromCosmosBlock

func (b *BackendImpl) EthMsgsFromCosmosBlock(resBlock *tmrpctypes.ResultBlock, blockRes *tmrpctypes.ResultBlockResults) []*txs.MsgEthereumTx

func (*BackendImpl) ExtRPCEnabled

func (b *BackendImpl) ExtRPCEnabled() bool

func (*BackendImpl) FeeHistory

func (b *BackendImpl) FeeHistory(blockCount uint64, lastBlock rpc.BlockNumber,
	rewardPercentiles []float64,
) (*rpctypes.FeeHistoryResult, error)

func (*BackendImpl) GasPrice

func (b *BackendImpl) GasPrice(ctx context.Context) (*hexutil.Big, error)

func (*BackendImpl) GetBalance

func (b *BackendImpl) GetBalance(address common.Address, blockNrOrHash rpc.BlockNumberOrHash) (*hexutil.Big, error)

func (*BackendImpl) GetBlockByNumber

func (b *BackendImpl) GetBlockByNumber(blockNum rpc.BlockNumber, fullTx bool) (map[string]interface{}, error)

func (*BackendImpl) GetBody

func (b *BackendImpl) GetBody(ctx context.Context, hash common.Hash,
	number rpc.BlockNumber,
) (*ethtypes.Body, error)

GetBody retrieves the block body.

func (*BackendImpl) GetCode

func (b *BackendImpl) GetCode(address common.Address, blockNrOrHash rpc.BlockNumberOrHash) (hexutil.Bytes, error)

func (*BackendImpl) GetCoinbase

func (b *BackendImpl) GetCoinbase() (sdktypes.AccAddress, error)

func (*BackendImpl) GetLogs

func (b *BackendImpl) GetLogs(
	_ context.Context, blockHash common.Hash, number uint64,
) ([][]*ethtypes.Log, error)

GetLogs returns the logs.

func (*BackendImpl) GetProof

func (b *BackendImpl) GetProof(address common.Address, storageKeys []string, blockNrOrHash rpctypes.BlockNumberOrHash) (*rpctypes.AccountResult, error)

GetProof returns an account object with proof and any storage proofs

func (*BackendImpl) GetReceipts

func (b *BackendImpl) GetReceipts(ctx context.Context, hash common.Hash) (ethtypes.Receipts, error)

GetReceipts get receipts by block hash

func (*BackendImpl) GetResendArgs

func (b *BackendImpl) GetResendArgs(args rpctypes.TransactionArgs, gasPrice *hexutil.Big, gasLimit *hexutil.Uint64) (rpctypes.TransactionArgs, error)

func (*BackendImpl) GetSender

func (b *BackendImpl) GetSender(msg *txs.MsgEthereumTx, chainID *big.Int) (from common.Address, err error)

GetSender extracts the sender address from the signature values using the latest signer for the given chainID.

func (*BackendImpl) GetStorageAt

func (b *BackendImpl) GetStorageAt(address common.Address, key string, blockNrOrHash rpc.BlockNumberOrHash) (hexutil.Bytes, error)

GetStorageAt returns the contract storage at the given address, block number, and key.

func (*BackendImpl) GetTransaction

func (b *BackendImpl) GetTransaction(ctx context.Context, txHash common.Hash) (*rpctypes.RPCTransaction, error)

func (*BackendImpl) GetTransactionCount

func (b *BackendImpl) GetTransactionCount(address common.Address, blockNrOrHash rpc.BlockNumberOrHash) (*hexutil.Uint64, error)

func (*BackendImpl) GetTransactionReceipt

func (b *BackendImpl) GetTransactionReceipt(ctx context.Context, hash common.Hash) (map[string]interface{}, error)

GetTransactionReceipt get receipt by transaction hash

func (*BackendImpl) GetTxByEthHash

func (b *BackendImpl) GetTxByEthHash(hash common.Hash) (*types.TxResult, error)

func (*BackendImpl) GetTxMsg

func (b *BackendImpl) GetTxMsg(ctx context.Context, txHash common.Hash) (*txs.MsgEthereumTx, error)

func (*BackendImpl) GlobalMinGasPrice

func (b *BackendImpl) GlobalMinGasPrice() (sdktypes.Dec, error)

GlobalMinGasPrice returns MinGasPrice param from FeeMarket

func (*BackendImpl) HeaderByHash

func (b *BackendImpl) HeaderByHash(ctx context.Context, hash common.Hash) (*ethtypes.Header, error)

func (*BackendImpl) HeaderByNumber

func (b *BackendImpl) HeaderByNumber(_ context.Context, number rpc.BlockNumber) (*ethtypes.Header, error)

func (*BackendImpl) HeaderByNumberOrHash

func (b *BackendImpl) HeaderByNumberOrHash(ctx context.Context,
	blockNrOrHash rpc.BlockNumberOrHash,
) (*ethtypes.Header, error)

func (*BackendImpl) ImportRawKey

func (b *BackendImpl) ImportRawKey(privkey, password string) (common.Address, error)

func (*BackendImpl) Listening

func (b *BackendImpl) Listening() bool

func (*BackendImpl) NewAccount

func (b *BackendImpl) NewAccount(password string) (common.AddressEIP55, error)

func (*BackendImpl) PeerCount

func (b *BackendImpl) PeerCount() hexutil.Uint

func (*BackendImpl) PendingBlockAndReceipts

func (b *BackendImpl) PendingBlockAndReceipts() (*types.Block, types.Receipts)

func (*BackendImpl) PendingTransactions

func (b *BackendImpl) PendingTransactions() ([]*sdktypes.Tx, error)

func (*BackendImpl) PendingTransactionsCount

func (b *BackendImpl) PendingTransactionsCount() (int, error)

func (*BackendImpl) RPCBlockRangeCap

func (b *BackendImpl) RPCBlockRangeCap() int32

RPCBlockRangeCap defines the max block range allowed for `eth_getLogs` query.

func (*BackendImpl) RPCEVMTimeout

func (b *BackendImpl) RPCEVMTimeout() time.Duration

func (*BackendImpl) RPCFilterCap

func (b *BackendImpl) RPCFilterCap() int32

RPCFilterCap is the limit for total number of filters that can be created

func (*BackendImpl) RPCGasCap

func (b *BackendImpl) RPCGasCap() uint64

func (*BackendImpl) RPCLogsCap

func (b *BackendImpl) RPCLogsCap() int32

RPCLogsCap defines the max number of results can be returned from single `eth_getLogs` query.

func (*BackendImpl) RPCMinGasPrice

func (b *BackendImpl) RPCMinGasPrice() int64

func (*BackendImpl) RPCTxFeeCap

func (b *BackendImpl) RPCTxFeeCap() float64

func (*BackendImpl) SendTx

func (b *BackendImpl) SendTx(ctx context.Context, signedTx *ethtypes.Transaction) error

func (*BackendImpl) ServiceFilter

func (b *BackendImpl) ServiceFilter(_ context.Context, _ *bloombits.MatcherSession)

func (*BackendImpl) Sign

func (b *BackendImpl) Sign(address common.Address, data hexutil.Bytes) (hexutil.Bytes, error)

Sign signs the provided data using the private key of address via Geth's signature standard.

func (*BackendImpl) SignTransaction

func (b *BackendImpl) SignTransaction(args *rpctypes.TransactionArgs) (*ethtypes.Transaction, error)

func (*BackendImpl) SubscribeChainEvent

func (b *BackendImpl) SubscribeChainEvent(ch chan<- core.ChainEvent) event.Subscription

func (*BackendImpl) SubscribeChainHeadEvent

func (b *BackendImpl) SubscribeChainHeadEvent(ch chan<- core.ChainHeadEvent) event.Subscription

func (*BackendImpl) SubscribeChainSideEvent

func (b *BackendImpl) SubscribeChainSideEvent(ch chan<- core.ChainSideEvent) event.Subscription

func (*BackendImpl) SubscribeLogsEvent

func (b *BackendImpl) SubscribeLogsEvent(ch chan<- []*ethtypes.Log) event.Subscription

func (*BackendImpl) SubscribeNewTxsEvent

func (b *BackendImpl) SubscribeNewTxsEvent(ch chan<- core.NewTxsEvent) event.Subscription

func (*BackendImpl) SubscribePendingLogsEvent

func (b *BackendImpl) SubscribePendingLogsEvent(ch chan<- []*ethtypes.Log) event.Subscription

func (*BackendImpl) SubscribeRemovedLogsEvent

func (b *BackendImpl) SubscribeRemovedLogsEvent(ch chan<- core.RemovedLogsEvent) event.Subscription

func (*BackendImpl) SuggestGasTipCap

func (b *BackendImpl) SuggestGasTipCap(baseFee *big.Int) (*big.Int, error)

func (*BackendImpl) SyncProgress

func (b *BackendImpl) SyncProgress() ethereum.SyncProgress

func (*BackendImpl) Syncing

func (b *BackendImpl) Syncing() (interface{}, error)

func (*BackendImpl) TraceBlock

func (b *BackendImpl) TraceBlock(height rpc.BlockNumber,
	config *support.TraceConfig,
	block *tmrpctypes.ResultBlock,
) ([]*evmtxs.TxTraceResult, error)

TraceBlock configures a new tracer according to the provided configuration, and executes all the transactions contained within. The return value will be one item per transaction, dependent on the requested tracer.

func (*BackendImpl) TraceTransaction

func (b *BackendImpl) TraceTransaction(hash common.Hash, config *support.TraceConfig) (interface{}, error)

TraceTransaction returns the structured logs created during the execution of EVM and returns them as a JSON object.

func (*BackendImpl) UnprotectedAllowed

func (b *BackendImpl) UnprotectedAllowed() bool

func (*BackendImpl) Version

func (b *BackendImpl) Version() string

Version returns the current ethereum protocol version.

type Config

type Config struct {
	// AppCfg preserve the server config
	AppCfg *config.Config

	// Gas Price Oracle config.
	GPO *gasprice.Config

	// RPCGasCap is the global gas cap for eth-call variants.
	RPCGasCap uint64 `toml:""`

	// RPCEVMTimeout is the global timeout for eth-call.
	RPCEVMTimeout time.Duration `toml:""`

	// RPCTxFeeCap is the global transaction fee(price * gaslimit) cap for
	// send-transaction variants. The unit is ether.
	RPCTxFeeCap float64 `toml:""`
}

Config represents the configurable parameters for Polaris.

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns the default JSON-RPC config.

func LoadConfigFromFilePath

func LoadConfigFromFilePath(filename string) (*Config, error)

LoadConfigFromFilePath reads in a Polaris config file from the fileystem.

type ErrorMessageJSON

type ErrorMessageJSON struct {
	Code    *big.Int `json:"code"`
	Message string   `json:"message"`
}

type ErrorResponseJSON

type ErrorResponseJSON struct {
	Jsonrpc string            `json:"jsonrpc"`
	Error   *ErrorMessageJSON `json:"error"`
	ID      *big.Int          `json:"id"`
}

type Node

type Node struct {
	*node.Node
}

Node Wrapers Ethereum Node

func (*Node) ExtRPCEnabled

func (n *Node) ExtRPCEnabled() bool

ExtRPCEnabled returns whether or not the external RPC service is enabled.

func (*Node) Start

func (n *Node) Start() error

Start starts the networking stack.

type SubscriptionNotification

type SubscriptionNotification struct {
	Jsonrpc string              `json:"jsonrpc"`
	Method  string              `json:"method"`
	Params  *SubscriptionResult `json:"params"`
}

type SubscriptionResponseJSON

type SubscriptionResponseJSON struct {
	Jsonrpc string      `json:"jsonrpc"`
	Result  interface{} `json:"result"`
	ID      float64     `json:"id"`
}

type SubscriptionResult

type SubscriptionResult struct {
	Subscription rpc.ID      `json:"subscription"`
	Result       interface{} `json:"result"`
}

type WebsocketsServer

type WebsocketsServer interface {
	Start()
}

func NewWebsocketsServer

func NewWebsocketsServer(clientCtx client.Context, tmWSClient *rpcclient.WSClient, cfg *config.Config, logger log.Logger) WebsocketsServer

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL