sequencer

package
v0.7.2-RC2 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2024 License: AGPL-3.0, AGPL-3.0-or-later Imports: 30 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrExpiredTransaction happens when the transaction is expired
	ErrExpiredTransaction = errors.New("transaction expired")
	// ErrEffectiveGasPriceReprocess happens when the effective gas price requires reexecution
	ErrEffectiveGasPriceReprocess = errors.New("effective gas price requires reprocessing the transaction")
	// ErrDuplicatedNonce is returned when adding a new tx to the worker and there is an existing tx
	// with the same nonce and higher gasPrice (in this case we keep the existing tx)
	ErrDuplicatedNonce = errors.New("duplicated nonce")
	// ErrReplacedTransaction is returned when an existing tx is replaced by a new tx with the same nonce and higher gasPrice
	ErrReplacedTransaction = errors.New("replaced transaction")
	// ErrGetBatchByNumber happens when we get an error trying to get a batch by number (GetBatchByNumber)
	ErrGetBatchByNumber = errors.New("get batch by number error")
	// ErrUpdateBatchAsChecked happens when we get an error trying to update a batch as checked (UpdateBatchAsChecked)
	ErrUpdateBatchAsChecked = errors.New("update batch as checked error")
	// ErrDecodeBatchL2Data happens when we get an error trying to decode BatchL2Data (DecodeTxs)
	ErrDecodeBatchL2Data = errors.New("decoding BatchL2Data error")
	// ErrProcessBatch happens when we get an error trying to process (executor) a batch
	ErrProcessBatch = errors.New("processing batch error")
	// ErrProcessBatchOOC happens when we get an OOC when processing (executor) a batch
	ErrProcessBatchOOC = errors.New("processing batch OOC")
	// ErrStateRootNoMatch happens when the SR returned for a full batch processing (sanity check) doesn't match
	// the SR calculated when filling a batch tx by tx
	ErrStateRootNoMatch = errors.New("state root no match")
	// ErrExecutorError happens when we got an executor error when processing a batch
	ErrExecutorError = errors.New("executor error")
	// ErrNoFittingTransaction happens when there is not a tx (from the txSortedList) that fits in the remaining batch resources
	ErrNoFittingTransaction = errors.New("no fit transaction")
	// ErrBatchResourceOverFlow happens when there is a tx that overlows remaining batch resources
	ErrBatchResourceOverFlow = errors.New("batch resource overflow")
	// ErrTransactionsListEmpty happens when txSortedList is empty
	ErrTransactionsListEmpty = errors.New("transactions list empty")
)

Functions

This section is empty.

Types

type Batch added in v0.5.0

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

Batch represents a wip or processed batch.

type Config

type Config struct {
	// DeletePoolTxsL1BlockConfirmations is blocks amount after which txs will be deleted from the pool
	DeletePoolTxsL1BlockConfirmations uint64 `mapstructure:"DeletePoolTxsL1BlockConfirmations"`

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

	// TxLifetimeCheckInterval is the time the sequencer waits to check txs lifetime
	TxLifetimeCheckInterval types.Duration `mapstructure:"TxLifetimeCheckInterval"`

	// TxLifetimeMax is the time a tx can be in the sequencer/worker memory
	TxLifetimeMax types.Duration `mapstructure:"TxLifetimeMax"`

	// LoadPoolTxsCheckInterval is the time the sequencer waits to check in there are new txs in the pool
	LoadPoolTxsCheckInterval types.Duration `mapstructure:"LoadPoolTxsCheckInterval"`

	// StateConsistencyCheckInterval is the time the sequencer waits to check if a state inconsistency has happened
	StateConsistencyCheckInterval types.Duration `mapstructure:"StateConsistencyCheckInterval"`

	// L2Coinbase defines which address is going to receive the fees. It gets the config value from SequenceSender.L2Coinbase
	L2Coinbase common.Address `mapstructure:"L2Coinbase"`

	// Finalizer's specific config properties
	Finalizer FinalizerCfg `mapstructure:"Finalizer"`

	// StreamServerCfg is the config for the stream server
	StreamServer StreamServerCfg `mapstructure:"StreamServer"`
}

Config represents the configuration of a sequencer

type DbTxMock

type DbTxMock struct {
	mock.Mock
}

DbTxMock is an autogenerated mock type for the Tx type

func NewDbTxMock

func NewDbTxMock(t interface {
	mock.TestingT
	Cleanup(func())
}) *DbTxMock

NewDbTxMock creates a new instance of DbTxMock. 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 (*DbTxMock) Begin

func (_m *DbTxMock) Begin(ctx context.Context) (pgx.Tx, error)

Begin provides a mock function with given fields: ctx

func (*DbTxMock) BeginFunc

func (_m *DbTxMock) BeginFunc(ctx context.Context, f func(pgx.Tx) error) error

