common

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const MaxRetriesBeforeHalt = 3

MaxRetriesBeforeHalt is the maximum number of retries before halting.

View Source
const MaxRetriesTimeout = 10 * time.Second

MaxRetriesTimeout is the maximum time to wait before halting.

View Source
const (
	// MetricsSubsystem is a subsystem shared by all metrics exposed by this
	// package.
	MetricsSubsystem = "sequencer"
)

Variables

View Source
var (
	// ErrNotProposer is used when the node is not a proposer
	ErrNotProposer = errors.New("not a proposer")

	// ErrNoBatch indicate no batch is available for creating block
	ErrNoBatch = errors.New("no batch to process")

	// ErrNoTransactionsInBatch is used when no transactions are found in batch
	ErrNoTransactionsInBatch = errors.New("no transactions found in batch")

	// ErrHeightFromFutureStr is the error message for height from future returned by da
	ErrHeightFromFutureStr = errors.New("given height is from the future")

	// ErrOversizedItem is an unrecoverable error indicating a single item exceeds DA blob size limit
	ErrOversizedItem = errors.New("single item exceeds DA blob size limit")
)

These errors are used by block components.

View Source
var DataHashForEmptyTxs = []byte{110, 52, 11, 156, 255, 179, 122, 152, 156, 165, 68, 230, 187, 120, 10, 44, 120, 144, 29, 63, 179, 55, 56, 118, 133, 17, 163, 6, 23, 175, 160, 29}

DataHashForEmptyTxs is the hash of an empty block data.

View Source
var DefaultMaxBlobSize uint64

DefaultMaxBlobSize is the max blob size limit used for blob submission.

Functions

This section is empty.

Types

type BlockOptions

type BlockOptions struct {
	AggregatorNodeSignatureBytesProvider types.AggregatorNodeSignatureBytesProvider
	SyncNodeSignatureBytesProvider       types.SyncNodeSignatureBytesProvider
	ValidatorHasherProvider              types.ValidatorHasherProvider
}

BlockOptions defines the options for creating block components

func DefaultBlockOptions

func DefaultBlockOptions() BlockOptions

DefaultBlockOptions returns the default block options

func (*BlockOptions) Validate

func (opts *BlockOptions) Validate() error

Validate validates the BlockOptions

type Broadcaster

type Broadcaster[H header.Header[H]] interface {
	WriteToStoreAndBroadcast(ctx context.Context, payload H, opts ...pubsub.PubOpt) error
	Store() header.Store[H]
	Height() uint64
}

Broadcaster interface for P2P broadcasting

type DAHeightEvent

type DAHeightEvent struct {
	Header *types.SignedHeader
	Data   *types.Data
	// DaHeight corresponds to the highest DA included height between the Header and Data.
	DaHeight uint64
	// Source indicates where this event originated from (DA or P2P)
	Source EventSource

	// Optional DA height hints from P2P. first is the DA height hint for the header, second is the DA height hint for the data
	DaHeightHints [2]uint64
}

DAHeightEvent represents a DA event for caching

type DASubmitterFailureReason

type DASubmitterFailureReason string

DASubmitterFailureReason represents a typed failure reason for DA submission failures

const (
	DASubmitterFailureReasonAlreadyRejected    DASubmitterFailureReason = "already_rejected"
	DASubmitterFailureReasonInsufficientFee    DASubmitterFailureReason = "insufficient_fee"
	DASubmitterFailureReasonTimeout            DASubmitterFailureReason = "timeout"
	DASubmitterFailureReasonAlreadyInMempool   DASubmitterFailureReason = "already_in_mempool"
	DASubmitterFailureReasonNotIncludedInBlock DASubmitterFailureReason = "not_included_in_block"
	DASubmitterFailureReasonTooBig             DASubmitterFailureReason = "too_big"
	DASubmitterFailureReasonContextCanceled    DASubmitterFailureReason = "context_canceled"
	DASubmitterFailureReasonUnknown            DASubmitterFailureReason = "unknown"
)

func AllDASubmitterFailureReasons

func AllDASubmitterFailureReasons() []DASubmitterFailureReason

AllDASubmitterFailureReasons returns all possible failure reasons

type DataP2PBroadcaster

type DataP2PBroadcaster = Broadcaster[*types.P2PData]

type EventSink added in v1.1.0

