Documentation
¶
Index ¶
- type BatchData
- type BlockProducer
- type Executor
- func (e *Executor) ApplyBlock(ctx context.Context, header types.Header, data *types.Data) (types.State, error)
- func (e *Executor) CreateBlock(ctx context.Context, height uint64, batchData *BatchData) (*types.SignedHeader, *types.Data, error)
- func (e *Executor) GetCoreExecutor() coreexecutor.Executor
- func (e *Executor) HasPendingTxNotification() bool
- func (e *Executor) IsSynced(expHeight uint64) bool
- func (e *Executor) IsSyncedWithRaft(raftState *raft.RaftBlockState) (int, error)
- func (e *Executor) NotifyNewTransactions()
- func (e *Executor) ProduceBlock(ctx context.Context) error
- func (e *Executor) RetrieveBatch(ctx context.Context) (*BatchData, error)
- func (e *Executor) SetBlockProducer(bp BlockProducer)
- func (e *Executor) Start(ctx context.Context) error
- func (e *Executor) Stop() error
- func (e *Executor) ValidateBlock(_ context.Context, lastState types.State, header *types.SignedHeader, ...) error
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 ¶
HasPendingTxNotification checks if there's a pending transaction notification It is used for testing purposes
func (*Executor) IsSynced ¶
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 ¶
ProduceBlock creates, validates, and stores a new block.
func (*Executor) RetrieveBatch ¶
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.