batcher

package
v0.0.0-...-23d24bf Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2024 License: MIT Imports: 33 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidChannelTimeout = errors.New("channel timeout is less than the safety margin")
	ErrMaxFrameIndex         = errors.New("max frame index reached (uint16)")
	ErrMaxDurationReached    = errors.New("max channel duration reached")
	ErrChannelTimeoutClose   = errors.New("close to channel timeout")
	ErrSeqWindowClose        = errors.New("close to sequencer window timeout")
	ErrTerminated            = errors.New("channel terminated")
)
View Source
var ErrReorg = errors.New("block does not extend existing chain")

Functions

func Main

func Main(version string, cliCtx *cli.Context) error

Main is the entrypoint into the Batch Submitter. This method returns a closure that executes the service and blocks until the service exits. The use of a closure allows the parameters bound to the tpt-level main package, e.g. GitVersion, to be captured and used once the function is executed.

func NewChannelManager

func NewChannelManager(log log.Logger, metr metrics.Metricer, cfg ChannelConfig) *channelManager

Types

type BatchSubmitter

type BatchSubmitter struct {
	Config // directly embed the config + sources
	// contains filtered or unexported fields
}

BatchSubmitter encapsulates a service responsible for submitting L2 tx batches to L1 for availability.

func NewBatchSubmitter

func NewBatchSubmitter(ctx context.Context, cfg Config, l log.Logger, m metrics.Metricer) (*BatchSubmitter, error)

NewBatchSubmitter initializes the BatchSubmitter, gathering any resources that will be needed during operation.

func NewBatchSubmitterFromCLIConfig

func NewBatchSubmitterFromCLIConfig(cfg CLIConfig, l log.Logger, m metrics.Metricer) (*BatchSubmitter, error)

NewBatchSubmitterFromCLIConfig initializes the BatchSubmitter, gathering any resources that will be needed during operation.

func (*BatchSubmitter) Start

func (l *BatchSubmitter) Start() error

func (*BatchSubmitter) Stop

func (l *BatchSubmitter) Stop(ctx context.Context) error

func (*BatchSubmitter) StopIfRunning

func (l *BatchSubmitter) StopIfRunning(ctx context.Context)

type CLIConfig

type CLIConfig struct {
	// L1EthRpc is the HTTP provider URL for L1.
	L1EthRpc string

	// L2EthRpc is the HTTP provider URL for the L2 execution engine.
	L2EthRpc string

	// RollupRpc is the HTTP provider URL for the L2 rollup node.
	RollupRpc string

	// MaxChannelDuration is the maximum duration (in #L1-blocks) to keep a
	// channel open. This allows to more eagerly send batcher transactions
	// during times of low L2 transaction volume. Note that the effective
	// L1-block distance between batcher transactions is then MaxChannelDuration
	// + NumConfirmations because the batcher waits for NumConfirmations blocks
	// after sending a batcher tx and only then starts a new channel.
	//
	// If 0, duration checks are disabled.
	MaxChannelDuration uint64

	// The batcher tx submission safety margin (in #L1-blocks) to subtract from
	// a channel's timeout and sequencing window, to guarantee safe inclusion of
	// a channel on L1.
	SubSafetyMargin uint64

	// PollInterval is the delay between querying L2 for more transaction
	// and creating a new batch.
	PollInterval time.Duration

	// MaxPendingTransactions is the maximum number of concurrent pending
	// transactions sent to the transaction manager (0 == no limit).
	MaxPendingTransactions uint64

	// MaxL1TxSize is the maximum size of a batch tx submitted to L1.
	MaxL1TxSize uint64

	Stopped bool

	TxMgrConfig      txmgr.CLIConfig
	RPCConfig        rpc.CLIConfig
	LogConfig        ptlog.CLIConfig
	MetricsConfig    ptmetrics.CLIConfig
	PprofConfig      ptpprof.CLIConfig
	CompressorConfig compressor.CLIConfig
}

func NewConfig

func NewConfig(ctx *cli.Context) CLIConfig

NewConfig parses the Config from the provided flags or environment variables.

func (CLIConfig) Check

func (c CLIConfig) Check() error

type ChannelConfig

type ChannelConfig struct {
	// Number of epochs (L1 blocks) per sequencing window, including the epoch
	// L1 origin block itself
	SeqWindowSize uint64
	// The maximum number of L1 blocks that the inclusion transactions of a
	// channel's frames can span.
	ChannelTimeout uint64

	// MaxChannelDuration is the maximum duration (in #L1-blocks) to keep the
	// channel open. This allows control over how long a channel is kept open
	// during times of low transaction volume.
	//
	// If 0, duration checks are disabled.
	MaxChannelDuration uint64
	// The batcher tx submission safety margin (in #L1-blocks) to subtract from
	// a channel's timeout and sequencing window, to guarantee safe inclusion of
	// a channel on L1.
	SubSafetyMargin uint64
	// The maximum byte-size a frame can have.
	MaxFrameSize uint64

	// CompressorConfig contains the configuration for creating new compressors.
	CompressorConfig compressor.Config
}

func (*ChannelConfig) Check

func (cc *ChannelConfig) Check() error

Check validates the ChannelConfig parameters.

type ChannelFullError

type ChannelFullError struct {
	Err error
}

func (*ChannelFullError) Error

func (e *ChannelFullError) Error() string

func (*ChannelFullError) Unwrap

func (e *ChannelFullError) Unwrap() error

type Config

type Config struct {
	L1Client   *ethclient.Client
	L2Client   *ethclient.Client
	RollupNode *sources.RollupClient
	TxManager  txmgr.TxManager

	NetworkTimeout         time.Duration
	PollInterval           time.Duration
	MaxPendingTransactions uint64

	// RollupConfig is queried at startup
	Rollup *rollup.Config

	// Channel builder parameters
	Channel ChannelConfig
	// contains filtered or unexported fields
}

func (*Config) Check

func (c *Config) Check() error

Check ensures that the Config is valid.

Jump to

Keyboard shortcuts

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