rpc

package
v0.43.0-dev-malleabili... Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2025 License: AGPL-3.0 Imports: 41 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HandleRPCSubscription added in v0.40.0

func HandleRPCSubscription[T any](sub subscription.Subscription, handleResponse func(resp T) error) error

HandleRPCSubscription is a generic handler for subscriptions to a specific type for rpc calls.

Parameters: - sub: The subscription. - handleResponse: The function responsible for handling the response of the subscribed type.

Expected errors during normal operation:

  • codes.Internal: If the subscription encounters an error or gets an unexpected response.

func WithBlockSignerDecoder added in v0.40.0

func WithBlockSignerDecoder(signerIndicesDecoder hotstuff.BlockSignerDecoder) func(*Handler)

WithBlockSignerDecoder configures the Handler to decode signer indices via the provided hotstuff.BlockSignerDecoder

func WithIndexReporter added in v0.40.0

func WithIndexReporter(indexReporter state_synchronization.IndexReporter) func(*Handler)

WithIndexReporter configures the Handler to work with index reporter

Types

type Config

type Config struct {
	UnsecureGRPCListenAddr string                           // the non-secure GRPC server address as ip:port
	SecureGRPCListenAddr   string                           // the secure GRPC server address as ip:port
	TransportCredentials   credentials.TransportCredentials // the secure GRPC credentials
	HTTPListenAddr         string                           // the HTTP web proxy address as ip:port
	CollectionAddr         string                           // the address of the upstream collection node
	HistoricalAccessAddrs  string                           // the list of all access nodes from previous spork

	BackendConfig             backend.Config // configurable options for creating Backend
	RestConfig                rest.Config    // the REST server configuration
	MaxMsgSize                uint           // GRPC max message size
	CompressorName            string         // GRPC compressor name
	WebSocketConfig           websockets.Config
	EnableWebSocketsStreamAPI bool
}

Config defines the configurable options for the access node server A secure GRPC server here implies a server that presents a self-signed TLS certificate and a client that authenticates the server via a pre-shared public key

type Engine

type Engine struct {
	component.Component
	// contains filtered or unexported fields
}

Engine exposes the server with a simplified version of the Access API. An unsecured GRPC server (default port 9000), a secure GRPC server (default port 9001) and an HTTP Web proxy (default port 8000) are brought up.

func (*Engine) OnFinalizedBlock added in v0.31.0

func (e *Engine) OnFinalizedBlock(block *model.Block)

OnFinalizedBlock responds to block finalization events.

func (*Engine) RestApiAddress added in v0.23.2

func (e *Engine) RestApiAddress() net.Addr

RestApiAddress returns the listen address of the REST API server. Guaranteed to be non-nil after Engine.Ready is closed.

type HTTPHeader

type HTTPHeader struct {
	Key   string
	Value string
}

type Handler added in v0.40.0

type Handler struct {
	subscription.StreamingData
	// contains filtered or unexported fields
}

func NewHandler added in v0.40.0

func NewHandler(
	api access.API,
	chain flow.Chain,
	finalizedHeader module.FinalizedHeaderCache,
	me module.Local,
	maxStreams uint32,
	options ...HandlerOption,
) *Handler

func (*Handler) ExecuteScriptAtBlockHeight added in v0.40.0

ExecuteScriptAtBlockHeight executes a script at a specific block height.

func (*Handler) ExecuteScriptAtBlockID added in v0.40.0

ExecuteScriptAtBlockID executes a script at a specific block ID.

func (*Handler) ExecuteScriptAtLatestBlock added in v0.40.0

ExecuteScriptAtLatestBlock executes a script at a the latest block.

func (*Handler) GetAccount added in v0.40.0

GetAccount returns an account by address at the latest sealed block.

func (*Handler) GetAccountAtBlockHeight added in v0.40.0

GetAccountAtBlockHeight returns an account by address at the given block height.

func (*Handler) GetAccountAtLatestBlock added in v0.40.0

GetAccountAtLatestBlock returns an account by address at the latest sealed block.

func (*Handler) GetAccountBalanceAtBlockHeight added in v0.40.0

func (*Handler) GetAccountBalanceAtLatestBlock added in v0.40.0

GetAccountBalanceAtLatestBlock returns an account balance by address at the latest sealed block.

Expected errors during normal operation: - codes.InvalidArgument - if invalid account address provided. - codes.Internal - if failed to get account from the execution node or failed to convert account message.

func (*Handler) GetAccountKeyAtBlockHeight added in v0.40.0

GetAccountKeyAtBlockHeight returns an account public keys by address and key index at the given block height. GetAccountKeyAtLatestBlock returns an account public key by address and key index at the latest sealed block.

Expected errors during normal operation: - codes.InvalidArgument - if invalid account address provided. - codes.Internal - if failed to get account from the execution node, ailed to convert account message or failed to encode account key.

