executing

package
v1.0.0-rc.1 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2026 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BatchData

type BatchData struct {
	*coresequencer.Batch
	time.Time
	Data [][]byte
}

BatchData represents batch data from sequencer

type BlockProducer

type BlockProducer interface {
	// ProduceBlock creates, validates, and broadcasts a new block.
	ProduceBlock(ctx context.Context) error

	// RetrieveBatch gets the next batch of transactions from the sequencer.
	RetrieveBatch(ctx context.Context) (*BatchData, error)

	// CreateBlock constructs a new block from the given batch data.
	CreateBlock(ctx context.Context, height uint64, batchData *BatchData) (*types.SignedHeader, *types.Data, error)

	// ApplyBlock executes the block transactions and returns the new state.
	ApplyBlock(ctx context.Context, header types.Header, data *types.Data) (types.State, error)

	// ValidateBlock validates block structure and state transitions.
	ValidateBlock(ctx context.Context, lastState types.State, header *types.SignedHeader, data *types.Data) error
}

BlockProducer defines operations for block production that can be traced. The Executor implements this interface, and a tracing decorator can wrap it to add OpenTelemetry spans to each operation.

func WithTracingBlockProducer

func WithTracingBlockProducer(inner BlockProducer) BlockProducer

WithTracingBlockProducer decorates the provided BlockProducer with tracing spans.

type Executor

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

Executor handles block production, transaction processing, and state management

func NewExecutor

func NewExecutor(
	store store.Store,
	exec coreexecutor.Executor,
	sequencer coresequencer.Sequencer,
	signer signer.Signer,
	cache cache.Manager,
	metrics *common.Metrics,
	config config.Config,
	genesis genesis.Genesis,
	headerBroadcaster common.Broadcaster[*types.SignedHeader],
	dataBroadcaster common.Broadcaster[*types.Data],
	logger zerolog.Logger,
	options common.BlockOptions,
	errorCh chan<- error,
	raftNode common.RaftNode,
) (*Executor, error)

NewExecutor creates a new block executor. The executor is responsible for: - Block production from sequencer batches - State transitions and validation - P2P broadcasting of produced blocks - DA submission of headers and data

When BasedSequencer is enabled, signer can be nil as blocks are not signed.

func (*Executor) ApplyBlock

func (e *Executor) ApplyBlock(ctx context.Context, header types.Header, data *types.Data) (types.State, error)

ApplyBlock applies the block to get the new state.

func (*Executor) CreateBlock

func (e *Executor) CreateBlock(ctx context.Context, height uint64, batchData *BatchData) (*types.SignedHeader, *types.Data, error)

CreateBlock creates a new block from the given batch.

func (*Executor) GetCoreExecutor

func (e *Executor) GetCoreExecutor() coreexecutor.Executor

GetCoreExecutor returns the underlying core executor for testing purposes

func (*Executor) HasPendingTxNotification

func (e *Executor) HasPendingTxNotification() bool

HasPendingTxNotification checks if there's a pending transaction notification It is used for testing purposes

func (*Executor) IsSynced

func (e *Executor) IsSynced(expHeight uint64) bool

IsSynced checks if the last block height in the stored state matches the expected height and returns true if they are equal.

func (*Executor) IsSyncedWithRaft

func (e *Executor) IsSyncedWithRaft(raftState *raft.RaftBlockState) (int, error)

IsSyncedWithRaft checks if the local state is synced with the given raft state, including hash check.

func (*Executor) NotifyNewTransactions

func (e *Executor) NotifyNewTransactions()

NotifyNewTransactions signals that new transactions are available

func (*Executor) ProduceBlock

func (e *Executor) ProduceBlock(ctx context.Context) error

ProduceBlock creates, validates, and stores a new block.

func (*Executor) RetrieveBatch

func (e *Executor) RetrieveBatch(ctx context.Context) (*BatchData, error)

RetrieveBatch gets the next batch of transactions from the sequencer.

func (*Executor) SetBlockProducer

func (e *Executor) SetBlockProducer(bp BlockProducer)

SetBlockProducer sets the block producer interface, allowing injection of a tracing wrapper or other decorator.

func (*Executor) Start

func (e *Executor) Start(ctx context.Context) error

Start begins the execution component

func (*Executor) Stop

func (e *Executor) Stop() error

Stop shuts down the execution component

func (*Executor) ValidateBlock

func (e *Executor) ValidateBlock(_ context.Context, lastState types.State, header *types.SignedHeader, data *types.Data) error

ValidateBlock validates the created block.

Jump to

Keyboard shortcuts

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