node

package
v0.11.19 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2024 License: Apache-2.0 Imports: 48 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrConsensusStateNotAvailable is returned because Rollkit doesn't use Tendermint consensus.
	ErrConsensusStateNotAvailable = errors.New("consensus state not available in Rollkit")
)

Functions

This section is empty.

Types

type FullClient

type FullClient struct {
	*cmtypes.EventBus
	// contains filtered or unexported fields
}

FullClient implements tendermint RPC client interface.

This is the type that is used in communication between cosmos-sdk app and Rollkit.

func NewFullClient

func NewFullClient(node *FullNode) *FullClient

NewFullClient returns Client working with given node.

func (*FullClient) ABCIInfo

func (c *FullClient) ABCIInfo(ctx context.Context) (*ctypes.ResultABCIInfo, error)

ABCIInfo returns basic information about application state.

func (*FullClient) ABCIQuery

func (c *FullClient) ABCIQuery(ctx context.Context, path string, data cmbytes.HexBytes) (*ctypes.ResultABCIQuery, error)

ABCIQuery queries for data from application.

func (*FullClient) ABCIQueryWithOptions

func (c *FullClient) ABCIQueryWithOptions(ctx context.Context, path string, data cmbytes.HexBytes, opts rpcclient.ABCIQueryOptions) (*ctypes.ResultABCIQuery, error)

ABCIQueryWithOptions queries for data from application.

func (*FullClient) Block

func (c *FullClient) Block(ctx context.Context, height *int64) (*ctypes.ResultBlock, error)

Block method returns BlockID and block itself for given height.

If height is nil, it returns information about last known block.

func (*FullClient) BlockByHash

func (c *FullClient) BlockByHash(ctx context.Context, hash []byte) (*ctypes.ResultBlock, error)

BlockByHash returns BlockID and block itself for given hash.

func (*FullClient) BlockResults

func (c *FullClient) BlockResults(ctx context.Context, height *int64) (*ctypes.ResultBlockResults, error)

BlockResults returns information about transactions, events and updates of validator set and consensus params.

func (*FullClient) BlockSearch

func (c *FullClient) BlockSearch(ctx context.Context, query string, page, perPage *int, orderBy string) (*ctypes.ResultBlockSearch, error)

BlockSearch defines a method to search for a paginated set of blocks by BeginBlock and EndBlock event search criteria.

func (*FullClient) BlockchainInfo

func (c *FullClient) BlockchainInfo(ctx context.Context, minHeight, maxHeight int64) (*ctypes.ResultBlockchainInfo, error)

BlockchainInfo returns ABCI block meta information for given height range.

func (*FullClient) BroadcastEvidence

func (c *FullClient) BroadcastEvidence(ctx context.Context, evidence cmtypes.Evidence) (*ctypes.ResultBroadcastEvidence, error)

BroadcastEvidence is not yet implemented.

func (*FullClient) BroadcastTxAsync

func (c *FullClient) BroadcastTxAsync(ctx context.Context, tx cmtypes.Tx) (*ctypes.ResultBroadcastTx, error)

BroadcastTxAsync returns right away, with no response. Does not wait for CheckTx nor DeliverTx results. More: https://docs.tendermint.com/master/rpc/#/Tx/broadcast_tx_async

func (*FullClient) BroadcastTxCommit

func (c *FullClient) BroadcastTxCommit(ctx context.Context, tx cmtypes.Tx) (*ctypes.ResultBroadcastTxCommit, error)

BroadcastTxCommit returns with the responses from CheckTx and DeliverTx. More: https://docs.tendermint.com/master/rpc/#/Tx/broadcast_tx_commit

func (*FullClient) BroadcastTxSync

func (c *FullClient) BroadcastTxSync(ctx context.Context, tx cmtypes.Tx) (*ctypes.ResultBroadcastTx, error)

BroadcastTxSync returns with the response from CheckTx. Does not wait for DeliverTx result. More: https://docs.tendermint.com/master/rpc/#/Tx/broadcast_tx_sync

func (*FullClient) CheckTx