BeginFunc provides a mock function with given fields: ctx, f

func (*DbTxMock) Commit

func (_m *DbTxMock) Commit(ctx context.Context) error

Commit provides a mock function with given fields: ctx

func (*DbTxMock) Conn

func (_m *DbTxMock) Conn() *pgx.Conn

Conn provides a mock function with given fields:

func (*DbTxMock) CopyFrom

func (_m *DbTxMock) CopyFrom(ctx context.Context, tableName pgx.Identifier, columnNames []string, rowSrc pgx.CopyFromSource) (int64, error)

CopyFrom provides a mock function with given fields: ctx, tableName, columnNames, rowSrc

func (*DbTxMock) Exec

func (_m *DbTxMock) Exec(ctx context.Context, sql string, arguments ...interface{}) (pgconn.CommandTag, error)

Exec provides a mock function with given fields: ctx, sql, arguments

func (*DbTxMock) LargeObjects

func (_m *DbTxMock) LargeObjects() pgx.LargeObjects

LargeObjects provides a mock function with given fields:

func (*DbTxMock) Prepare

func (_m *DbTxMock) Prepare(ctx context.Context, name string, sql string) (*pgconn.StatementDescription, error)

Prepare provides a mock function with given fields: ctx, name, sql

func (*DbTxMock) Query

func (_m *DbTxMock) Query(ctx context.Context, sql string, args ...interface{}) (pgx.Rows, error)

Query provides a mock function with given fields: ctx, sql, args

func (*DbTxMock) QueryFunc

func (_m *DbTxMock) QueryFunc(ctx context.Context, sql string, args []interface{}, scans []interface{}, f func(pgx.QueryFuncRow) error) (pgconn.CommandTag, error)

QueryFunc provides a mock function with given fields: ctx, sql, args, scans, f

func (*DbTxMock) QueryRow

func (_m *DbTxMock) QueryRow(ctx context.Context, sql string, args ...interface{}) pgx.Row

QueryRow provides a mock function with given fields: ctx, sql, args

func (*DbTxMock) Rollback

func (_m *DbTxMock) Rollback(ctx context.Context) error

Rollback provides a mock function with given fields: ctx

func (*DbTxMock) SendBatch

func (_m *DbTxMock) SendBatch(ctx context.Context, b *pgx.Batch) pgx.BatchResults

SendBatch provides a mock function with given fields: ctx, b

type EthermanMock

type EthermanMock struct {
	mock.Mock
}

EthermanMock is an autogenerated mock type for the ethermanInterface type

func NewEthermanMock

func NewEthermanMock(t interface {
	mock.TestingT
	Cleanup(func())
}) *EthermanMock

NewEthermanMock creates a new instance of EthermanMock. 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 (*EthermanMock) DepositCount added in v0.6.6

func (_m *EthermanMock) DepositCount(ctx context.Context, blockNumber *uint64) (*big.Int, error)

DepositCount provides a mock function with given fields: ctx, blockNumber

func (*EthermanMock) GetLatestBatchNumber

func (_m *EthermanMock) GetLatestBatchNumber() (uint64, error)

GetLatestBatchNumber provides a mock function with given fields:

func (*EthermanMock) GetLatestBlockNumber

func (_m *EthermanMock) GetLatestBlockNumber(ctx context.Context) (uint64, error)

GetLatestBlockNumber provides a mock function with given fields: ctx

func (*EthermanMock) GetRollupInfoByBlockRange added in v0.6.6

func (_m *EthermanMock) GetRollupInfoByBlockRange(ctx context.Context, fromBlock uint64, toBlock *uint64) ([]etherman.Block, map[common.Hash][]etherman.Order, error)

GetRollupInfoByBlockRange provides a mock function with given fields: ctx, fromBlock, toBlock

func (*EthermanMock) HeaderByNumber added in v0.6.4

func (_m *EthermanMock) HeaderByNumber(ctx context.Context, number *big.Int) (*types.Header, error)

HeaderByNumber provides a mock function with given fields: ctx, number

func (*EthermanMock) TrustedSequencer

func (_m *EthermanMock) TrustedSequencer() (common.Address, error)

TrustedSequencer provides a mock function with given fields:

type FinalizerCfg

