factory

package
v0.44.0-unsafe-collect... Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2025 License: AGPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateExecutionDataProcessorComponent

func CreateExecutionDataProcessorComponent(
	log zerolog.Logger,
	executionDataSyncEnabled bool,
	collectionSyncMode CollectionSyncMode,
	executionDataCache execution_data.ExecutionDataCache,
	executionDataRequester state_synchronization.ExecutionDataRequester,
	collectionIndexedHeight storage.ConsumerProgress,
	blockCollectionIndexer collection_sync.BlockCollectionIndexer,
	collectionSyncMetrics module.CollectionSyncMetrics,
	lastFullBlockHeight *ProgressReader,
	distributor *edrequester.ExecutionDataDistributor,
) (module.ReadyDoneAware, error)

CreateExecutionDataProcessorComponent creates an execution data processor component. It creates an execution data processor if execution data sync is enabled and collection sync mode is not "collection_only".

Parameters:

  • log: Logger for logging operations
  • executionDataSyncEnabled: Whether execution data sync is enabled
  • collectionSyncMode: The collection sync mode
  • executionDataCache: Execution data cache
  • executionDataRequester: Execution data requester
  • collectionIndexedHeight: Consumer progress for collection indexed height
  • blockCollectionIndexer: Block collection indexer
  • collectionSyncMetrics: Collection sync metrics
  • lastFullBlockHeight: Progress reader to register the processor with
  • distributor: Execution data distributor to notify on new execution data

Returns:

  • The processor component (or NoopReadyDoneAware if not created)
  • An error if the processor creation fails

Types

type CollectionSyncFetcherComponentResult

type CollectionSyncFetcherComponentResult struct {
	Fetcher   module.ReadyDoneAware
	Requester module.ReadyDoneAware
}

CollectionSyncFetcherComponentResult contains the results from creating the collection sync fetcher component.

func CreateCollectionSyncFetcherComponent

func CreateCollectionSyncFetcherComponent(
	log zerolog.Logger,
	executionDataSyncEnabled bool,
	collectionSyncMode CollectionSyncMode,
	engineMetrics module.EngineMetrics,
	engineRegistry network.EngineRegistry,
	state protocol.State,
	me module.Local,
	blocks storage.Blocks,
	db storage.DB,
	blockCollectionIndexer collection_sync.BlockCollectionIndexer,
	followerDistributor hotstuff.Distributor,
	collectionExecutedMetric module.CollectionExecutedMetric,
	collectionSyncMetrics module.CollectionSyncMetrics,
	maxProcessing uint64,
	maxSearchAhead uint64,
	lastFullBlockHeight *ProgressReader,
) (*CollectionSyncFetcherComponentResult, error)

CreateCollectionSyncFetcherComponent creates a collection fetcher and requester engine based on the collection sync mode.

Parameters:

  • log: Logger for logging operations
  • executionDataSyncEnabled: Whether execution data sync is enabled
  • collectionSyncMode: The collection sync mode
  • engineMetrics: Engine metrics
  • engineRegistry: Engine registry
  • state: Protocol state
  • me: Local node identity
  • blocks: Blocks storage
  • db: Database for storage operations
  • blockCollectionIndexer: Block collection indexer
  • followerDistributor: Follower distributor
  • collectionExecutedMetric: Collection executed metric
  • collectionSyncMetrics: Collection sync metrics
  • maxProcessing: Maximum number of concurrent processing jobs
  • maxSearchAhead: Maximum number of blocks to search ahead
  • lastFullBlockHeight: Progress reader to register the fetcher with

Returns:

  • The result containing the fetcher component, requester component, and requester engine
  • An error if the fetcher creation fails

type CollectionSyncMode

type CollectionSyncMode string

CollectionSyncMode represents the mode for collection synchronization.

const (
	// CollectionSyncModeExecutionFirst fetches from execution nodes first if execution data syncing is enabled,
	// otherwise fetches from collection nodes.
	CollectionSyncModeExecutionFirst CollectionSyncMode = "execution_first"
	// CollectionSyncModeExecutionAndCollection fetches from both collection nodes and execution nodes.
	CollectionSyncModeExecutionAndCollection CollectionSyncMode = "execution_and_collection"
	// CollectionSyncModeCollectionOnly only fetches from collection nodes.
	CollectionSyncModeCollectionOnly CollectionSyncMode = "collection_only"
)

