sequencer

package
v0.0.1-RC10 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2023 License: GPL-3.0 Imports: 20 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// WaitPeriodSendSequence is the time the sequencer waits until
	// trying to send a sequence to L1
	WaitPeriodSendSequence types.Duration `mapstructure:"WaitPeriodSendSequence"`
	// WaitPeriodPoolIsEmpty is the time the sequencer waits until
	// trying to add new txs to the state
	WaitPeriodPoolIsEmpty types.Duration `mapstructure:"WaitPeriodPoolIsEmpty"`

	// LastBatchVirtualizationTimeMaxWaitPeriod is time since sequences should be sent
	LastBatchVirtualizationTimeMaxWaitPeriod types.Duration `mapstructure:"LastBatchVirtualizationTimeMaxWaitPeriod"`

	// WaitBlocksToUpdateGER is number of blocks for sequencer to wait
	WaitBlocksToUpdateGER uint64 `mapstructure:"WaitBlocksToUpdateGER"`

	// WaitBlocksToConsiderGerFinal is number of blocks for sequencer to consider GER final
	WaitBlocksToConsiderGerFinal uint64 `mapstructure:"WaitBlocksToConsiderGerFinal"`

	// ElapsedTimeToCloseBatchWithoutTxsDueToNewGER it's time to close a batch bcs new GER appeared
	ElapsedTimeToCloseBatchWithoutTxsDueToNewGER types.Duration `mapstructure:"ElapsedTimeToCloseBatchWithoutTxsDueToNewGER"`

	// MinTimeToCloseBatch enough time passed to close a batch.
	MinTimeToCloseBatch types.Duration `mapstructure:"MinTimeToCloseBatch"`

	// MaxTimeForBatchToBeOpen is time after which new batch should be closed
	MaxTimeForBatchToBeOpen types.Duration `mapstructure:"MaxTimeForBatchToBeOpen"`

	// BlocksAmountForTxsToBeDeleted is blocks amount after which txs will be deleted from the pool
	BlocksAmountForTxsToBeDeleted uint64 `mapstructure:"BlocksAmountForTxsToBeDeleted"`

	// FrequencyToCheckTxsForDelete is frequency with which txs will be checked for deleting
	FrequencyToCheckTxsForDelete types.Duration `mapstructure:"FrequencyToCheckTxsForDelete"`

	// MaxTxsPerBatch is the maximum amount of transactions in the batch
	MaxTxsPerBatch uint64 `mapstructure:"MaxTxsPerBatch"`

	// MaxBatchBytesSize is the maximum batch size in bytes
	MaxBatchBytesSize int `mapstructure:"MaxBatchBytesSize"`

	// MaxCumulativeGasUsed is max gas amount used by batch
	MaxCumulativeGasUsed uint64 `mapstructure:"MaxCumulativeGasUsed"`

	// MaxKeccakHashes is max keccak hashes used by batch
	MaxKeccakHashes int32 `mapstructure:"MaxKeccakHashes"`

	// MaxPoseidonHashes is max poseidon hashes batch can handle
	MaxPoseidonHashes int32 `mapstructure:"MaxPoseidonHashes"`

	// MaxPoseidonPaddings is max poseidon paddings batch can handle
	MaxPoseidonPaddings int32 `mapstructure:"MaxPoseidonPaddings"`

	// MaxMemAligns is max mem aligns batch can handle
	MaxMemAligns int32 `mapstructure:"MaxMemAligns"`

	// MaxArithmetics is max arithmetics batch can handle
	MaxArithmetics int32 `mapstructure:"MaxArithmetics"`

	// MaxBinaries is max binaries batch can handle
	MaxBinaries int32 `mapstructure:"MaxBinaries"`

	// MaxSteps is max steps batch can handle
	MaxSteps int32 `mapstructure:"MaxSteps"`

	// ProfitabilityChecker configuration
	ProfitabilityChecker profitabilitychecker.Config `mapstructure:"ProfitabilityChecker"`

	// Maximum size, in gas size, a sequence can reach
	MaxSequenceSize MaxSequenceSize `mapstructure:"MaxSequenceSize"`

	// Maximum allowed failed counter for the tx before it becomes invalid
	MaxAllowedFailedCounter uint64 `mapstructure:"MaxAllowedFailedCounter"`
}

Config represents the configuration of a sequencer

type MaxSequenceSize

type MaxSequenceSize struct {
	*big.Int `validate:"required"`
}

MaxSequenceSize is a wrapper type that parses token amount to big int

func (*MaxSequenceSize) UnmarshalText

func (m *MaxSequenceSize) UnmarshalText(data []byte) error

UnmarshalText unmarshal token amount from float string to big int

type PendingTxsQueue

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

PendingTxsQueue keeps pending tx queue and gives tx with the highest gas price by request

func NewPendingTxsQueue

func NewPendingTxsQueue(cfg PendingTxsQueueConfig, pool txPool) *PendingTxsQueue

NewPendingTxsQueue inits new pending tx queue

func (*PendingTxsQueue) CleanPendTxsChan

func (q *PendingTxsQueue) CleanPendTxsChan(ctx context.Context)

CleanPendTxsChan cleans pending tx that is already popped from the queue and selected/rejected

func (*PendingTxsQueue) GetPendingTxsQueueLength

func (q *PendingTxsQueue) GetPendingTxsQueueLength() int

GetPendingTxsQueueLength get length

func (*PendingTxsQueue) InsertPendingTx

func (q *PendingTxsQueue) InsertPendingTx(tx pool.Transaction)

InsertPendingTx insert pending tx from the pool to the queue

func (*PendingTxsQueue) KeepPendingTxsQueue

func (q *PendingTxsQueue) KeepPendingTxsQueue(ctx context.Context)

KeepPendingTxsQueue keeps pending txs queue full

func (*PendingTxsQueue) PopPendingTx

func (q *PendingTxsQueue) PopPendingTx() *pool.Transaction

PopPendingTx pops top pending tx from the queue

type PendingTxsQueueConfig

type PendingTxsQueueConfig struct {
	TxPendingInQueueCheckingFrequency types.Duration `mapstructure:"TxPendingInQueueCheckingFrequency"`
	GetPendingTxsFrequency            types.Duration `mapstructure:"GetPendingTxsFrequency"`
}

PendingTxsQueueConfig config for pending tx queue data structure

type Sequencer

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

Sequencer represents a sequencer

func New

func New(
	cfg Config,
	txPool txPool,
	state stateInterface,
	etherman etherman,
	priceGetter priceGetter,
	manager txManager,
	gpe gasPriceEstimator) (*Sequencer, error)

New init sequencer

func (*Sequencer) Start

func (s *Sequencer) Start(ctx context.Context)

Start starts the sequencer

Directories

Path Synopsis
pb

Jump to

Keyboard shortcuts

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