type FinalizerCfg struct {
	// ForcedBatchesTimeout is the time the finalizer waits after receiving closing signal to process Forced Batches
	ForcedBatchesTimeout types.Duration `mapstructure:"ForcedBatchesTimeout"`

	// NewTxsWaitInterval is the time the finalizer sleeps between each iteration, if there are no transactions to be processed
	NewTxsWaitInterval types.Duration `mapstructure:"NewTxsWaitInterval"`

	// ResourceExhaustedMarginPct is the percentage window of the resource left out for the batch to be closed
	ResourceExhaustedMarginPct uint32 `mapstructure:"ResourceExhaustedMarginPct"`

	// ForcedBatchesL1BlockConfirmations is number of blocks to consider GER final
	ForcedBatchesL1BlockConfirmations uint64 `mapstructure:"ForcedBatchesL1BlockConfirmations"`

	// L1InfoTreeL1BlockConfirmations is number of blocks to consider L1InfoRoot final
	L1InfoTreeL1BlockConfirmations uint64 `mapstructure:"L1InfoTreeL1BlockConfirmations"`

	// ForcedBatchesCheckInterval is used by the closing signals manager to wait for its operation
	ForcedBatchesCheckInterval types.Duration `mapstructure:"ForcedBatchesCheckInterval"`

	// L1InfoTreeCheckInterval is the time interval to check if the L1InfoRoot has been updated
	L1InfoTreeCheckInterval types.Duration `mapstructure:"L1InfoTreeCheckInterval"`

	// BatchMaxDeltaTimestamp is the resolution of the timestamp used to close a batch
	BatchMaxDeltaTimestamp types.Duration `mapstructure:"BatchMaxDeltaTimestamp"`

	// L2BlockMaxDeltaTimestamp is the resolution of the timestamp used to close a L2 block
	L2BlockMaxDeltaTimestamp types.Duration `mapstructure:"L2BlockMaxDeltaTimestamp"`

	// StateRootSyncInterval indicates how often the stateroot generated by the L2 block process will be synchronized with
	// the stateroot used in the tx-by-tx execution
	StateRootSyncInterval types.Duration `mapstructure:"StateRootSyncInterval"`

	// FlushIdCheckInterval is the time interval to get storedFlushID value from the executor/hashdb
	FlushIdCheckInterval types.Duration `mapstructure:"FlushIdCheckInterval"`

	// HaltOnBatchNumber specifies the batch number where the Sequencer will stop to process more transactions and generate new batches.
	// The Sequencer will halt after it closes the batch equal to this number
	HaltOnBatchNumber uint64 `mapstructure:"HaltOnBatchNumber"`

	// SequentialBatchSanityCheck indicates if the reprocess of a closed batch (sanity check) must be done in a
	// sequential way (instead than in parallel)
	SequentialBatchSanityCheck bool `mapstructure:"SequentialBatchSanityCheck"`

	// SequentialProcessL2Block indicates if the processing of a L2 Block must be done in the same finalizer go func instead
	// in the processPendingL2Blocks go func
	SequentialProcessL2Block bool `mapstructure:"SequentialProcessL2Block"`

	// Metrics is the config for the sequencer metrics
	Metrics MetricsCfg `mapstructure:"Metrics"`
}

FinalizerCfg contains the finalizer's configuration properties

type L2Block added in v0.5.0

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

L2Block represents a wip or processed L2 block

type MetricsCfg added in v0.6.1

type MetricsCfg struct {
	// Interval is the interval of time to calculate sequencer metrics
	Interval types.Duration `mapstructure:"Interval"`

	// EnableLog is a flag to enable/disable metrics logs
	EnableLog bool `mapstructure:"EnableLog"`
}

MetricsCfg contains the sequencer metrics configuration properties

type PoolMock

type PoolMock struct {
	mock.Mock
}

PoolMock is an autogenerated mock type for the txPool type

func NewPoolMock

func NewPoolMock(t interface {
	mock.TestingT
	Cleanup(func())
}) *PoolMock

NewPoolMock creates a new instance of PoolMock. 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 (*PoolMock) DeleteFailedTransactionsOlderThan added in v0.4.0

func (_m *PoolMock) DeleteFailedTransactionsOlderThan(ctx context.Context, date time.Time) error

DeleteFailedTransactionsOlderThan provides a mock function with given fields: ctx, date

func (*PoolMock) DeleteTransactionByHash

func (_m *PoolMock) DeleteTransactionByHash(ctx context.Context, hash common.Hash) error

DeleteTransactionByHash provides a mock function with given fields: ctx, hash

func (*PoolMock) DeleteTransactionsByHashes

func (_m *PoolMock) DeleteTransactionsByHashes(ctx context.Context, hashes []common.Hash) error

DeleteTransactionsByHashes provides a mock function with given fields: ctx, hashes

func (*PoolMock) GetDefaultMinGasPriceAllowed added in v0.0.990

func (_m *PoolMock) GetDefaultMinGasPriceAllowed() uint64

GetDefaultMinGasPriceAllowed provides a mock function with given fields:

func (*PoolMock) GetEarliestProcessedTx added in v0.4.7

func (_m *PoolMock) GetEarliestProcessedTx(ctx context.Context) (common.Hash, error)

GetEarliestProcessedTx provides a mock function with given fields: ctx

func (*PoolMock) GetGasPrices added in v0.0.990

func (_m *PoolMock) GetGasPrices(ctx context.Context) (pool.GasPrices, error)

