Documentation
¶
Overview ¶
This package implements a single sequencer.
Index ¶
- Constants
- Variables
- type BatchQueue
- type Metrics
- type MetricsProvider
- type Sequencer
- func (c *Sequencer) GetNextBatch(ctx context.Context, req coresequencer.GetNextBatchRequest) (*coresequencer.GetNextBatchResponse, error)
- func (c *Sequencer) RecordMetrics(gasPrice float64, blobSize uint64, statusCode coreda.StatusCode, ...)
- func (c *Sequencer) SubmitBatchTxs(ctx context.Context, req coresequencer.SubmitBatchTxsRequest) (*coresequencer.SubmitBatchTxsResponse, error)
- func (c *Sequencer) VerifyBatch(ctx context.Context, req coresequencer.VerifyBatchRequest) (*coresequencer.VerifyBatchResponse, error)
Constants ¶
const ( // MetricsSubsystem is a subsystem shared by all metrics exposed by this // package. MetricsSubsystem = "sequencer" )
Variables ¶
var (
ErrInvalidId = errors.New("invalid chain id")
)
ErrInvalidId is returned when the chain id is invalid
var ErrQueueFull = errors.New("batch queue is full")
ErrQueueFull is returned when the batch queue has reached its maximum size
Functions ¶
This section is empty.
Types ¶
type BatchQueue ¶
type BatchQueue struct {
// contains filtered or unexported fields
}
BatchQueue implements a persistent queue for transaction batches
func NewBatchQueue ¶
func NewBatchQueue(db ds.Batching, prefix string, maxSize int) *BatchQueue
NewBatchQueue creates a new BatchQueue with the specified maximum size. If maxSize is 0, the queue will be unlimited.
func (*BatchQueue) AddBatch ¶
func (bq *BatchQueue) AddBatch(ctx context.Context, batch coresequencer.Batch) error
AddBatch adds a new transaction to the queue and writes it to the WAL. Returns ErrQueueFull if the queue has reached its maximum size.
func (*BatchQueue) Load ¶
func (bq *BatchQueue) Load(ctx context.Context) error
Load reloads all batches from WAL file into the in-memory queue after a crash or restart
func (*BatchQueue) Next ¶
func (bq *BatchQueue) Next(ctx context.Context) (*coresequencer.Batch, error)
Next extracts a batch of transactions from the queue and marks it as processed in the WAL
func (*BatchQueue) Size ¶
func (bq *BatchQueue) Size() int
Size returns the effective number of batches in the queue This method is primarily for testing and monitoring purposes
type Metrics ¶
type Metrics struct {
// GasPrice
GasPrice metrics.Gauge
// Last submitted blob size
LastBlobSize metrics.Gauge
// cost / byte
// CostPerByte metrics.Gauge
// Wallet Balance
// WalletBalance metrics.Gauge
// Transaction Status
TransactionStatus metrics.Counter
// Number of pending blocks.
NumPendingBlocks metrics.Gauge
// Last included block height
IncludedBlockHeight metrics.Gauge
}
Metrics contains metrics exposed by this package.
func PrometheusMetrics ¶
PrometheusMetrics returns Metrics build using Prometheus client library. Optionally, labels can be provided along with their values ("foo", "fooValue").
type MetricsProvider ¶
MetricsProvider returns sequencing Metrics.
func DefaultMetricsProvider ¶
func DefaultMetricsProvider(enabled bool) MetricsProvider
DefaultMetricsProvider returns Metrics build using Prometheus client library if Prometheus is enabled. Otherwise, it returns no-op Metrics.
type Sequencer ¶
type Sequencer struct {
Id []byte
// contains filtered or unexported fields
}
Sequencer implements core sequencing interface
func NewSequencer ¶
func NewSequencer( ctx context.Context, logger zerolog.Logger, db ds.Batching, da coreda.DA, id []byte, batchTime time.Duration, metrics *Metrics, proposer bool, ) (*Sequencer, error)
NewSequencer creates a new Single Sequencer
func NewSequencerWithQueueSize ¶
func NewSequencerWithQueueSize( ctx context.Context, logger zerolog.Logger, db ds.Batching, da coreda.DA, id []byte, batchTime time.Duration, metrics *Metrics, proposer bool, maxQueueSize int, ) (*Sequencer, error)
NewSequencerWithQueueSize creates a new Single Sequencer with configurable queue size
func (*Sequencer) GetNextBatch ¶
func (c *Sequencer) GetNextBatch(ctx context.Context, req coresequencer.GetNextBatchRequest) (*coresequencer.GetNextBatchResponse, error)
GetNextBatch implements sequencing.Sequencer.
func (*Sequencer) RecordMetrics ¶
func (c *Sequencer) RecordMetrics(gasPrice float64, blobSize uint64, statusCode coreda.StatusCode, numPendingBlocks uint64, includedBlockHeight uint64)
RecordMetrics updates the metrics with the given values. This method is intended to be called by the block manager after submitting data to the DA layer.
func (*Sequencer) SubmitBatchTxs ¶
func (c *Sequencer) SubmitBatchTxs(ctx context.Context, req coresequencer.SubmitBatchTxsRequest) (*coresequencer.SubmitBatchTxsResponse, error)
SubmitBatchTxs implements sequencing.Sequencer.
func (*Sequencer) VerifyBatch ¶
func (c *Sequencer) VerifyBatch(ctx context.Context, req coresequencer.VerifyBatchRequest) (*coresequencer.VerifyBatchResponse, error)
VerifyBatch implements sequencing.Sequencer.