func (c *FullClient) CheckTx(ctx context.Context, tx cmtypes.Tx) (*ctypes.ResultCheckTx, error)

CheckTx executes a new transaction against the application to determine its validity.

If valid, the tx is automatically added to the mempool.

func (*FullClient) Commit

func (c *FullClient) Commit(ctx context.Context, height *int64) (*ctypes.ResultCommit, error)

Commit returns signed header (aka commit) at given height.

func (*FullClient) ConsensusParams

func (c *FullClient) ConsensusParams(ctx context.Context, height *int64) (*ctypes.ResultConsensusParams, error)

ConsensusParams returns consensus params at given height.

func (*FullClient) ConsensusState

func (c *FullClient) ConsensusState(ctx context.Context) (*ctypes.ResultConsensusState, error)

ConsensusState always returns error as there is no consensus state in Rollkit.

func (*FullClient) DumpConsensusState

func (c *FullClient) DumpConsensusState(ctx context.Context) (*ctypes.ResultDumpConsensusState, error)

DumpConsensusState always returns error as there is no consensus state in Rollkit.

func (*FullClient) Genesis

func (c *FullClient) Genesis(_ context.Context) (*ctypes.ResultGenesis, error)

Genesis returns entire genesis.

func (*FullClient) GenesisChunked

func (c *FullClient) GenesisChunked(context context.Context, id uint) (*ctypes.ResultGenesisChunk, error)

GenesisChunked returns given chunk of genesis.

func (*FullClient) Header added in v0.10.0

func (c *FullClient) Header(ctx context.Context, height *int64) (*ctypes.ResultHeader, error)

Header returns a cometbft ResultsHeader for the FullClient

func (*FullClient) HeaderByHash added in v0.10.0

func (c *FullClient) HeaderByHash(ctx context.Context, hash cmbytes.HexBytes) (*ctypes.ResultHeader, error)

HeaderByHash loads the block for the provided hash and returns the header

func (*FullClient) Health

func (c *FullClient) Health(ctx context.Context) (*ctypes.ResultHealth, error)

Health endpoint returns empty value. It can be used to monitor service availability.

func (*FullClient) NetInfo

func (c *FullClient) NetInfo(ctx context.Context) (*ctypes.ResultNetInfo, error)

NetInfo returns basic information about client P2P connections.

func (*FullClient) NumUnconfirmedTxs

func (c *FullClient) NumUnconfirmedTxs(ctx context.Context) (*ctypes.ResultUnconfirmedTxs, error)

NumUnconfirmedTxs returns information about transactions in mempool.

func (*FullClient) Status

func (c *FullClient) Status(ctx context.Context) (*ctypes.ResultStatus, error)

Status returns detailed information about current status of the node.

func (*FullClient) Subscribe

func (c *FullClient) Subscribe(ctx context.Context, subscriber, query string, outCapacity ...int) (out <-chan ctypes.ResultEvent, err error)

Subscribe subscribe given subscriber to a query.

func (*FullClient) Tx

func (c *FullClient) Tx(ctx context.Context, hash []byte, prove bool) (*ctypes.ResultTx, error)

Tx returns detailed information about transaction identified by its hash.

func (*FullClient) TxSearch

func (c *FullClient) TxSearch(ctx context.Context, query string, prove bool, pagePtr, perPagePtr *int, orderBy string) (*ctypes.ResultTxSearch, error)

TxSearch returns detailed information about transactions matching query.

func (*FullClient) UnconfirmedTxs

func (c *FullClient) UnconfirmedTxs(ctx context.Context, limitPtr *int) (*ctypes.ResultUnconfirmedTxs, error)

UnconfirmedTxs returns transactions in mempool.

func (*FullClient) Unsubscribe

func (c *FullClient) Unsubscribe(ctx context.Context, subscriber, query string) error

Unsubscribe unsubscribes given subscriber from a query.

func (*FullClient) Validators

func (c *FullClient) Validators(ctx context.Context, heightPtr *int64, pagePtr, perPagePtr *int) (*ctypes.ResultValidators, error)

Validators returns paginated list of validators at given height.

type FullNode