func (*Handler) GetAccountKeyAtLatestBlock added in v0.40.0

GetAccountKeyAtLatestBlock returns an account public key by address and key index at the latest sealed block.

Expected errors during normal operation: - codes.InvalidArgument - if invalid account address provided. - codes.Internal - if failed to get account from the execution node, ailed to convert account message or failed to encode account key.

func (*Handler) GetAccountKeysAtBlockHeight added in v0.40.0

GetAccountKeysAtBlockHeight returns an account public keys by address at the given block height. GetAccountKeyAtLatestBlock returns an account public key by address and key index at the latest sealed block.

Expected errors during normal operation: - codes.InvalidArgument - if invalid account address provided. - codes.Internal - if failed to get account from the execution node, ailed to convert account message or failed to encode account key.

func (*Handler) GetAccountKeysAtLatestBlock added in v0.40.0

GetAccountKeysAtLatestBlock returns an account public keys by address at the latest sealed block. GetAccountKeyAtLatestBlock returns an account public key by address and key index at the latest sealed block.

Expected errors during normal operation: - codes.InvalidArgument - if invalid account address provided. - codes.Internal - if failed to get account from the execution node, ailed to convert account message or failed to encode account key.

func (*Handler) GetBlockByHeight added in v0.40.0

GetBlockByHeight gets a block by height.

func (*Handler) GetBlockByID added in v0.40.0

GetBlockByID gets a block by ID.

func (*Handler) GetBlockHeaderByHeight added in v0.40.0

GetBlockHeaderByHeight gets a block header by height.

func (*Handler) GetBlockHeaderByID added in v0.40.0

GetBlockHeaderByID gets a block header by ID.

func (*Handler) GetCollectionByID added in v0.40.0

GetCollectionByID gets a collection by ID.

func (*Handler) GetEventsForBlockIDs added in v0.40.0

GetEventsForBlockIDs returns events matching a set of block IDs.

func (*Handler) GetEventsForHeightRange added in v0.40.0

GetEventsForHeightRange returns events matching a query.

func (*Handler) GetExecutionResultByID added in v0.40.0

GetExecutionResultByID returns the execution result for the given ID.

func (*Handler) GetExecutionResultForBlockID added in v0.40.0

GetExecutionResultForBlockID returns the latest received execution result for the given block ID. AN might receive multiple receipts with conflicting results for unsealed blocks. If this case happens, since AN is not able to determine which result is the correct one until the block is sealed, it has to pick one result to respond to this query. For now, we return the result from the latest received receipt.

func (*Handler) GetFullCollectionByID added in v0.40.0

func (*Handler) GetLatestBlock added in v0.40.0

GetLatestBlock gets the latest sealed block.

func (*Handler) GetLatestBlockHeader added in v0.40.0

GetLatestBlockHeader gets the latest sealed block header.

func (*Handler) GetLatestProtocolStateSnapshot added in v0.40.0

GetLatestProtocolStateSnapshot returns the latest serializable Snapshot

func (*Handler) GetNetworkParameters added in v0.40.0

func (*Handler) GetNodeVersionInfo added in v0.40.0

GetNodeVersionInfo gets node version information such as semver, commit, sporkID, protocolVersion, etc

func (*Handler) GetProtocolStateSnapshotByBlockID added in v0.40.0

GetProtocolStateSnapshotByBlockID returns serializable Snapshot by blockID

func (*Handler) GetProtocolStateSnapshotByHeight added in v0.40.0

GetProtocolStateSnapshotByHeight returns serializable Snapshot by block height

func (*Handler) GetSystemTransaction added in v0.40.0

func (*Handler) GetSystemTransactionResult added in v0.40.0

func (*Handler) GetTransaction added in v0.40.0

GetTransaction gets a transaction by ID.

func (*Handler) GetTransactionResult added in v0.40.0

GetTransactionResult gets a transaction by ID.

func (*Handler) GetTransactionResultByIndex added in v0.40.0

GetTransactionResultByIndex gets a transaction at a specific index for in a block that is executed, pending or finalized transactions return errors

func (*Handler) GetTransactionResultsByBlockID added in v0.40.0

func (*Handler) GetTransactionsByBlockID added in v0.40.0

func (*Handler) Ping added in v0.40.0

Ping the Access API server for a response.

func (*Handler) SendAndSubscribeTransactionStatuses added in v0.40.0

SendAndSubscribeTransactionStatuses streams transaction statuses starting from the reference block saved in the transaction itself until the block containing the transaction becomes sealed or expired. When the transaction status becomes TransactionStatusSealed or TransactionStatusExpired, the subscription will automatically shut down.

func (*Handler) SendTransaction added in v0.40.0

