{"modulePath":"github.com/onflow/flow-go","version":"v0.51.2","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package execution_data\n\n## Constants\n\n```go\nconst DefaultMaxBlobSize = 1 \u003c\u003c 20 // 1MiB\n\n```\nDefaultMaxBlobSize is the default maximum size of a blob. This is calibrated to fit within a libp2p message and not exceed the max size recommended by bitswap.\n\n## Functions\n\n```go\nfunc CalculateID(ctx context.Context, execData *BlockExecutionData, serializer Serializer) (flow.Identifier, error)\n```\nCalculateID calculates the root ID of the given execution data without storing any data. No errors are expected during normal operation.\n\n```go\nfunc ConvertTransactionResults(results flow.TransactionResults) []flow.LightTransactionResult\n```\nConvertTransactionResults converts a list of flow.TransactionResults into a list of flow.LightTransactionResults to be included in a ChunkExecutionData.\n\n```go\nfunc IsBlobNotFoundError(err error) bool\n```\nIsBlobNotFoundError returns whether an error is BlobNotFoundError\n\n```go\nfunc IsBlobSizeLimitExceededError(err error) bool\n```\nIsBlobSizeLimitExceededError returns whether an error is BlobSizeLimitExceededError\n\n```go\nfunc IsMalformedDataError(err error) bool\n```\nIsMalformedDataError returns whether an error is MalformedDataError\n\n```go\nfunc NewDownloader(blobService network.BlobService, opts ...DownloaderOption) *downloader\n```\nNewDownloader creates a new Downloader instance\n\n```go\nfunc NewExecutionDataStore(blobstore blobs.Blobstore, serializer Serializer, opts ...ExecutionDataStoreOption) *store\n```\nNewExecutionDataStore creates a new Execution Data Store.\n\n```go\nfunc NewSerializer(codec encoding.Codec, compressor network.Compressor) *serializer\n```\nNewSerializer returns a new Execution Data serializer using the provided encoder and compressor.\n\n## Types\n\n```go\ntype BlobNotFoundError struct {\n\t// contains filtered or unexported fields\n}\n```\nBlobNotFoundError is returned when a blob could not be found.\n\n```go\nfunc NewBlobNotFoundError(cid cid.Cid) *BlobNotFoundError\n```\n\n```go\nfunc (e *BlobNotFoundError) Error() string\n```\n\n```go\ntype BlobSizeLimitExceededError struct {\n\t// contains filtered or unexported fields\n}\n```\nBlobSizeLimitExceededError is returned when a blob exceeds the maximum size allowed.\n\n```go\nfunc (e *BlobSizeLimitExceededError) Error() string\n```\n\n```go\ntype BlockExecutionData struct {\n\tBlockID             flow.Identifier\n\tChunkExecutionDatas []*ChunkExecutionData\n}\n```\nBlockExecutionData represents the execution data of a block.\n\n```go\nfunc (bd *BlockExecutionData) StandardChunks() []*ChunkExecutionData\n```\nStandardChunks returns all standard (non-system) chunks for the block.\n\n```go\nfunc (bd *BlockExecutionData) StandardCollections() []*flow.Collection\n```\nStandardCollections returns all standard (non-system) collections for the block.\n\n```go\nfunc (bd *BlockExecutionData) SystemChunk() *ChunkExecutionData\n```\nSystemChunk returns the system chunk for the block.\n\n```go\nfunc (bd *BlockExecutionData) SystemCollection() *flow.Collection\n```\nSystemCollection returns the system collection for the block.\n\n```go\ntype BlockExecutionDataEntity struct {\n\t*BlockExecutionData\n\n\t// ExecutionDataID holds the cached BlockExecutionData ID. The ID generation process is expensive, so this\n\t// wrapper exclusively uses a pre-calculated value.\n\tExecutionDataID flow.Identifier\n}\n```\nBlockExecutionDataEntity is a wrapper around BlockExecutionData that holds the cached BlockExecutionData ID\n\n```go\nfunc NewBlockExecutionDataEntity(executionDataID flow.Identifier, executionData *BlockExecutionData) *BlockExecutionDataEntity\n```\n\n```go\ntype ChunkExecutionData struct {\n\t// Collection is the collection for which this chunk was executed\n\tCollection *flow.Collection\n\n\t// Events are the events generated by executing the collection\n\tEvents flow.EventsList\n\n\t// TrieUpdate is the trie update generated by executing the collection\n\t// This includes a list of all registers updated during the execution\n\tTrieUpdate *ledger.TrieUpdate\n\n\t// TransactionResults are the results of executing the transactions in the collection\n\t// This includes all of the data from flow.TransactionResult, except that it uses a boolean\n\t// value to indicate if an error occurred instead of a full error message.\n\tTransactionResults []flow.LightTransactionResult\n}\n```\nChunkExecutionData represents the execution data of a chunk\n\n```go\ntype Downloader interface {\n\tmodule.ReadyDoneAware\n\tExecutionDataGetter\n\tProcessedHeightRecorder\n}\n```\nDownloader is used to download execution data blobs from the network via a blob service.\n\n```go\ntype DownloaderOption func(*downloader)\n```\n\n```go\nfunc WithExecutionDataTracker(storage tracker.Storage, headers storage.Headers) DownloaderOption\n```\nWithExecutionDataTracker configures the execution data tracker and the storage headers for the downloader\n\n```go\nfunc WithSerializer(serializer Serializer) DownloaderOption\n```\nWithSerializer configures the serializer for the downloader\n\n```go\ntype ExecutionDataCache interface {\n\t// ByID returns the execution data for the given ExecutionDataID.\n\t//\n\t// Expected error returns during normal operation:\n\t//   - [BlobNotFoundError]: if some CID in the blob tree could not be found from the blobstore\n\t//   - [MalformedDataError]: if some level of the blob tree cannot be properly deserialized\n\t//   - [BlobSizeLimitExceededError]: if some blob in the blob tree exceeds the maximum allowed size\n\tByID(ctx context.Context, executionDataID flow.Identifier) (*BlockExecutionDataEntity, error)\n\n\t// ByBlockID returns the execution data for the given block ID.\n\t//\n\t// Expected error returns during normal operation:\n\t//   - [storage.ErrNotFound]: if a seal or execution result is not available for the block\n\t//   - [BlobNotFoundError]: if some CID in the blob tree could not be found from the blobstore\n\t//   - [MalformedDataError]: if some level of the blob tree cannot be properly deserialized\n\t//   - [BlobSizeLimitExceededError]: if some blob in the blob tree exceeds the maximum allowed size\n\tByBlockID(ctx context.Context, blockID flow.Identifier) (*BlockExecutionDataEntity, error)\n\n\t// ByHeight returns the execution data for the given block height.\n\t//\n\t// Expected error returns during normal operation:\n\t//   - [storage.ErrNotFound]: if a seal or execution result is not available for the block\n\t//   - [BlobNotFoundError]: if some CID in the blob tree could not be found from the blobstore\n\t//   - [MalformedDataError]: if some level of the blob tree cannot be properly deserialized\n\t//   - [BlobSizeLimitExceededError]: if some blob in the blob tree exceeds the maximum allowed size\n\tByHeight(ctx context.Context, height uint64) (*BlockExecutionDataEntity, error)\n\n\t// LookupID returns the ExecutionDataID for the given block ID.\n\t//\n\t// Expected error returns during normal operation:\n\t//   - [storage.ErrNotFound]: if a seal or execution result is not available for the block\n\tLookupID(blockID flow.Identifier) (flow.Identifier, error)\n}\n```\nExecutionDataCache provides a read-through cache for execution data. All methods are safe for concurrent use.\n\n```go\ntype ExecutionDataDBMode int\n```\nExecutionDataDBMode controls which db type to use.\n\n```go\nconst (\n\t// ExecutionDataDBModeBadger uses badger db\n\tExecutionDataDBModeBadger ExecutionDataDBMode = iota + 1\n\n\t// ExecutionDataDBModePebble uses pebble db\n\tExecutionDataDBModePebble\n)\n```\n\n```go\nfunc ParseExecutionDataDBMode(s string) (ExecutionDataDBMode, error)\n```\n\n```go\nfunc (m ExecutionDataDBMode) String() string\n```\n\n```go\ntype ExecutionDataGetter interface {\n\t// Get gets the BlockExecutionData for the given root ID from the blobstore.\n\t// Expected errors during normal operations:\n\t// - BlobNotFoundError if some CID in the blob tree could not be found from the blobstore\n\t// - MalformedDataError if some level of the blob tree cannot be properly deserialized\n\t// - BlobSizeLimitExceededError if some blob in the blob tree exceeds the maximum allowed size\n\tGet(ctx context.Context, rootID flow.Identifier) (*BlockExecutionData, error)\n}\n```\nExecutionDataGetter handles getting execution data from a blobstore\n\n```go\ntype ExecutionDataStore interface {\n\tExecutionDataGetter\n\n\t// Add constructs a blob tree for the given BlockExecutionData, adds it to the blobstore,\n\t// then returns the root CID.\n\t// No errors are expected during normal operation.\n\tAdd(ctx context.Context, executionData *BlockExecutionData) (flow.Identifier, error)\n}\n```\nExecutionDataStore handles adding / getting execution data to / from a blobstore\n\n```go\ntype ExecutionDataStoreOption func(*store)\n```\n\n```go\nfunc WithMaxBlobSize(size int) ExecutionDataStoreOption\n```\nWithMaxBlobSize configures the maximum blob size of the store\n\n```go\ntype HeightUpdatesConsumer func(height uint64)\n```\n\n```go\ntype MalformedDataError struct {\n\t// contains filtered or unexported fields\n}\n```\nMalformedDataError is returned when malformed data is found at some level of the requested blob tree. It likely indicates that the tree was generated incorrectly, and hence the request should not be retried.\n\n```go\nfunc NewMalformedDataError(err error) *MalformedDataError\n```\n\n```go\nfunc (e *MalformedDataError) Error() string\n```\n\n```go\nfunc (e *MalformedDataError) Unwrap() error\n```\n\n```go\ntype ProcessedHeightRecorder interface {\n\t// OnBlockProcessed updates the highest processed height when a block is processed.\n\tOnBlockProcessed(uint64)\n\t// HighestCompleteHeight returns the highest complete processed block height.\n\tHighestCompleteHeight() uint64\n\n\t// SetHeightUpdatesConsumer subscribe consumer for processed height updates.\n\t// Callback are called synchronously and must be non-blocking\n\tSetHeightUpdatesConsumer(HeightUpdatesConsumer)\n}\n```\nProcessedHeightRecorder is an interface for tracking the highest execution data processed height when a block is processed and for providing this height.\n\n```go\ntype ProcessedHeightRecorderManager struct {\n\t// contains filtered or unexported fields\n}\n```\nProcessedHeightRecorderManager manages an execution data height recorder and tracks the highest processed block height.\n\n```go\nfunc NewProcessedHeightRecorderManager(initHeight uint64) *ProcessedHeightRecorderManager\n```\nNewProcessedHeightRecorderManager creates a new ProcessedHeightRecorderManager with the given initial height.\n\n```go\nfunc (e *ProcessedHeightRecorderManager) HighestCompleteHeight() uint64\n```\nHighestCompleteHeight returns the highest complete processed block height.\n\n```go\nfunc (e *ProcessedHeightRecorderManager) OnBlockProcessed(height uint64)\n```\nOnBlockProcessed updates the highest processed height when a block is processed.\n\n```go\nfunc (e *ProcessedHeightRecorderManager) SetHeightUpdatesConsumer(consumer HeightUpdatesConsumer)\n```\nSetHeightUpdatesConsumer subscribe consumers for processed height updates.\n\n```go\ntype Serializer interface {\n\t// Serialize encodes and compresses the given value to the given writer.\n\t// No errors are expected during normal operation.\n\tSerialize(io.Writer, any) error\n\n\t// Deserialize decompresses and decodes the data from the given reader.\n\t// No errors are expected during normal operation.\n\tDeserialize(io.Reader) (any, error)\n}\n```\nSerializer is used to serialize / deserialize Execution Data and CID lists for the Execution Data Service.\n\n```go\nvar DefaultSerializer Serializer\n```\nDefaultSerializer is the default implementation for an Execution Data serializer. It is configured to use cbor encoding with LZ4 compression.\n\nCAUTION: this encoding should only be used for encoding/decoding data within a node. If used for decoding data that is shared between nodes, it makes the recipient VULNERABLE to RESOURCE EXHAUSTION ATTACKS, where a byzantine sender could include garbage data in the encoding, which would not be noticed by the recipient because the garbage data is dropped at the decoding step - yet, it consumes the recipient's networking bandwidth.\n\n","path":"github.com/onflow/flow-go/module/executiondatasync/execution_data","name":"execution_data","synopsis":"","isRedistributable":true}