type FullNode struct {
	service.BaseService

	// TODO(tzdybal): consider extracting "mempool reactor"
	Mempool mempool.Mempool

	Store store.Store

	// Preserves cometBFT compatibility
	TxIndexer      txindex.TxIndexer
	BlockIndexer   indexer.BlockIndexer
	IndexerService *txindex.IndexerService
	// contains filtered or unexported fields
}

FullNode represents a client node in Rollkit network. It connects all the components and orchestrates their work.

func (*FullNode) AppClient

func (n *FullNode) AppClient() proxy.AppConns

AppClient returns ABCI proxy connections to communicate with application.

func (*FullNode) Cancel added in v0.10.7

func (n *FullNode) Cancel()

Cancel calls the underlying context's cancel function.

func (*FullNode) EventBus

func (n *FullNode) EventBus() *cmtypes.EventBus

EventBus gives access to Node's event bus.

func (*FullNode) GetClient

func (n *FullNode) GetClient() rpcclient.Client

GetClient returns the RPC client for the full node.

func (*FullNode) GetGenesis

func (n *FullNode) GetGenesis() *cmtypes.GenesisDoc

GetGenesis returns entire genesis doc.

func (*FullNode) GetGenesisChunks

func (n *FullNode) GetGenesisChunks() ([]string, error)

GetGenesisChunks returns chunked version of genesis.

func (*FullNode) GetLogger

func (n *FullNode) GetLogger() log.Logger

GetLogger returns logger.

func (*FullNode) OnReset

func (n *FullNode) OnReset() error

OnReset is a part of Service interface.

func (*FullNode) OnStart

func (n *FullNode) OnStart() error

OnStart is a part of Service interface.

func (*FullNode) OnStop

func (n *FullNode) OnStop()

OnStop is a part of Service interface.

func (*FullNode) SetLogger

func (n *FullNode) SetLogger(logger log.Logger)

SetLogger sets the logger used by node.

type LightClient

type LightClient struct {
	types.EventBus
	// contains filtered or unexported fields
}

LightClient is a Client interface for the LightNode

func NewLightClient

func NewLightClient(node *LightNode) *LightClient

NewLightClient returns a new LightClient for the LightNode

func (*LightClient) ABCIInfo

func (c *LightClient) ABCIInfo(ctx context.Context) (*ctypes.ResultABCIInfo, error)

ABCIInfo returns basic information about application state.

func (*LightClient) ABCIQuery

func (c *LightClient) ABCIQuery(ctx context.Context, path string, data cmbytes.HexBytes) (*ctypes.ResultABCIQuery, error)

ABCIQuery queries for data from application.

func (*LightClient) ABCIQueryWithOptions

func (c *LightClient) ABCIQueryWithOptions(ctx context.Context, path string, data cmbytes.HexBytes, opts rpcclient.ABCIQueryOptions) (*ctypes.ResultABCIQuery, error)

ABCIQueryWithOptions queries for data from application.

func (*LightClient) Block

func (c *LightClient) Block(ctx context.Context, height *int64) (*ctypes.ResultBlock, error)

Block method returns BlockID and block itself for given height.

If height is nil, it returns information about last known block.

func (*LightClient) BlockByHash

func (c *LightClient) BlockByHash(ctx context.Context, hash []byte) (*ctypes.ResultBlock, error)

BlockByHash returns BlockID and block itself for given hash.

func (*LightClient) BlockResults

func (c *LightClient) BlockResults(ctx context.Context, height *int64) (*ctypes.ResultBlockResults, error)

BlockResults returns information about transactions, events and updates of validator set and consensus params.

func (*LightClient) BlockSearch

func (c *LightClient) BlockSearch(ctx context.Context, query string, page, perPage *int, orderBy string) (*ctypes.ResultBlockSearch, error)

BlockSearch defines a method to search for a paginated set of blocks by BeginBlock and EndBlock event search criteria.

func (*LightClient) BlockchainInfo

func (c *LightClient) BlockchainInfo(ctx context.Context, minHeight, maxHeight int64) (*ctypes.ResultBlockchainInfo, error)

BlockchainInfo returns ABCI block meta information for given height range.

