rpc

package
v0.43.1-rc.1.access-me... Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2025 License: AGPL-3.0 Imports: 13 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// DefaultMaxMsgSize is the default maximum message size for GRPC servers and clients.
	// This is the default used by the grpc library if no max is specified.
	DefaultMaxMsgSize = 4 << (10 * 2) // 4 MiB

	// DefaultMaxResponseMsgSize is the default maximum response message size for GRPC servers and clients.
	// This uses 1 GiB, which allows for reasonably large messages returned for execution data.
	DefaultMaxResponseMsgSize = 1 << (10 * 3) // 1 GiB

	// DefaultAccessMaxRequestSize is the default maximum request message size for the access API.
	DefaultAccessMaxRequestSize = DefaultMaxMsgSize

	// DefaultAccessMaxResponseSize is the default maximum response message size for the access API.
	// This must be large enought to accomodate large execution data responses.
	DefaultAccessMaxResponseSize = DefaultMaxResponseMsgSize

	// DefaultExecutionMaxRequestSize is the default maximum request message size for the execution API.
	DefaultExecutionMaxRequestSize = DefaultMaxMsgSize

	// DefaultExecutionMaxResponseSize is the default maximum response message size for the execution API.
	// This must be large enought to accomodate large execution data responses.
	DefaultExecutionMaxResponseSize = DefaultMaxResponseMsgSize

	// DefaultCollectionMaxRequestSize is the default maximum request message size for the collection node.
	// This is set to 4 MiB, which is larger than the default max service account transaction size (3 MiB).
	// The service account size is controled by MaxCollectionByteSize used by the transaction validator.
	DefaultCollectionMaxRequestSize = 4 << (10 * 2) // 4 MiB

	// DefaultCollectionMaxResponseSize is the default maximum response message size for the collection node.
	// This can be set to a smaller value since responses should be very small.
	DefaultCollectionMaxResponseSize = DefaultMaxMsgSize
)
View Source
const MaxNodesCnt = 3

MaxNodesCnt is the maximum number of nodes that will be contacted to complete an API request.

Variables

View Source
var ErrNoENsFoundForExecutionResult = fmt.Errorf("no execution nodes found for execution result")

ErrNoENsFoundForExecutionResult is returned when no execution nodes were found that produced the requested execution result and matches all operator's criteria.

View Source
var ErrScriptTooLarge = errors.New("script and/or arguments are too large")

ErrScriptTooLarge is returned when a script and/or arguments exceed the max size allowed by the server

Functions

func CheckScriptSize added in v0.43.0

func CheckScriptSize(script []byte, arguments [][]byte, maxSize uint) bool

CheckScriptSize returns true if the combined size (in bytes) of the script and arguments is less than or equal to the max size.

func ConvertError added in v0.30.0

func ConvertError(err error, msg string, defaultCode codes.Code) error

ConvertError converts a generic error into a grpc status error. The input may either be a status.Error already, or standard error type. Any error that matches on of the common status code mappings will be converted, all unmatched errors will be converted to the provided defaultCode.

func ConvertIndexError added in v0.33.13

func ConvertIndexError(err error, height uint64, defaultMsg string) error

ConvertIndexError converts errors related to index and storage to appropriate gRPC status errors. If the error is nil, it returns nil. If the error is not recognized, it falls back to ConvertError with the provided default message and Internal gRPC code.

func ConvertMultiError added in v0.29.12

func ConvertMultiError(err *multierror.Error, msg string, defaultCode codes.Code) error

ConvertMultiError converts a multierror to a grpc status error. If the errors have related status codes, the common code is returned, otherwise defaultCode is used.

func ConvertStorageError added in v0.29.0

func ConvertStorageError(err error) error

ConvertStorageError converts a generic error into a grpc status error, converting storage errors into codes.NotFound

Types

type ExecutionNodeIdentitiesProvider added in v0.38.0

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

ExecutionNodeIdentitiesProvider is a container for elements required to retrieve execution node identities for a given block ID.

func NewExecutionNodeIdentitiesProvider added in v0.38.0

func NewExecutionNodeIdentitiesProvider(
	log zerolog.Logger,
	state protocol.State,
	executionReceipts storage.ExecutionReceipts,
	preferredENIdentifiers flow.IdentifierList,
	fixedENIdentifiers flow.IdentifierList,
) *ExecutionNodeIdentitiesProvider

NewExecutionNodeIdentitiesProvider creates and returns a new instance of ExecutionNodeIdentitiesProvider.

Parameters:

  • log: The logger to use for logging.
  • state: The protocol state used for retrieving block information.
  • executionReceipts: A storage.ExecutionReceipts object that contains the execution receipts for blocks.
  • preferredENIdentifiers: A flow.IdentifierList of preferred execution node identifiers that are prioritized during selection.
  • fixedENIdentifiers: A flow.IdentifierList of fixed execution node identifiers that are always considered if available.

func (*ExecutionNodeIdentitiesProvider) ChooseFromPreferredENIDs added in v0.38.0

func (e *ExecutionNodeIdentitiesProvider) ChooseFromPreferredENIDs(
	allENs flow.IdentityList,
	executorIDs flow.IdentifierList,
) flow.IdentityList

ChooseFromPreferredENIDs finds the subset of execution nodes if preferred execution nodes are defined. If preferredENIdentifiers is set and there are less than maxNodesCnt nodes selected, than the list is padded up to maxNodesCnt nodes using the following order: 1. Use any EN with a receipt. 2. Use any preferred node not already selected. 3. Use any EN not already selected.

func (*ExecutionNodeIdentitiesProvider) ExecutionNodesForBlockID added in v0.38.0

func (e *ExecutionNodeIdentitiesProvider) ExecutionNodesForBlockID(
	ctx context.Context,
	blockID flow.Identifier,
) (flow.IdentitySkeletonList, error)

ExecutionNodesForBlockID returns upto maxNodesCnt number of randomly chosen execution node identities which have executed the given block ID.

Expected errors during normal operations:

  • InsufficientExecutionReceipts - If no such execution node is found.
  • ErrNoENsFoundForExecutionResult - if no execution nodes were found that produced the provided execution result and matched the operators criteria

func (*ExecutionNodeIdentitiesProvider) ExecutionNodesForResultID added in v0.43.0

func (e *ExecutionNodeIdentitiesProvider) ExecutionNodesForResultID(
	blockID flow.Identifier,
	resultID flow.Identifier,
) (flow.IdentitySkeletonList, error)

ExecutionNodesForResultID returns execution node identities that produced receipts for the specific execution result ID within the given block.

Expected errors during normal operation:

  • ErrNoENsFoundForExecutionResult - if no execution nodes were found that produced the provided execution result and matched the operators criteria

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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