SendTransaction submits a transaction to the network.

func (*Handler) SubscribeBlockDigestsFromLatest added in v0.40.0

SubscribeBlockDigestsFromLatest handles subscription requests for lightweight block started from latest sealed block. It takes a SubscribeBlockDigestsFromLatestRequest and an AccessAPI_SubscribeBlockDigestsFromLatestServer stream as input. The handler manages the subscription to block updates and sends the subscribed block header information to the client via the provided stream.

Expected errors during normal operation: - codes.InvalidArgument - if unknown block status provided. - codes.ResourceExhausted - if the maximum number of streams is reached. - codes.Internal - if stream encountered an error, if stream got unexpected response or could not convert block to message or could not send response.

func (*Handler) SubscribeBlockDigestsFromStartBlockID added in v0.40.0

SubscribeBlockDigestsFromStartBlockID streams finalized or sealed lightweight block starting at the requested block id. It takes a SubscribeBlockDigestsFromStartBlockIDRequest and an AccessAPI_SubscribeBlockDigestsFromStartBlockIDServer stream as input.

Expected errors during normal operation: - codes.InvalidArgument - if invalid startBlockID provided or unknown block status provided, - codes.ResourceExhausted - if the maximum number of streams is reached. - codes.Internal - if stream encountered an error, if stream got unexpected response or could not convert block to message or could not send response.

func (*Handler) SubscribeBlockDigestsFromStartHeight added in v0.40.0

SubscribeBlockDigestsFromStartHeight handles subscription requests for lightweight blocks started from block height. It takes a SubscribeBlockDigestsFromStartHeightRequest and an AccessAPI_SubscribeBlockDigestsFromStartHeightServer stream as input. The handler manages the subscription to block updates and sends the subscribed block information to the client via the provided stream.

Expected errors during normal operation: - codes.InvalidArgument - if unknown block status provided. - codes.ResourceExhausted - if the maximum number of streams is reached. - codes.Internal - if stream encountered an error, if stream got unexpected response or could not convert block to message or could not send response.

func (*Handler) SubscribeBlockHeadersFromLatest added in v0.40.0

SubscribeBlockHeadersFromLatest handles subscription requests for block headers started from latest sealed block. It takes a SubscribeBlockHeadersFromLatestRequest and an AccessAPI_SubscribeBlockHeadersFromLatestServer stream as input. The handler manages the subscription to block updates and sends the subscribed block header information to the client via the provided stream.

Expected errors during normal operation: - codes.InvalidArgument - if unknown block status provided. - codes.ResourceExhausted - if the maximum number of streams is reached. - codes.Internal - if stream encountered an error, if stream got unexpected response or could not convert block header to message or could not send response.

func (*Handler) SubscribeBlockHeadersFromStartBlockID added in v0.40.0

SubscribeBlockHeadersFromStartBlockID handles subscription requests for block headers started from block id. It takes a SubscribeBlockHeadersFromStartBlockIDRequest and an AccessAPI_SubscribeBlockHeadersFromStartBlockIDServer stream as input. The handler manages the subscription to block updates and sends the subscribed block header information to the client via the provided stream.

Expected errors during normal operation: - codes.InvalidArgument - if invalid startBlockID provided or unknown block status provided. - codes.ResourceExhausted - if the maximum number of streams is reached. - codes.Internal - if stream encountered an error, if stream got unexpected response or could not convert block header to message or could not send response.

func (*Handler) SubscribeBlockHeadersFromStartHeight added in v0.40.0

SubscribeBlockHeadersFromStartHeight handles subscription requests for block headers started from block height. It takes a SubscribeBlockHeadersFromStartHeightRequest and an AccessAPI_SubscribeBlockHeadersFromStartHeightServer stream as input. The handler manages the subscription to block updates and sends the subscribed block header information to the client via the provided stream.

Expected errors during normal operation: - codes.InvalidArgument - if unknown block status provided. - codes.ResourceExhausted - if the maximum number of streams is reached. - codes.Internal - if stream encountered an error, if stream got unexpected response or could not convert block header to message or could not send response.

func (*Handler) SubscribeBlocksFromLatest added in v0.40.0

SubscribeBlocksFromLatest handles subscription requests for blocks started from latest sealed block. It takes a SubscribeBlocksFromLatestRequest and an AccessAPI_SubscribeBlocksFromLatestServer stream as input. The handler manages the subscription to block updates and sends the subscribed block information to the client via the provided stream.

Expected errors during normal operation: - codes.InvalidArgument - if unknown block status provided. - codes.ResourceExhausted - if the maximum number of streams is reached. - codes.Internal - if stream encountered an error, if stream got unexpected response or could not convert block to message or could not send response.

func (*Handler) SubscribeBlocksFromStartBlockID added in v0.40.0