func (*LightClient) BroadcastEvidence

func (c *LightClient) BroadcastEvidence(ctx context.Context, evidence types.Evidence) (*ctypes.ResultBroadcastEvidence, error)

BroadcastEvidence is not yet implemented.

func (*LightClient) BroadcastTxAsync

func (c *LightClient) BroadcastTxAsync(ctx context.Context, tx types.Tx) (*ctypes.ResultBroadcastTx, error)

BroadcastTxAsync returns right away, with no response. Does not wait for CheckTx nor DeliverTx results. More: https://docs.tendermint.com/master/rpc/#/Tx/broadcast_tx_async

func (*LightClient) BroadcastTxCommit

func (c *LightClient) BroadcastTxCommit(ctx context.Context, tx types.Tx) (*ctypes.ResultBroadcastTxCommit, error)

BroadcastTxCommit returns with the responses from CheckTx and DeliverTx. More: https://docs.tendermint.com/master/rpc/#/Tx/broadcast_tx_commit

func (*LightClient) BroadcastTxSync

func (c *LightClient) BroadcastTxSync(ctx context.Context, tx types.Tx) (*ctypes.ResultBroadcastTx, error)

BroadcastTxSync returns with the response from CheckTx. Does not wait for DeliverTx result. More: https://docs.tendermint.com/master/rpc/#/Tx/broadcast_tx_sync

func (*LightClient) CheckTx

func (c *LightClient) CheckTx(ctx context.Context, tx types.Tx) (*ctypes.ResultCheckTx, error)

CheckTx executes a new transaction against the application to determine its validity.

If valid, the tx is automatically added to the mempool.

func (*LightClient) Commit

func (c *LightClient) Commit(ctx context.Context, height *int64) (*ctypes.ResultCommit, error)

Commit returns signed header (aka commit) at given height.

func (*LightClient) ConsensusParams

func (c *LightClient) ConsensusParams(ctx context.Context, height *int64) (*ctypes.ResultConsensusParams, error)

ConsensusParams returns consensus params at given height.

Currently, consensus params changes are not supported and this method returns params as defined in genesis.

func (*LightClient) ConsensusState

func (c *LightClient) ConsensusState(ctx context.Context) (*ctypes.ResultConsensusState, error)

ConsensusState always returns error as there is no consensus state in Rollkit.

func (*LightClient) DumpConsensusState

func (c *LightClient) DumpConsensusState(ctx context.Context) (*ctypes.ResultDumpConsensusState, error)

DumpConsensusState always returns error as there is no consensus state in Rollkit.

func (*LightClient) Genesis

Genesis returns entire genesis.

func (*LightClient) GenesisChunked

func (c *LightClient) GenesisChunked(context context.Context, id uint) (*ctypes.ResultGenesisChunk, error)

GenesisChunked returns given chunk of genesis.

func (*LightClient) Header added in v0.10.0

func (c *LightClient) Header(ctx context.Context, height *int64) (*ctypes.ResultHeader, error)

Header satisfies the client interface but is not implemented

func (*LightClient) HeaderByHash added in v0.10.0

func (c *LightClient) HeaderByHash(ctx context.Context, hash cmbytes.HexBytes) (*ctypes.ResultHeader, error)

HeaderByHash satisfies the client interface but is not implemented

func (*LightClient) Health

func (c *LightClient) Health(ctx context.Context) (*ctypes.ResultHealth, error)

Health endpoint returns empty value. It can be used to monitor service availability.

func (*LightClient) NetInfo

func (c *LightClient) NetInfo(ctx context.Context) (*ctypes.ResultNetInfo, error)

NetInfo returns basic information about client P2P connections.

func (*LightClient) NumUnconfirmedTxs

func (c *LightClient) NumUnconfirmedTxs(ctx context.Context) (*ctypes.ResultUnconfirmedTxs, error)

NumUnconfirmedTxs returns information about transactions in mempool.

func (*LightClient) Status

func (c *LightClient) Status(ctx context.Context) (*ctypes.ResultStatus, error)

Status returns detailed information about current status of the node.

func (*LightClient) Subscribe

