Documentation
¶
Overview ¶
Package single implements a single sequencer.
Index ¶
- Variables
- type BatchQueue
- func (bq *BatchQueue) Ack(ctx context.Context) error
- func (bq *BatchQueue) AddBatch(ctx context.Context, batch coresequencer.Batch) error
- func (bq *BatchQueue) Drain(ctx context.Context, maxBytes uint64) (*coresequencer.Batch, error)
- func (bq *BatchQueue) DropIncluded(ctx context.Context, included [][]byte) (int, error)
- func (bq *BatchQueue) Load(ctx context.Context) error
- func (bq *BatchQueue) SetPostponed(txs [][]byte)
- func (bq *BatchQueue) Size() int
- type Sequencer
- func (c *Sequencer) AckBatch(ctx context.Context) error
- func (c *Sequencer) GetDAHeight() uint64
- func (c *Sequencer) GetNextBatch(ctx context.Context, req coresequencer.GetNextBatchRequest) (*coresequencer.GetNextBatchResponse, error)
- func (c *Sequencer) SetDAHeight(height uint64)
- 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 ¶
This section is empty.
Variables ¶
var ErrInvalidId = seqcommon.ErrInvalidID
var ErrQueueFull = common.ErrQueueFull
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 ¶
NewBatchQueue creates a new BatchQueue with the specified maximum size. If maxSize is 0, the queue will be unlimited.
func (*BatchQueue) Ack ¶ added in v1.1.3
func (bq *BatchQueue) Ack(ctx context.Context) error
Ack commits the current inFlight entries: durably requeues any postponed transactions first, then deletes committed WAL entries. On failure neither inFlight nor inFlightPostponed is cleared, so the next Drain will roll entries back and a retry is safe.
func (*BatchQueue) AddBatch ¶
func (bq *BatchQueue) AddBatch(ctx context.Context, batch coresequencer.Batch) error
AddBatch adds a new transaction batch to the queue and writes it to the WAL. Duplicate transactions (by hash) already in the queue or in-flight are silently skipped. Returns ErrQueueFull if the queue has reached its maximum size.
func (*BatchQueue) Drain ¶ added in v1.1.3
func (bq *BatchQueue) Drain(ctx context.Context, maxBytes uint64) (*coresequencer.Batch, error)
Drain merges multiple queue entries into a single batch up to maxBytes. If maxBytes is 0, all available entries are drained. Any previously un-acked inFlight entries are rolled back to the front first. Drained entries move to inFlight state; WAL entries are NOT deleted until Ack.
func (*BatchQueue) DropIncluded ¶ added in v1.1.3
DropIncluded removes the given transactions from queued entries and the WAL. It reconciles a crash between block commit and Ack: after a restart the WAL may still hold entries whose txs were already committed in the last block. Entries are rewritten in place (or deleted when emptied) so a subsequent reload stays consistent. Returns the number of dropped transactions. It must be called on a freshly loaded queue: only queued entries are scanned, so any in-flight entries would be missed.
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) SetPostponed ¶ added in v1.1.3
func (bq *BatchQueue) SetPostponed(txs [][]byte)
SetPostponed records txs that should be requeued on the next Ack. Must be called at most once between a Drain and its Ack — a later call in the same cycle would overwrite the recorded txs. The postponedItem guard makes a repeated call after a failed Ack a no-op, so the already-persisted entry is not replaced. The queue owns this state so it is only cleared on successful Ack — no data loss on failure.
func (*BatchQueue) Size ¶
func (bq *BatchQueue) Size() int
Size returns the total number of pending batches (queued + drained-but-unacked).
type Sequencer ¶
type Sequencer struct {
Id []byte
// contains filtered or unexported fields
}
Sequencer implements core sequencing interface
func NewSequencer ¶
func NewSequencer( logger zerolog.Logger, db ds.Batching, daClient block.FullDAClient, cfg config.Config, id []byte, maxQueueSize int, genesis genesis.Genesis, executor execution.Executor, ) (*Sequencer, error)
NewSequencer creates a new Single Sequencer
func (*Sequencer) AckBatch ¶ added in v1.1.3
AckBatch commits the current in-flight queue entries and requeues any postponed txs.
func (*Sequencer) GetDAHeight ¶
GetDAHeight returns the current DA height
func (*Sequencer) GetNextBatch ¶
func (c *Sequencer) GetNextBatch(ctx context.Context, req coresequencer.GetNextBatchRequest) (*coresequencer.GetNextBatchResponse, error)
GetNextBatch gets the next batch. During catch-up, only forced inclusion txs are returned to match based sequencing behavior.
func (*Sequencer) SetDAHeight ¶
SetDAHeight sets the current DA height for the sequencer This should be called when the sequencer needs to sync to a specific DA height
func (*Sequencer) SubmitBatchTxs ¶
func (c *Sequencer) SubmitBatchTxs(ctx context.Context, req coresequencer.SubmitBatchTxsRequest) (*coresequencer.SubmitBatchTxsResponse, error)
SubmitBatchTxs implements sequencing.Sequencer. It adds mempool transactions to a batch.
func (*Sequencer) VerifyBatch ¶
func (c *Sequencer) VerifyBatch(ctx context.Context, req coresequencer.VerifyBatchRequest) (*coresequencer.VerifyBatchResponse, error)
VerifyBatch implements sequencing.Sequencer.