SubscribeBlocksFromStartBlockID handles subscription requests for blocks started from block id. It takes a SubscribeBlocksFromStartBlockIDRequest and an AccessAPI_SubscribeBlocksFromStartBlockIDServer stream as input. The handler manages the subscription to block updates and sends the subscribed block information to the client via the provided stream.

Expected errors during normal operation: - codes.InvalidArgument - if invalid startBlockID provided or unknown block status provided. - codes.ResourceExhausted - if the maximum number of streams is reached. - codes.Internal - if stream encountered an error, if stream got unexpected response or could not convert block to message or could not send response.

func (*Handler) SubscribeBlocksFromStartHeight added in v0.40.0

SubscribeBlocksFromStartHeight handles subscription requests for blocks started from block height. It takes a SubscribeBlocksFromStartHeightRequest and an AccessAPI_SubscribeBlocksFromStartHeightServer stream as input. The handler manages the subscription to block updates and sends the subscribed block information to the client via the provided stream.

Expected errors during normal operation: - codes.InvalidArgument - if unknown block status provided. - codes.ResourceExhausted - if the maximum number of streams is reached. - codes.Internal - if stream encountered an error, if stream got unexpected response or could not convert block to message or could not send response.

type HandlerOption added in v0.40.0

type HandlerOption func(*Handler)

HandlerOption is used to hand over optional constructor parameters

type Option added in v0.32.0

type Option func(*RPCEngineBuilder)

type RPCEngineBuilder added in v0.27.0

type RPCEngineBuilder struct {
	*Engine
	// contains filtered or unexported fields
}

func NewBuilder added in v0.27.0

func NewBuilder(
	log zerolog.Logger,
	state protocol.State,
	config Config,
	chainID flow.ChainID,
	accessMetrics module.AccessMetrics,
	rpcMetricsEnabled bool,
	me module.Local,
	backend *backend.Backend,
	restHandler access.API,
	secureGrpcServer *grpcserver.GrpcServer,
	unsecureGrpcServer *grpcserver.GrpcServer,
	stateStreamBackend state_stream.API,
	stateStreamConfig statestreambackend.Config,
	indexReporter state_synchronization.IndexReporter,
) (*RPCEngineBuilder, error)

NewBuilder returns a new RPC engine builder.

func NewRPCEngineBuilder added in v0.27.0

func NewRPCEngineBuilder(engine *Engine, me module.Local, finalizedHeaderCache module.FinalizedHeaderCache, indexReporter state_synchronization.IndexReporter) *RPCEngineBuilder

NewRPCEngineBuilder helps to build a new RPC engine.

func (*RPCEngineBuilder) Build added in v0.27.0

func (builder *RPCEngineBuilder) Build() (*Engine, error)

func (*RPCEngineBuilder) DefaultHandler added in v0.33.30

func (builder *RPCEngineBuilder) DefaultHandler(signerIndicesDecoder hotstuff.BlockSignerDecoder) *Handler

func (*RPCEngineBuilder) RpcHandler added in v0.32.0

func (builder *RPCEngineBuilder) RpcHandler() accessproto.AccessAPIServer

func (*RPCEngineBuilder) WithBlockSignerDecoder added in v0.27.0

func (builder *RPCEngineBuilder) WithBlockSignerDecoder(signerIndicesDecoder hotstuff.BlockSignerDecoder) *RPCEngineBuilder

WithBlockSignerDecoder specifies that signer indices in block headers should be translated to full node IDs with the given decoder. Caution: you can inject either a `BlockSignerDecoder` (via method `WithBlockSignerDecoder`) or an `AccessAPIServer` (via method `WithNewHandler`); but not both. If both are specified, the builder will error during the build step.

Returns self-reference for chaining.

func (*RPCEngineBuilder) WithLegacy added in v0.27.0

func (builder *RPCEngineBuilder) WithLegacy() *RPCEngineBuilder

WithLegacy specifies that a legacy access API should be instantiated Returns self-reference for chaining.

func (*RPCEngineBuilder) WithMetrics added in v0.27.0

func (builder *RPCEngineBuilder) WithMetrics() *RPCEngineBuilder

WithMetrics specifies the metrics should be collected. Returns self-reference for chaining.

func (*RPCEngineBuilder) WithRpcHandler added in v0.32.0

func (builder *RPCEngineBuilder) WithRpcHandler(handler accessproto.AccessAPIServer) *RPCEngineBuilder

WithRpcHandler specifies that the given `AccessAPIServer` should be used for serving API queries. Caution: you can inject either a `BlockSignerDecoder` (via method `WithBlockSignerDecoder`) or an `AccessAPIServer` (via method `WithRpcHandler`); but not both. If both are specified, the builder will error during the build step.

Returns self-reference for chaining.

Jump to

Keyboard shortcuts

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