GetGasPrices provides a mock function with given fields: ctx

func (*PoolMock) GetL1AndL2GasPrice added in v0.4.0

func (_m *PoolMock) GetL1AndL2GasPrice() (uint64, uint64)

GetL1AndL2GasPrice provides a mock function with given fields:

func (*PoolMock) GetNonWIPPendingTxs

func (_m *PoolMock) GetNonWIPPendingTxs(ctx context.Context) ([]pool.Transaction, error)

GetNonWIPPendingTxs provides a mock function with given fields: ctx

func (*PoolMock) GetTxZkCountersByHash

func (_m *PoolMock) GetTxZkCountersByHash(ctx context.Context, hash common.Hash) (*state.ZKCounters, *state.ZKCounters, error)

GetTxZkCountersByHash provides a mock function with given fields: ctx, hash

func (*PoolMock) MarkWIPTxsAsPending

func (_m *PoolMock) MarkWIPTxsAsPending(ctx context.Context) error

MarkWIPTxsAsPending provides a mock function with given fields: ctx

func (*PoolMock) UpdateTxStatus

func (_m *PoolMock) UpdateTxStatus(ctx context.Context, hash common.Hash, newStatus pool.TxStatus, isWIP bool, failedReason *string) error

UpdateTxStatus provides a mock function with given fields: ctx, hash, newStatus, isWIP, failedReason

func (*PoolMock) UpdateTxWIPStatus

func (_m *PoolMock) UpdateTxWIPStatus(ctx context.Context, hash common.Hash, isWIP bool) error

UpdateTxWIPStatus provides a mock function with given fields: ctx, hash, isWIP

type Sequencer

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

Sequencer represents a sequencer

func New

func New(cfg Config, batchCfg state.BatchConfig, poolCfg pool.Config, txPool txPool, stateIntf stateInterface, etherman ethermanInterface, eventLog *event.EventLog) (*Sequencer, error)

New init sequencer

func (*Sequencer) Start

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

Start starts the sequencer

type StateMock

type StateMock struct {
	mock.Mock
}

StateMock is an autogenerated mock type for the stateInterface type

func NewStateMock

func NewStateMock(t interface {
	mock.TestingT
	Cleanup(func())
}) *StateMock

NewStateMock creates a new instance of StateMock. 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 (*StateMock) BeginStateTransaction

func (_m *StateMock) BeginStateTransaction(ctx context.Context) (pgx.Tx, error)

BeginStateTransaction provides a mock function with given fields: ctx

func (*StateMock) BuildChangeL2Block added in v0.5.0

func (_m *StateMock) BuildChangeL2Block(deltaTimestamp uint32, l1InfoTreeIndex uint32) []byte

BuildChangeL2Block provides a mock function with given fields: deltaTimestamp, l1InfoTreeIndex

func (*StateMock) CloseBatch

func (_m *StateMock) CloseBatch(ctx context.Context, receipt state.ProcessingReceipt, dbTx pgx.Tx) error

CloseBatch provides a mock function with given fields: ctx, receipt, dbTx

func (*StateMock) CloseWIPBatch added in v0.5.0

func (_m *StateMock) CloseWIPBatch(ctx context.Context, receipt state.ProcessingReceipt, dbTx pgx.Tx) error

CloseWIPBatch provides a mock function with given fields: ctx, receipt, dbTx

func (*StateMock) CountReorgs

func (_m *StateMock) CountReorgs(ctx context.Context, dbTx pgx.Tx) (uint64, error)

CountReorgs provides a mock function with given fields: ctx, dbTx

func (*StateMock) GetBalanceByStateRoot

func (_m *StateMock) GetBalanceByStateRoot(ctx context.Context, address common.Address, root common.Hash) (*big.Int, error)

GetBalanceByStateRoot provides a mock function with given fields: ctx, address, root

func (*StateMock) GetBatchByNumber