func (c *LightClient) Subscribe(ctx context.Context, subscriber, query string, outCapacity ...int) (out <-chan ctypes.ResultEvent, err error)

Subscribe subscribe given subscriber to a query.

func (*LightClient) Tx

func (c *LightClient) Tx(ctx context.Context, hash []byte, prove bool) (*ctypes.ResultTx, error)

Tx returns detailed information about transaction identified by its hash.

func (*LightClient) TxSearch

func (c *LightClient) TxSearch(ctx context.Context, query string, prove bool, pagePtr, perPagePtr *int, orderBy string) (*ctypes.ResultTxSearch, error)

TxSearch returns detailed information about transactions matching query.

func (*LightClient) UnconfirmedTxs

func (c *LightClient) UnconfirmedTxs(ctx context.Context, limitPtr *int) (*ctypes.ResultUnconfirmedTxs, error)

UnconfirmedTxs returns transactions in mempool.

func (*LightClient) Unsubscribe

func (c *LightClient) Unsubscribe(ctx context.Context, subscriber, query string) error

Unsubscribe unsubscribes given subscriber from a query.

func (*LightClient) Validators

func (c *LightClient) Validators(ctx context.Context, heightPtr *int64, pagePtr, perPagePtr *int) (*ctypes.ResultValidators, error)

Validators returns paginated list of validators at given height.

type LightNode

type LightNode struct {
	service.BaseService

	P2P *p2p.Client
	// contains filtered or unexported fields
}

LightNode is a rollup node that only needs the header service

func (*LightNode) Cancel added in v0.10.7

func (n *LightNode) Cancel()

Cancel calls the underlying context's cancel function.

func (*LightNode) GetClient

func (ln *LightNode) GetClient() rpcclient.Client

GetClient returns a new rpcclient for the light node

func (*LightNode) OnStart added in v0.7.0

func (ln *LightNode) OnStart() error

OnStart starts the P2P and HeaderSync services

func (*LightNode) OnStop added in v0.7.0

func (ln *LightNode) OnStop()

OnStop stops the light node

type MetricsProvider added in v0.11.19

type MetricsProvider func(chainID string) (*block.Metrics, *p2p.Metrics, *mempool.Metrics, *state.Metrics, *proxy.Metrics)

MetricsProvider returns a consensus, p2p and mempool Metrics.

func DefaultMetricsProvider added in v0.11.19

func DefaultMetricsProvider(config *cmcfg.InstrumentationConfig) MetricsProvider

DefaultMetricsProvider returns Metrics build using Prometheus client library if Prometheus is enabled. Otherwise, it returns no-op Metrics.

type MockTester added in v0.9.0

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

MockTester is a mock testing.T

func (MockTester) Errorf added in v0.9.0

func (m MockTester) Errorf(format string, args ...interface{})

Errorf is used to log an error to the test logger

func (MockTester) Fail added in v0.9.0

func (m MockTester) Fail()

Fail is used to fail the test

func (MockTester) FailNow added in v0.9.0

func (m MockTester) FailNow()

FailNow is used to fail the test immediately

func (MockTester) Logf added in v0.9.0

func (m MockTester) Logf(format string, args ...interface{})

Logf is used to log a message to the test logger

type Node

type Node interface {
	Start() error
	GetClient() rpcclient.Client
	Stop() error
	IsRunning() bool
	Cancel()
}

Node is the interface for a rollup node

func NewNode

func NewNode(
	ctx context.Context,
	conf config.NodeConfig,
	p2pKey crypto.PrivKey,
	signingKey crypto.PrivKey,
	appClient proxy.ClientCreator,
	genesis *cmtypes.GenesisDoc,
	metricsProvider MetricsProvider,
	logger log.Logger,
) (Node, error)

NewNode returns a new Full or Light Node based on the config

type Source added in v0.10.2

type Source int

Source is an enum representing different sources of height

const (
	// Header is the source of height from the header service
	Header Source = iota
	// Block is the source of height from the block service
	Block
	// Store is the source of height from the block manager store
	Store
)

Jump to

Keyboard shortcuts

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