type EventSink interface {
	PipeEvent(ctx context.Context, event DAHeightEvent) error
}

EventSink receives parsed DA events with backpressure support.

type EventSinkFunc added in v1.1.0

type EventSinkFunc func(ctx context.Context, event DAHeightEvent) error

EventSinkFunc adapts a plain function to the EventSink interface. Useful in tests:

sink := common.EventSinkFunc(func(ctx context.Context, ev common.DAHeightEvent) error { return nil })

func (EventSinkFunc) PipeEvent added in v1.1.0

func (f EventSinkFunc) PipeEvent(ctx context.Context, event DAHeightEvent) error

type EventSource

type EventSource string

EventSource represents the origin of a block event

const (
	// SourceDA indicates the event came from the DA layer
	SourceDA EventSource = "da"
	// SourceP2P indicates the event came from P2P network
	SourceP2P EventSource = "p2p"
	// SourceRaft indicates the event came from Raft consensus recovery
	SourceRaft EventSource = "raft"
)

func AllEventSources added in v1.1.1

func AllEventSources() []EventSource

AllEventSources returns all possible event sources.

type HeaderP2PBroadcaster

type HeaderP2PBroadcaster = Broadcaster[*types.P2PSignedHeader]

type Metrics

type Metrics struct {
	// Original metrics
	Height          metrics.Gauge // Height of the chain
	NumTxs          metrics.Gauge // Number of transactions in the latest block
	BlockSizeBytes  metrics.Gauge // Size of the latest block
	TotalTxs        metrics.Gauge // Total number of transactions
	CommittedHeight metrics.Gauge `metrics_name:"latest_block_height"` // The latest block height
	TxsPerBlock     metrics.Histogram

	// Performance metrics
	OperationDuration map[string]metrics.Histogram

	// DA metrics
	DASubmitterFailures     map[DASubmitterFailureReason]metrics.Counter // Counter with reason label
	DASubmitterLastFailure  map[DASubmitterFailureReason]metrics.Gauge   // Timestamp gauge with reason label
	DASubmitterPendingBlobs metrics.Gauge                                // Total number of blobs awaiting submission (backlog)
	DASubmitterResends      metrics.Counter                              // Number of resend attempts
	DARetrievalAttempts     metrics.Counter
	DARetrievalSuccesses    metrics.Counter
	DARetrievalFailures     metrics.Counter
	DAInclusionHeight       metrics.Gauge

	// Forced inclusion metrics
	ForcedInclusionTxsInGracePeriod metrics.Gauge   // Number of forced inclusion txs currently in grace period
	ForcedInclusionTxsMalicious     metrics.Counter // Total number of forced inclusion txs marked as malicious

	// Syncer metrics
	BlocksSynchronized map[EventSource]metrics.Counter // Blocks synchronized by source (P2P or DA)
}

Metrics contains all metrics exposed by this package.

func NopMetrics

func NopMetrics() *Metrics

NopMetrics returns no-op Metrics

func PrometheusMetrics

func PrometheusMetrics(namespace string, labelsAndValues ...string) *Metrics

PrometheusMetrics returns Metrics built using Prometheus client library

type MockBroadcaster

type MockBroadcaster[H header.Header[H]] struct {
	mock.Mock
}

MockBroadcaster is an autogenerated mock type for the Broadcaster type

func NewMockBroadcaster

func NewMockBroadcaster[H header.Header[H]](t interface {
	mock.TestingT
	Cleanup(func())
}) *MockBroadcaster[H]

NewMockBroadcaster creates a new instance of MockBroadcaster. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*MockBroadcaster[H]) EXPECT

func (_m *MockBroadcaster[H]) EXPECT() *MockBroadcaster_Expecter[H]

func (*MockBroadcaster[H]) Height

func (_mock *MockBroadcaster[H]) Height() uint64

Height provides a mock function for the type MockBroadcaster

func (*MockBroadcaster[H]) Store

func (_mock *MockBroadcaster[H]) Store() header.Store[H]

Store provides a mock function for the type MockBroadcaster

func (*MockBroadcaster[H]) WriteToStoreAndBroadcast

func (_mock *MockBroadcaster[H]) WriteToStoreAndBroadcast(ctx context.Context, payload H, opts ...pubsub.PubOpt) error

WriteToStoreAndBroadcast provides a mock function for the type MockBroadcaster