func (_m *StateMock) GetBatchByNumber(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (*state.Batch, error)

GetBatchByNumber provides a mock function with given fields: ctx, batchNumber, dbTx

func (*StateMock) GetBlockByNumber added in v0.5.0

func (_m *StateMock) GetBlockByNumber(ctx context.Context, blockNumber uint64, dbTx pgx.Tx) (*state.Block, error)

GetBlockByNumber provides a mock function with given fields: ctx, blockNumber, dbTx

func (*StateMock) GetDSBatches added in v0.4.0

func (_m *StateMock) GetDSBatches(ctx context.Context, firstBatchNumber uint64, lastBatchNumber uint64, readWIPBatch bool, dbTx pgx.Tx) ([]*state.DSBatch, error)

GetDSBatches provides a mock function with given fields: ctx, firstBatchNumber, lastBatchNumber, readWIPBatch, dbTx

func (*StateMock) GetDSGenesisBlock added in v0.0.990

func (_m *StateMock) GetDSGenesisBlock(ctx context.Context, dbTx pgx.Tx) (*state.DSL2Block, error)

GetDSGenesisBlock provides a mock function with given fields: ctx, dbTx

func (*StateMock) GetDSL2Blocks added in v0.0.990

func (_m *StateMock) GetDSL2Blocks(ctx context.Context, firstBatchNumber uint64, lastBatchNumber uint64, dbTx pgx.Tx) ([]*state.DSL2Block, error)

GetDSL2Blocks provides a mock function with given fields: ctx, firstBatchNumber, lastBatchNumber, dbTx

func (*StateMock) GetDSL2Transactions added in v0.0.990

func (_m *StateMock) GetDSL2Transactions(ctx context.Context, firstL2Block uint64, lastL2Block uint64, dbTx pgx.Tx) ([]*state.DSL2Transaction, error)

GetDSL2Transactions provides a mock function with given fields: ctx, firstL2Block, lastL2Block, dbTx

func (*StateMock) GetForcedBatch

func (_m *StateMock) GetForcedBatch(ctx context.Context, forcedBatchNumber uint64, dbTx pgx.Tx) (*state.ForcedBatch, error)

GetForcedBatch provides a mock function with given fields: ctx, forcedBatchNumber, dbTx

func (*StateMock) GetForcedBatchParentHash added in v0.5.0

func (_m *StateMock) GetForcedBatchParentHash(ctx context.Context, forcedBatchNumber uint64, dbTx pgx.Tx) (common.Hash, error)

GetForcedBatchParentHash provides a mock function with given fields: ctx, forcedBatchNumber, dbTx

func (*StateMock) GetForcedBatchesSince

func (_m *StateMock) GetForcedBatchesSince(ctx context.Context, forcedBatchNumber uint64, maxBlockNumber uint64, dbTx pgx.Tx) ([]*state.ForcedBatch, error)

GetForcedBatchesSince provides a mock function with given fields: ctx, forcedBatchNumber, maxBlockNumber, dbTx

func (*StateMock) GetForkIDByBatchNumber added in v0.0.990

func (_m *StateMock) GetForkIDByBatchNumber(batchNumber uint64) uint64

GetForkIDByBatchNumber provides a mock function with given fields: batchNumber

func (*StateMock) GetL1InfoRootLeafByIndex added in v0.5.0

func (_m *StateMock) GetL1InfoRootLeafByIndex(ctx context.Context, l1InfoTreeIndex uint32, dbTx pgx.Tx) (state.L1InfoTreeExitRootStorageEntry, error)

GetL1InfoRootLeafByIndex provides a mock function with given fields: ctx, l1InfoTreeIndex, dbTx

func (*StateMock) GetL1InfoTreeDataFromBatchL2Data added in v0.5.0

func (_m *StateMock) GetL1InfoTreeDataFromBatchL2Data(ctx context.Context, batchL2Data []byte, dbTx pgx.Tx) (map[uint32]state.L1DataV2, common.Hash, common.Hash, error)

GetL1InfoTreeDataFromBatchL2Data provides a mock function with given fields: ctx, batchL2Data, dbTx

func (*StateMock) GetLastBatchNumber

func (_m *StateMock) GetLastBatchNumber(ctx context.Context, dbTx pgx.Tx) (uint64, error)

GetLastBatchNumber provides a mock function with given fields: ctx, dbTx

func (*StateMock) GetLastBlock

func (_m *StateMock) GetLastBlock(ctx context.Context, dbTx pgx.Tx) (*state.Block, error)

GetLastBlock provides a mock function with given fields: ctx, dbTx

func (*StateMock) GetLastL2Block

func (_m *StateMock) GetLastL2Block(ctx context.Context, dbTx pgx.Tx) (*state.L2Block, error)

GetLastL2Block provides a mock function with given fields: ctx, dbTx

func (*StateMock) GetLastStateRoot

func (_m *StateMock) GetLastStateRoot(ctx context.Context, dbTx pgx.Tx) (common.Hash, error)

GetLastStateRoot provides a mock function with given fields: ctx, dbTx

func (*StateMock) GetLastTrustedForcedBatchNumber

func (_m *StateMock) GetLastTrustedForcedBatchNumber(ctx context.Context, dbTx pgx.Tx) (uint64, error)

GetLastTrustedForcedBatchNumber provides a mock function with given fields: ctx, dbTx

func (*StateMock) GetLastVirtualBatchNum

func (_m *StateMock) GetLastVirtualBatchNum(ctx context.Context, dbTx pgx.Tx) (uint64, error)

GetLastVirtualBatchNum provides a mock function with given fields: ctx, dbTx

func (*StateMock) GetLatestBatchGlobalExitRoot added in v0.5.0

func (_m *StateMock) GetLatestBatchGlobalExitRoot(ctx context.Context, dbTx pgx.Tx) (common.Hash, error)

GetLatestBatchGlobalExitRoot provides a mock function with given fields: ctx, dbTx

func (*StateMock) GetLatestL1InfoRoot added in v0.5.0

func (_m *StateMock) GetLatestL1InfoRoot(ctx context.Context, maxBlockNumber uint64) (state.L1InfoTreeExitRootStorageEntry, error)

GetLatestL1InfoRoot provides a mock function with given fields: ctx, maxBlockNumber

func (*StateMock) GetNonceByStateRoot

func (_m *StateMock) GetNonceByStateRoot(ctx context.Context, address common.Address, root common.Hash) (*big.Int, error)

GetNonceByStateRoot provides a mock function with given fields: ctx, address, root

func (*StateMock) GetNotCheckedBatches added in v0.5.8

func (_m *StateMock) GetNotCheckedBatches(ctx context.Context, dbTx pgx.Tx) ([]*state.Batch, error)

GetNotCheckedBatches provides a mock function with given fields: ctx, dbTx

func (*StateMock) GetStorageAt added in v0.4.3

func (_m *StateMock) GetStorageAt(ctx context.Context, address common.Address, position *big.Int, root common.Hash) (*big.Int, error)

GetStorageAt provides a mock function with given fields: ctx, address, position, root

func (*StateMock) GetStoredFlushID added in v0.0.990

func (_m *StateMock) GetStoredFlushID(ctx context.Context) (uint64, string, error)

GetStoredFlushID provides a mock function with given fields: ctx

func (*StateMock) GetTxsOlderThanNL1BlocksUntilTxHash added in v0.4.7

func (_m *StateMock) GetTxsOlderThanNL1BlocksUntilTxHash(ctx context.Context, nL1Blocks uint64, earliestTxHash common.Hash, dbTx pgx.Tx) ([]common.Hash, error)

GetTxsOlderThanNL1BlocksUntilTxHash provides a mock function with given fields: ctx, nL1Blocks, earliestTxHash, dbTx

func (*StateMock) GetVirtualBatchParentHash added in v0.5.0

func (_m *StateMock) GetVirtualBatchParentHash(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (common.Hash, error)

GetVirtualBatchParentHash provides a mock function with given fields: ctx, batchNumber, dbTx

func (*StateMock) OpenBatch

func (_m *StateMock) OpenBatch(ctx context.Context, processingContext state.ProcessingContext, dbTx pgx.Tx) error

OpenBatch provides a mock function with given fields: ctx, processingContext, dbTx

func (*StateMock) OpenWIPBatch added in v0.5.0

func (_m *StateMock) OpenWIPBatch(ctx context.Context, batch state.Batch, dbTx pgx.Tx) error

OpenWIPBatch provides a mock function with given fields: ctx, batch, dbTx

func (*StateMock) ProcessBatchV2 added in v0.5.0

func (_m *StateMock) ProcessBatchV2(ctx context.Context, request state.ProcessRequest, updateMerkleTree bool) (*state.ProcessBatchResponse, string, error)

ProcessBatchV2 provides a mock function with given fields: ctx, request, updateMerkleTree

func (*StateMock) StoreL2Block added in v0.5.0

func (_m *StateMock) StoreL2Block(ctx context.Context, batchNumber uint64, l2Block *state.ProcessBlockResponse, txsEGPLog []*state.EffectiveGasPriceLog, dbTx pgx.Tx) (common.Hash, error)

StoreL2Block provides a mock function with given fields: ctx, batchNumber, l2Block, txsEGPLog, dbTx

func (*StateMock) UpdateBatchAsChecked added in v0.5.8

func (_m *StateMock) UpdateBatchAsChecked(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) error

UpdateBatchAsChecked provides a mock function with given fields: ctx, batchNumber, dbTx

func (*StateMock) UpdateWIPBatch added in v0.5.0

func (_m *StateMock) UpdateWIPBatch(ctx context.Context, receipt state.ProcessingReceipt, dbTx pgx.Tx) error

UpdateWIPBatch provides a mock function with given fields: ctx, receipt, dbTx

type StreamServerCfg added in v0.0.990

type StreamServerCfg struct {
	// Port to listen on
	Port uint16 `mapstructure:"Port"`
	// Filename of the binary data file
	Filename string `mapstructure:"Filename"`
	// Version of the binary data file
	Version uint8 `mapstructure:"Version"`
	// ChainID is the chain ID
	ChainID uint64 `mapstructure:"ChainID"`
	// Enabled is a flag to enable/disable the data streamer
	Enabled bool `mapstructure:"Enabled"`
	// Log is the log configuration
	Log log.Config `mapstructure:"Log"`
	// UpgradeEtrogBatchNumber is the batch number of the upgrade etrog
	UpgradeEtrogBatchNumber uint64 `mapstructure:"UpgradeEtrogBatchNumber"`
	// WriteTimeout is the TCP write timeout when sending data to a datastream client
	WriteTimeout types.Duration `mapstructure:"WriteTimeout"`
	// InactivityTimeout is the timeout to kill an inactive datastream client connection
	InactivityTimeout types.Duration `mapstructure:"InactivityTimeout"`
	// InactivityCheckInterval is the time interval to check for datastream client connections that have reached the inactivity timeout to kill them
	InactivityCheckInterval types.Duration `mapstructure:"InactivityCheckInterval"`
}

StreamServerCfg contains the data streamer's configuration properties

type TxTracker

type TxTracker struct {
	Hash               common.Hash
	HashStr            string
	From               common.Address
	FromStr            string
	Nonce              uint64
	Gas                uint64 // To check if it fits into a batch
	GasPrice           *big.Int
	Cost               *big.Int // Cost = Amount + Benefit
	Bytes              uint64
	UsedZKCounters     state.ZKCounters
	ReservedZKCounters state.ZKCounters
	RawTx              []byte
	ReceivedAt         time.Time // To check if it has been in the txSortedList for too long
	IP                 string    // IP of the tx sender
	FailedReason       *string   // FailedReason is the reason why the tx failed, if it failed
	EffectiveGasPrice  *big.Int
	EGPPercentage      byte
	IsLastExecution    bool
	EGPLog             state.EffectiveGasPriceLog
	L1GasPrice         uint64
	L2GasPrice         uint64
}

TxTracker is a struct that contains all the tx data needed to be managed by the worker

type WaitGroupCount added in v0.6.7

type WaitGroupCount struct {
	sync.WaitGroup
	// contains filtered or unexported fields
}

WaitGroupCount implements a sync.WaitGroup that also has a field to get the WaitGroup counter

func (*WaitGroupCount) Add added in v0.6.7

func (wg *WaitGroupCount) Add(delta int)

Add adds delta to the WaitGroup and increase the counter

func (*WaitGroupCount) Count added in v0.6.7

func (wg *WaitGroupCount) Count() int

Count returns the counter of the WaitGroup

func (*WaitGroupCount) Done added in v0.6.7

func (wg *WaitGroupCount) Done()

Done decrements the WaitGroup and counter by one

type Worker

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

Worker represents the worker component of the sequencer

func NewWorker

func NewWorker(state stateInterface, constraints state.BatchConstraintsCfg, readyTxsCond *timeoutCond) *Worker

NewWorker creates an init a worker

func (*Worker) AddForcedTx added in v0.0.990

func (w *Worker) AddForcedTx(txHash common.Hash, addr common.Address)

AddForcedTx adds a forced tx to the addrQueue

func (*Worker) AddTxTracker

func (w *Worker) AddTxTracker(ctx context.Context, tx *TxTracker) (replacedTx *TxTracker, dropReason error)

AddTxTracker adds a new Tx to the Worker

func (*Worker) DeleteForcedTx added in v0.0.990

func (w *Worker) DeleteForcedTx(txHash common.Hash, addr common.Address)

DeleteForcedTx deletes a forced tx from the addrQueue

func (*Worker) DeleteTx

func (w *Worker) DeleteTx(txHash common.Hash, addr common.Address)

DeleteTx deletes a regular tx from the addrQueue

func (*Worker) DeleteTxPendingToStore added in v0.6.7

func (w *Worker) DeleteTxPendingToStore(txHash common.Hash, addr common.Address)

DeleteTxPendingToStore delete a tx from the addrQueue list of pending txs to store in the DB (trusted state)

func (*Worker) ExpireTransactions

func (w *Worker) ExpireTransactions(maxTime time.Duration) []*TxTracker

ExpireTransactions deletes old txs

func (*Worker) GetBestFittingTx

func (w *Worker) GetBestFittingTx(remainingResources state.BatchResources, highReservedCounters state.ZKCounters, isFistL2BlockAndEmpty bool) (*TxTracker, []*TxTracker, error)

GetBestFittingTx gets the most efficient tx that fits in the available batch resources

func (*Worker) MoveTxPendingToStore added in v0.6.7

func (w *Worker) MoveTxPendingToStore(txHash common.Hash, addr common.Address)

MoveTxPendingToStore moves a tx to pending to store list

func (*Worker) MoveTxToNotReady

func (w *Worker) MoveTxToNotReady(txHash common.Hash, from common.Address, actualNonce *uint64, actualBalance *big.Int) []*TxTracker

MoveTxToNotReady move a tx to not ready after it fails to execute

func (*Worker) NewTxTracker

func (w *Worker) NewTxTracker(tx types.Transaction, usedZKCounters state.ZKCounters, reservedZKCounters state.ZKCounters, ip string) (*TxTracker, error)

NewTxTracker creates and inits a TxTracker

func (*Worker) RestoreTxsPendingToStore added in v0.6.7

func (w *Worker) RestoreTxsPendingToStore(ctx context.Context) ([]*TxTracker, []*TxTracker)

RestoreTxsPendingToStore restores the txs pending to store and move them to the worker pool to be processed again

func (*Worker) UpdateAfterSingleSuccessfulTxExecution

func (w *Worker) UpdateAfterSingleSuccessfulTxExecution(from common.Address, touchedAddresses map[common.Address]*state.InfoReadWrite) []*TxTracker

UpdateAfterSingleSuccessfulTxExecution updates the touched addresses after execute on Executor a successfully tx

func (*Worker) UpdateTxZKCounters added in v0.0.990

func (w *Worker) UpdateTxZKCounters(txHash common.Hash, addr common.Address, usedZKCounters state.ZKCounters, reservedZKCounters state.ZKCounters)

UpdateTxZKCounters updates the ZKCounter of a tx

type WorkerMock

type WorkerMock struct {
	mock.Mock
}

WorkerMock is an autogenerated mock type for the workerInterface type

func NewWorkerMock

func NewWorkerMock(t interface {
	mock.TestingT
	Cleanup(func())
}) *WorkerMock

NewWorkerMock creates a new instance of WorkerMock. 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 (*WorkerMock) AddForcedTx added in v0.0.990

func (_m *WorkerMock) AddForcedTx(txHash common.Hash, addr common.Address)

AddForcedTx provides a mock function with given fields: txHash, addr

func (*WorkerMock) AddTxTracker

func (_m *WorkerMock) AddTxTracker(ctx context.Context, txTracker *TxTracker) (*TxTracker, error)

AddTxTracker provides a mock function with given fields: ctx, txTracker

func (*WorkerMock) DeleteForcedTx added in v0.0.990

func (_m *WorkerMock) DeleteForcedTx(txHash common.Hash, addr common.Address)

DeleteForcedTx provides a mock function with given fields: txHash, addr

func (*WorkerMock) DeleteTx

func (_m *WorkerMock) DeleteTx(txHash common.Hash, from common.Address)

DeleteTx provides a mock function with given fields: txHash, from

func (*WorkerMock) DeleteTxPendingToStore added in v0.6.7

func (_m *WorkerMock) DeleteTxPendingToStore(txHash common.Hash, addr common.Address)

DeleteTxPendingToStore provides a mock function with given fields: txHash, addr

func (*WorkerMock) GetBestFittingTx

func (_m *WorkerMock) GetBestFittingTx(remainingResources state.BatchResources, highReservedCounters state.ZKCounters, fistL2Block bool) (*TxTracker, []*TxTracker, error)

GetBestFittingTx provides a mock function with given fields: remainingResources, highReservedCounters, fistL2Block

func (*WorkerMock) MoveTxPendingToStore added in v0.6.7

func (_m *WorkerMock) MoveTxPendingToStore(txHash common.Hash, addr common.Address)

MoveTxPendingToStore provides a mock function with given fields: txHash, addr

func (*WorkerMock) MoveTxToNotReady

func (_m *WorkerMock) MoveTxToNotReady(txHash common.Hash, from common.Address, actualNonce *uint64, actualBalance *big.Int) []*TxTracker

MoveTxToNotReady provides a mock function with given fields: txHash, from, actualNonce, actualBalance

func (*WorkerMock) NewTxTracker

func (_m *WorkerMock) NewTxTracker(tx types.Transaction, usedZKcounters state.ZKCounters, reservedZKCouners state.ZKCounters, ip string) (*TxTracker, error)

NewTxTracker provides a mock function with given fields: tx, usedZKcounters, reservedZKCouners, ip

func (*WorkerMock) RestoreTxsPendingToStore added in v0.6.7

func (_m *WorkerMock) RestoreTxsPendingToStore(ctx context.Context) ([]*TxTracker, []*TxTracker)

RestoreTxsPendingToStore provides a mock function with given fields: ctx

func (*WorkerMock) UpdateAfterSingleSuccessfulTxExecution

func (_m *WorkerMock) UpdateAfterSingleSuccessfulTxExecution(from common.Address, touchedAddresses map[common.Address]*state.InfoReadWrite) []*TxTracker

UpdateAfterSingleSuccessfulTxExecution provides a mock function with given fields: from, touchedAddresses

func (*WorkerMock) UpdateTxZKCounters added in v0.0.990

func (_m *WorkerMock) UpdateTxZKCounters(txHash common.Hash, from common.Address, usedZKCounters state.ZKCounters, reservedZKCounters state.ZKCounters)

UpdateTxZKCounters provides a mock function with given fields: txHash, from, usedZKCounters, reservedZKCounters

Jump to

Keyboard shortcuts

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