Documentation
¶
Overview ¶
Package core defines the CometBFT RPC endpoints.
CometBFT ships with its own JSONRPC library - https://github.com/cometbft/cometbft/tree/v0.34.x/rpc/jsonrpc.
## Get the list
An HTTP Get request to the root RPC endpoint shows a list of available endpoints.
```bash curl 'localhost:26657' ```
> Response:
```plain Available endpoints: /abci_info /dump_consensus_state /genesis /net_info /num_unconfirmed_txs /status /health /unconfirmed_txs /unsafe_flush_mempool /validators
Endpoints that require arguments: /abci_query?path=_&data=_&prove=_ /block?height=_ /blockchain?minHeight=_&maxHeight=_ /broadcast_tx_async?tx=_ /broadcast_tx_commit?tx=_ /broadcast_tx_sync?tx=_ /commit?height=_ /dial_seeds?seeds=_ /dial_persistent_peers?persistent_peers=_ /subscribe?event=_ /tx?hash=_&prove=_ /unsubscribe?event=_ ```
Index ¶
- Constants
- Variables
- func ABCIInfo(ctx *rpctypes.Context) (*ctypes.ResultABCIInfo, error)
- func ABCIQuery(ctx *rpctypes.Context, path string, data bytes.HexBytes, height int64, ...) (*ctypes.ResultABCIQuery, error)
- func AddUnsafeRoutes()
- func Block(ctx *rpctypes.Context, heightPtr *int64) (*ctypes.ResultBlock, error)
- func BlockByHash(ctx *rpctypes.Context, hash []byte) (*ctypes.ResultBlock, error)
- func BlockResults(ctx *rpctypes.Context, heightPtr *int64) (*ctypes.ResultBlockResults, error)
- func BlockSearch(ctx *rpctypes.Context, query string, pagePtr, perPagePtr *int, orderBy string) (*ctypes.ResultBlockSearch, error)
- func BlockSearchMatchEvents(ctx *rpctypes.Context, query string, pagePtr, perPagePtr *int, orderBy string, ...) (*ctypes.ResultBlockSearch, error)
- func BlockchainInfo(ctx *rpctypes.Context, minHeight, maxHeight int64) (*ctypes.ResultBlockchainInfo, error)
- func BroadcastEvidence(ctx *rpctypes.Context, ev types.Evidence) (*ctypes.ResultBroadcastEvidence, error)
- func BroadcastTxAsync(ctx *rpctypes.Context, tx types.Tx) (*ctypes.ResultBroadcastTx, error)
- func BroadcastTxCommit(ctx *rpctypes.Context, tx types.Tx) (*ctypes.ResultBroadcastTxCommit, error)
- func BroadcastTxSync(ctx *rpctypes.Context, tx types.Tx) (*ctypes.ResultBroadcastTx, error)
- func CheckTx(ctx *rpctypes.Context, tx types.Tx) (*ctypes.ResultCheckTx, error)
- func Commit(ctx *rpctypes.Context, heightPtr *int64) (*ctypes.ResultCommit, error)
- func ConsensusParams(ctx *rpctypes.Context, heightPtr *int64) (*ctypes.ResultConsensusParams, error)
- func ConsensusState(ctx *rpctypes.Context) (*ctypes.ResultConsensusState, error)
- func DataCommitment(ctx *rpctypes.Context, start, end uint64) (*ctypes.ResultDataCommitment, error)
- func DataRootInclusionProof(ctx *rpctypes.Context, height int64, start, end uint64) (*ctypes.ResultDataRootInclusionProof, error)
- func DumpConsensusState(ctx *rpctypes.Context) (*ctypes.ResultDumpConsensusState, error)
- func EncodeDataRootTuple(height uint64, dataRoot [32]byte) ([]byte, error)
- func Genesis(ctx *rpctypes.Context) (*ctypes.ResultGenesis, error)
- func GenesisChunked(ctx *rpctypes.Context, chunk uint) (*ctypes.ResultGenesisChunk, error)
- func Header(ctx *rpctypes.Context, heightPtr *int64) (*ctypes.ResultHeader, error)
- func HeaderByHash(ctx *rpctypes.Context, hash bytes.HexBytes) (*ctypes.ResultHeader, error)
- func Health(ctx *rpctypes.Context) (*ctypes.ResultHealth, error)
- func InitGenesisChunks() error
- func NetInfo(ctx *rpctypes.Context) (*ctypes.ResultNetInfo, error)
- func NumUnconfirmedTxs(ctx *rpctypes.Context) (*ctypes.ResultUnconfirmedTxs, error)
- func ProveShares(_ *rpctypes.Context, height int64, startShare uint64, endShare uint64) (types.ShareProof, error)
- func SetEnvironment(e *Environment)
- func SignedBlock(ctx *rpctypes.Context, heightPtr *int64) (*ctypes.ResultSignedBlock, error)
- func Status(ctx *rpctypes.Context) (*ctypes.ResultStatus, error)
- func Subscribe(ctx *rpctypes.Context, query string) (*ctypes.ResultSubscribe, error)
- func To32PaddedHexBytes(number uint64) ([]byte, error)
- func Tx(ctx *rpctypes.Context, hash []byte, prove bool) (*ctypes.ResultTx, error)
- func TxSearch(ctx *rpctypes.Context, query string, prove bool, pagePtr, perPagePtr *int, ...) (*ctypes.ResultTxSearch, error)
- func TxSearchMatchEvents(ctx *rpctypes.Context, query string, prove bool, pagePtr, perPagePtr *int, ...) (*ctypes.ResultTxSearch, error)
- func UnconfirmedTxs(ctx *rpctypes.Context, limitPtr *int) (*ctypes.ResultUnconfirmedTxs, error)
- func UnsafeDialPeers(ctx *rpctypes.Context, peers []string, persistent, unconditional, private bool) (*ctypes.ResultDialPeers, error)
- func UnsafeDialSeeds(ctx *rpctypes.Context, seeds []string) (*ctypes.ResultDialSeeds, error)
- func UnsafeFlushMempool(ctx *rpctypes.Context) (*ctypes.ResultUnsafeFlushMempool, error)
- func Unsubscribe(ctx *rpctypes.Context, query string) (*ctypes.ResultUnsubscribe, error)
- func UnsubscribeAll(ctx *rpctypes.Context) (*ctypes.ResultUnsubscribe, error)
- func Validators(ctx *rpctypes.Context, heightPtr *int64, pagePtr, perPagePtr *int) (*ctypes.ResultValidators, error)
- type Consensus
- type DataRootTuple
- type Environment
Constants ¶
const ( // SubscribeTimeout is the maximum time we wait to subscribe for an event. // must be less than the server's write timeout (see rpcserver.DefaultConfig) SubscribeTimeout = 5 * time.Second )
Variables ¶
var Routes = map[string]*rpc.RPCFunc{ "subscribe": rpc.NewWSRPCFunc(Subscribe, "query"), "unsubscribe": rpc.NewWSRPCFunc(Unsubscribe, "query"), "unsubscribe_all": rpc.NewWSRPCFunc(UnsubscribeAll, ""), "health": rpc.NewRPCFunc(Health, ""), "status": rpc.NewRPCFunc(Status, ""), "net_info": rpc.NewRPCFunc(NetInfo, ""), "blockchain": rpc.NewRPCFunc(BlockchainInfo, "minHeight,maxHeight", rpc.Cacheable()), "genesis": rpc.NewRPCFunc(Genesis, "", rpc.Cacheable()), "genesis_chunked": rpc.NewRPCFunc(GenesisChunked, "chunk", rpc.Cacheable()), "block": rpc.NewRPCFunc(Block, "height", rpc.Cacheable("height")), "signed_block": rpc.NewRPCFunc(SignedBlock, "height", rpc.Cacheable("height")), "block_by_hash": rpc.NewRPCFunc(BlockByHash, "hash", rpc.Cacheable()), "block_results": rpc.NewRPCFunc(BlockResults, "height", rpc.Cacheable("height")), "commit": rpc.NewRPCFunc(Commit, "height", rpc.Cacheable("height")), "header": rpc.NewRPCFunc(Header, "height", rpc.Cacheable("height")), "header_by_hash": rpc.NewRPCFunc(HeaderByHash, "hash"), "data_commitment": rpc.NewRPCFunc(DataCommitment, "start,end"), "check_tx": rpc.NewRPCFunc(CheckTx, "tx"), "tx": rpc.NewRPCFunc(Tx, "hash,prove", rpc.Cacheable()), "prove_shares": rpc.NewRPCFunc(ProveShares, "height,startShare,endShare"), "data_root_inclusion_proof": rpc.NewRPCFunc(DataRootInclusionProof, "height,start,end"), "tx_search": rpc.NewRPCFunc(TxSearchMatchEvents, "query,prove,page,per_page,order_by,match_events"), "block_search": rpc.NewRPCFunc(BlockSearchMatchEvents, "query,page,per_page,order_by,match_events"), "validators": rpc.NewRPCFunc(Validators, "height,page,per_page", rpc.Cacheable("height")), "dump_consensus_state": rpc.NewRPCFunc(DumpConsensusState, ""), "consensus_state": rpc.NewRPCFunc(ConsensusState, ""), "consensus_params": rpc.NewRPCFunc(ConsensusParams, "height", rpc.Cacheable("height")), "unconfirmed_txs": rpc.NewRPCFunc(UnconfirmedTxs, "limit"), "num_unconfirmed_txs": rpc.NewRPCFunc(NumUnconfirmedTxs, ""), "broadcast_tx_commit": rpc.NewRPCFunc(BroadcastTxCommit, "tx"), "broadcast_tx_sync": rpc.NewRPCFunc(BroadcastTxSync, "tx"), "broadcast_tx_async": rpc.NewRPCFunc(BroadcastTxAsync, "tx"), "abci_query": rpc.NewRPCFunc(ABCIQuery, "path,data,height,prove"), "abci_info": rpc.NewRPCFunc(ABCIInfo, "", rpc.Cacheable()), "broadcast_evidence": rpc.NewRPCFunc(BroadcastEvidence, "evidence"), }
Routes is a map of available routes.
Functions ¶
func ABCIInfo ¶
func ABCIInfo(ctx *rpctypes.Context) (*ctypes.ResultABCIInfo, error)
ABCIInfo gets some info about the application. More: https://docs.cometbft.com/v0.34/rpc/#/ABCI/abci_info
func ABCIQuery ¶
func ABCIQuery( ctx *rpctypes.Context, path string, data bytes.HexBytes, height int64, prove bool, ) (*ctypes.ResultABCIQuery, error)
ABCIQuery queries the application for some information. More: https://docs.cometbft.com/v0.34/rpc/#/ABCI/abci_query
func Block ¶
Block gets block at a given height. If no height is provided, it will fetch the latest block. More: https://docs.cometbft.com/v0.34/rpc/#/Info/block
func BlockByHash ¶
BlockByHash gets block by hash. More: https://docs.cometbft.com/v0.34/rpc/#/Info/block_by_hash
func BlockResults ¶
BlockResults gets ABCIResults at a given height. If no height is provided, it will fetch results for the latest block. When DiscardABCIResponses is enabled, an error will be returned.
Results are for the height of the block containing the txs. Thus response.results.deliver_tx[5] is the results of executing getBlock(h).Txs[5] More: https://docs.cometbft.com/v0.34/rpc/#/Info/block_results
func BlockSearch ¶
func BlockSearch( ctx *rpctypes.Context, query string, pagePtr, perPagePtr *int, orderBy string, ) (*ctypes.ResultBlockSearch, error)
BlockSearch searches for a paginated set of blocks matching BeginBlock and EndBlock event search criteria.
func BlockSearchMatchEvents ¶
func BlockchainInfo ¶
func BlockchainInfo(ctx *rpctypes.Context, minHeight, maxHeight int64) (*ctypes.ResultBlockchainInfo, error)
BlockchainInfo gets block headers for minHeight <= height <= maxHeight.
If maxHeight does not yet exist, blocks up to the current height will be returned. If minHeight does not exist (due to pruning), earliest existing height will be used.
At most 20 items will be returned. Block headers are returned in descending order (highest first).
func BroadcastEvidence ¶
func BroadcastEvidence(ctx *rpctypes.Context, ev types.Evidence) (*ctypes.ResultBroadcastEvidence, error)
BroadcastEvidence broadcasts evidence of the misbehavior. More: https://docs.cometbft.com/v0.34/rpc/#/Info/broadcast_evidence
func BroadcastTxAsync ¶
BroadcastTxAsync returns right away, with no response. Does not wait for CheckTx nor DeliverTx results. More: https://docs.cometbft.com/v0.34/rpc/#/Tx/broadcast_tx_async
func BroadcastTxCommit ¶
BroadcastTxCommit returns with the responses from CheckTx and DeliverTx. More: https://docs.cometbft.com/v0.34/rpc/#/Tx/broadcast_tx_commit
func BroadcastTxSync ¶
BroadcastTxSync returns with the response from CheckTx. Does not wait for DeliverTx result. More: https://docs.cometbft.com/v0.34/rpc/#/Tx/broadcast_tx_sync
func CheckTx ¶
CheckTx checks the transaction without executing it. The transaction won't be added to the mempool either. More: https://docs.cometbft.com/v0.34/rpc/#/Tx/check_tx
func Commit ¶
Commit gets block commit at a given height. If no height is provided, it will fetch the commit for the latest block. More: https://docs.cometbft.com/v0.34/rpc/#/Info/commit
func ConsensusParams ¶
func ConsensusParams(ctx *rpctypes.Context, heightPtr *int64) (*ctypes.ResultConsensusParams, error)
ConsensusParams gets the consensus parameters at the given block height. If no height is provided, it will fetch the latest consensus params. More: https://docs.cometbft.com/v0.34/rpc/#/Info/consensus_params
func ConsensusState ¶
func ConsensusState(ctx *rpctypes.Context) (*ctypes.ResultConsensusState, error)
ConsensusState returns a concise summary of the consensus state. UNSTABLE More: https://docs.cometbft.com/v0.34/rpc/#/Info/consensus_state
func DataCommitment ¶
DataCommitment collects the data roots over a provided ordered range of blocks, and then creates a new Merkle root of those data roots. The range is end exclusive.
func DataRootInclusionProof ¶
func DataRootInclusionProof( ctx *rpctypes.Context, height int64, start, end uint64, ) (*ctypes.ResultDataRootInclusionProof, error)
DataRootInclusionProof creates an inclusion proof for the data root of block height `height` in the set of blocks defined by `start` and `end`. The range is end exclusive.
func DumpConsensusState ¶
func DumpConsensusState(ctx *rpctypes.Context) (*ctypes.ResultDumpConsensusState, error)
DumpConsensusState dumps consensus state. UNSTABLE More: https://docs.cometbft.com/v0.34/rpc/#/Info/dump_consensus_state
func EncodeDataRootTuple ¶
EncodeDataRootTuple takes a height and a data root, and returns the equivalent of `abi.encode(...)` in Ethereum. The encoded type is a DataRootTuple, which has the following ABI:
{ "components":[ { "internalType":"uint256", "name":"height", "type":"uint256" }, { "internalType":"bytes32", "name":"dataRoot", "type":"bytes32" }, { "internalType":"structDataRootTuple", "name":"_tuple", "type":"tuple" } ] }
padding the hex representation of the height padded to 32 bytes concatenated to the data root. For more information, refer to: https://github.com/celestiaorg/quantum-gravity-bridge/blob/master/src/DataRootTuple.sol
func Genesis ¶
func Genesis(ctx *rpctypes.Context) (*ctypes.ResultGenesis, error)
Genesis returns genesis file. More: https://docs.cometbft.com/v0.34/rpc/#/Info/genesis
func GenesisChunked ¶
func Header ¶
Header gets block header at a given height. If no height is provided, it will fetch the latest header. More: https://docs.tendermint.com/master/rpc/#/Info/header
func HeaderByHash ¶
HeaderByHash gets header by hash. More: https://docs.tendermint.com/master/rpc/#/Info/header_by_hash
func Health ¶
func Health(ctx *rpctypes.Context) (*ctypes.ResultHealth, error)
Health gets node health. Returns empty result (200 OK) on success, no response - in case of an error. More: https://docs.cometbft.com/v0.34/rpc/#/Info/health
func InitGenesisChunks ¶
func InitGenesisChunks() error
InitGenesisChunks configures the environment and should be called on service startup.
func NetInfo ¶
func NetInfo(ctx *rpctypes.Context) (*ctypes.ResultNetInfo, error)
NetInfo returns network info. More: https://docs.cometbft.com/v0.34/rpc/#/Info/net_info
func NumUnconfirmedTxs ¶
func NumUnconfirmedTxs(ctx *rpctypes.Context) (*ctypes.ResultUnconfirmedTxs, error)
NumUnconfirmedTxs gets number of unconfirmed transactions. More: https://docs.cometbft.com/v0.34/rpc/#/Info/num_unconfirmed_txs
func ProveShares ¶
func ProveShares( _ *rpctypes.Context, height int64, startShare uint64, endShare uint64, ) (types.ShareProof, error)
ProveShares creates an NMT proof for a set of shares to a set of rows. It is end exclusive.
func SetEnvironment ¶
func SetEnvironment(e *Environment)
SetEnvironment sets the global environment to e. The globalEnv var that this function modifies is protected by a sync.Once so multiple calls within the same process will not be effective.
func SignedBlock ¶
SignedBlock fetches the set of transactions at a specified height and all the relevant data to verify the transactions (i.e. using light client verification).
func Status ¶
func Status(ctx *rpctypes.Context) (*ctypes.ResultStatus, error)
Status returns CometBFT status including node info, pubkey, latest block hash, app hash, block height and time. More: https://docs.cometbft.com/v0.34/rpc/#/Info/status
func Subscribe ¶
Subscribe for events via WebSocket. More: https://docs.cometbft.com/v0.34/rpc/#/Websocket/subscribe
func To32PaddedHexBytes ¶
To32PaddedHexBytes takes a number and returns its hex representation padded to 32 bytes. Used to mimic the result of `abi.encode(number)` in Ethereum.
func Tx ¶
Tx allows you to query the transaction results. `nil` could mean the transaction is in the mempool, invalidated, or was not sent in the first place. More: https://docs.cometbft.com/v0.34/rpc/#/Info/tx
func TxSearch ¶
func TxSearch( ctx *rpctypes.Context, query string, prove bool, pagePtr, perPagePtr *int, orderBy string, ) (*ctypes.ResultTxSearch, error)
TxSearch allows you to query for multiple transactions results. It returns a list of transactions (maximum ?per_page entries) and the total count. More: https://docs.cometbft.com/v0.34/rpc/#/Info/tx_search
func TxSearchMatchEvents ¶
func TxSearchMatchEvents( ctx *rpctypes.Context, query string, prove bool, pagePtr, perPagePtr *int, orderBy string, matchEvents bool, ) (*ctypes.ResultTxSearch, error)
TxSearchMatchEvents allows you to query for multiple transactions results and match the query attributes to a common event. It returns a list of transactions (maximum ?per_page entries) and the total count. More: https://docs.cometbft.com/v0.34/rpc/#/Info/tx_search
func UnconfirmedTxs ¶
UnconfirmedTxs gets unconfirmed transactions (maximum ?limit entries) including their number. More: https://docs.cometbft.com/v0.34/rpc/#/Info/unconfirmed_txs
func UnsafeDialPeers ¶
func UnsafeDialPeers(ctx *rpctypes.Context, peers []string, persistent, unconditional, private bool) ( *ctypes.ResultDialPeers, error)
UnsafeDialPeers dials the given peers (comma-separated id@IP:PORT), optionally making them persistent.
func UnsafeDialSeeds ¶
UnsafeDialSeeds dials the given seeds (comma-separated id@IP:PORT).
func UnsafeFlushMempool ¶
func UnsafeFlushMempool(ctx *rpctypes.Context) (*ctypes.ResultUnsafeFlushMempool, error)
UnsafeFlushMempool removes all transactions from the mempool.
func Unsubscribe ¶
Unsubscribe from events via WebSocket. More: https://docs.cometbft.com/v0.34/rpc/#/Websocket/unsubscribe
func UnsubscribeAll ¶
func UnsubscribeAll(ctx *rpctypes.Context) (*ctypes.ResultUnsubscribe, error)
UnsubscribeAll from all events via WebSocket. More: https://docs.cometbft.com/v0.34/rpc/#/Websocket/unsubscribe_all
func Validators ¶
func Validators(ctx *rpctypes.Context, heightPtr *int64, pagePtr, perPagePtr *int) (*ctypes.ResultValidators, error)
Validators gets the validator set at the given block height.
If no height is provided, it will fetch the latest validator set. Note the validators are sorted by their voting power - this is the canonical order for the validators in the set as used in computing their Merkle root.
Types ¶
type DataRootTuple ¶
type DataRootTuple struct {
// contains filtered or unexported fields
}
DataRootTuple contains the data that will be used to create the QGB commitments. The commitments will be signed by orchestrators and submitted to an EVM chain via a relayer. For more information: https://github.com/celestiaorg/quantum-gravity-bridge/blob/master/src/DataRootTuple.sol
type Environment ¶
type Environment struct { // external, thread safe interfaces ProxyAppQuery proxy.AppConnQuery ProxyAppMempool proxy.AppConnMempool // interfaces defined in types and above StateStore sm.Store BlockStore sm.BlockStore EvidencePool sm.EvidencePool ConsensusState Consensus P2PPeers peers P2PTransport transport // objects PubKey crypto.PubKey GenDoc *types.GenesisDoc // cache the genesis structure TxIndexer txindex.TxIndexer BlockIndexer indexer.BlockIndexer ConsensusReactor *consensus.Reactor EventBus *types.EventBus // thread safe Mempool mempl.Mempool Logger log.Logger Config cfg.RPCConfig // contains filtered or unexported fields }
---------------------------------------------- Environment contains objects and interfaces used by the RPC. It is expected to be setup once during startup.
func GetEnvironment ¶
func GetEnvironment() *Environment