type MockBroadcaster_Expecter

type MockBroadcaster_Expecter[H header.Header[H]] struct {
	// contains filtered or unexported fields
}

func (*MockBroadcaster_Expecter[H]) Height

Height is a helper method to define mock.On call

func (*MockBroadcaster_Expecter[H]) Store

Store is a helper method to define mock.On call

func (*MockBroadcaster_Expecter[H]) WriteToStoreAndBroadcast

func (_e *MockBroadcaster_Expecter[H]) WriteToStoreAndBroadcast(ctx interface{}, payload interface{}, opts ...interface{}) *MockBroadcaster_WriteToStoreAndBroadcast_Call[H]

WriteToStoreAndBroadcast is a helper method to define mock.On call

  • ctx context.Context
  • payload H
  • opts ...pubsub.PubOpt

type MockBroadcaster_Height_Call

type MockBroadcaster_Height_Call[H header.Header[H]] struct {
	*mock.Call
}

MockBroadcaster_Height_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Height'

func (*MockBroadcaster_Height_Call[H]) Return

func (*MockBroadcaster_Height_Call[H]) Run

func (_c *MockBroadcaster_Height_Call[H]) Run(run func()) *MockBroadcaster_Height_Call[H]

func (*MockBroadcaster_Height_Call[H]) RunAndReturn

func (_c *MockBroadcaster_Height_Call[H]) RunAndReturn(run func() uint64) *MockBroadcaster_Height_Call[H]

type MockBroadcaster_Store_Call

type MockBroadcaster_Store_Call[H header.Header[H]] struct {
	*mock.Call
}

MockBroadcaster_Store_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Store'

func (*MockBroadcaster_Store_Call[H]) Return

func (*MockBroadcaster_Store_Call[H]) Run

func (_c *MockBroadcaster_Store_Call[H]) Run(run func()) *MockBroadcaster_Store_Call[H]

func (*MockBroadcaster_Store_Call[H]) RunAndReturn

func (_c *MockBroadcaster_Store_Call[H]) RunAndReturn(run func() header.Store[H]) *MockBroadcaster_Store_Call[H]

type MockBroadcaster_WriteToStoreAndBroadcast_Call

type MockBroadcaster_WriteToStoreAndBroadcast_Call[H header.Header[H]] struct {
	*mock.Call
}

MockBroadcaster_WriteToStoreAndBroadcast_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'WriteToStoreAndBroadcast'

func (*MockBroadcaster_WriteToStoreAndBroadcast_Call[H]) Return

func (*MockBroadcaster_WriteToStoreAndBroadcast_Call[H]) Run

func (_c *MockBroadcaster_WriteToStoreAndBroadcast_Call[H]) Run(run func(ctx context.Context, payload H, opts ...pubsub.PubOpt)) *MockBroadcaster_WriteToStoreAndBroadcast_Call[H]

func (*MockBroadcaster_WriteToStoreAndBroadcast_Call[H]) RunAndReturn

func (_c *MockBroadcaster_WriteToStoreAndBroadcast_Call[H]) RunAndReturn(run func(ctx context.Context, payload H, opts ...pubsub.PubOpt) error) *MockBroadcaster_WriteToStoreAndBroadcast_Call[H]

type RaftNode

type RaftNode interface {
	IsLeader() bool
	HasQuorum() bool
	GetState() *raft.RaftBlockState

	Broadcast(ctx context.Context, state *raft.RaftBlockState) error

	SetApplyCallback(ch chan<- raft.RaftApplyMsg)
}

RaftNode interface for raft consensus integration

type Replayer

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

Replayer handles synchronization of the execution layer with ev-node's state. It replays blocks from the store to bring the execution layer up to date.

func NewReplayer

func NewReplayer(
	store store.Store,
	exec coreexecutor.Executor,
	genesis genesis.Genesis,
	logger zerolog.Logger,
) *Replayer

NewReplayer creates a new execution layer replayer.

func (*Replayer) SyncToHeight

func (s *Replayer) SyncToHeight(ctx context.Context, targetHeight uint64) error

SyncToHeight checks if the execution layer is behind ev-node and syncs it to the target height. This is useful for crash recovery scenarios where ev-node is ahead of the execution layer.

Returns: - error if sync fails

Jump to

Keyboard shortcuts

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