func ParseCollectionSyncMode

func ParseCollectionSyncMode(s string) (CollectionSyncMode, error)

ParseCollectionSyncMode parses a string into a CollectionSyncMode.

func (CollectionSyncMode) ShouldCreateExecutionDataProcessor

func (m CollectionSyncMode) ShouldCreateExecutionDataProcessor(executionDataSyncEnabled bool) bool

ShouldCreateExecutionDataProcessor returns whether an execution data processor should be created based on the sync mode and whether execution data sync is enabled.

An execution data processor should be created if:

  • Execution data sync is enabled AND
  • The mode is NOT CollectionOnly (since CollectionOnly mode only fetches from collection nodes)

func (CollectionSyncMode) ShouldCreateFetcher

func (m CollectionSyncMode) ShouldCreateFetcher(executionDataSyncEnabled bool) bool

ShouldCreateFetcher returns whether a collection fetcher should be created based on the sync mode and whether execution data sync is enabled.

A fetcher should be created if:

  • The mode is ExecutionAndCollection (always create, even with execution data sync)
  • The mode is CollectionOnly (always create)
  • The mode is ExecutionFirst and execution data sync is disabled

func (CollectionSyncMode) String

func (m CollectionSyncMode) String() string

String returns the string representation of the CollectionSyncMode.

type CreateFetcherConfig

type CreateFetcherConfig struct {
	// MaxProcessing is the maximum number of jobs to process concurrently.
	MaxProcessing uint64
	// MaxSearchAhead is the maximum number of jobs beyond processedIndex to process. 0 means no limit.
	MaxSearchAhead uint64
}

CreateFetcherConfig holds configuration parameters for creating a Fetcher.

type ProcessedLastFullBlockHeightModuleResult

type ProcessedLastFullBlockHeightModuleResult struct {
	LastFullBlockHeight     *ProgressReader
	CollectionIndexedHeight storage.ConsumerProgress
}

ProcessedLastFullBlockHeightModuleResult contains the results from creating the processed last full block height module.

func CreateProcessedLastFullBlockHeightModule

func CreateProcessedLastFullBlockHeightModule(
	log zerolog.Logger,
	state protocol.State,
	db storage.DB,
) (*ProcessedLastFullBlockHeightModuleResult, error)

CreateProcessedLastFullBlockHeightModule initializes and syncs the progress trackers for collection sync.

Parameters:

  • log: Logger for logging operations
  • state: Protocol state to get root block height
  • db: Database for storing progress

Returns:

  • The result containing the ProgressReader and collection indexed height
  • An error if the initialization fails

type ProgressReader

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

ProgressReader aggregates progress from multiple backends and returns the maximum processed height. It can be initialized with an readonly lastProgress value and two optional backends: executionDataProcessor and collectionFetcher.

func NewProgressReader

func NewProgressReader(lastProgress uint64) *ProgressReader

NewProgressReader creates a new ProgressReader initialized with lastProgress. Backends can be added using SetExecutionDataProcessor and SetCollectionFetcher.

func (*ProgressReader) ProcessedHeight

func (pr *ProgressReader) ProcessedHeight() uint64

ProcessedHeight returns the maximum processed height from the available backends. If both backends are available, it returns the maximum of their progress and lastProgress. If only one backend is available, it returns the maximum of that backend's progress and lastProgress. If neither backend is available, it returns lastProgress.

func (*ProgressReader) SetCollectionFetcher

func (pr *ProgressReader) SetCollectionFetcher(backend collection_sync.ProgressReader)

SetCollectionFetcher sets the collection fetcher backend.

func (*ProgressReader) SetExecutionDataProcessor

func (pr *ProgressReader) SetExecutionDataProcessor(backend collection_sync.ProgressReader)

SetExecutionDataProcessor sets the execution data processor backend.

Jump to

Keyboard shortcuts

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