batcher

package
v0.10.14 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2023 License: MIT Imports: 34 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInputTargetReached = errors.New("target amount of input data reached")
	ErrMaxFrameIndex      = errors.New("max frame index reached (uint16)")
	ErrChannelTimedOut    = errors.New("channel timed out")
)
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 top-level main package, e.g. GitVersion, to be captured and used once the function is executed.

func NewChannelManager

func NewChannelManager(log log.Logger, 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(cfg Config, l log.Logger) (*BatchSubmitter, error)

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

func NewBatchSubmitterFromCLIConfig added in v0.10.12

func NewBatchSubmitterFromCLIConfig(cfg CLIConfig, l log.Logger) (*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()

type CLIConfig added in v0.10.12

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

	// 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

	// NumConfirmations is the number of confirmations which we will wait after
	// appending new batches.
	NumConfirmations uint64

	// SafeAbortNonceTooLowCount is the number of ErrNonceTooLowObservations
	// required to give up on a tx at a particular nonce without receiving
	// confirmation.
	SafeAbortNonceTooLowCount uint64

	// ResubmissionTimeout is time we will wait before resubmitting a
	// transaction.
	ResubmissionTimeout time.Duration

	// Mnemonic is the HD seed used to derive the wallet private keys for both
	// the sequence and proposer. Must be used in conjunction with
	// SequencerHDPath and ProposerHDPath.
	Mnemonic string

	// SequencerHDPath is the derivation path used to obtain the private key for
	// batched submission of sequencer transactions.
	SequencerHDPath string

	// PrivateKey is the private key used to submit sequencer transactions.
	PrivateKey string

	RPCConfig oprpc.CLIConfig

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

	// TargetL1TxSize is the target size of a batch tx submitted to L1.
	TargetL1TxSize uint64

	// TargetNumFrames is the target number of frames per channel.
	TargetNumFrames int

	// ApproxComprRatio is the approximate compression ratio (<= 1.0) of the used
	// compression algorithm.
	ApproxComprRatio float64

	LogConfig oplog.CLIConfig

	MetricsConfig opmetrics.CLIConfig

	PprofConfig oppprof.CLIConfig

	// SignerConfig contains the client config for op-signer service
	SignerConfig opsigner.CLIConfig
}

func NewConfig

func NewConfig(ctx *cli.Context) CLIConfig

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

func (CLIConfig) Check added in v0.10.12

func (c CLIConfig) Check() error

type ChannelConfig added in v0.10.12

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
	// 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
	// The target number of frames to create per channel. Note that if the
	// realized compression ratio is worse than the approximate, more frames may
	// actually be created. This also depends on how close TargetFrameSize is to
	// MaxFrameSize.
	TargetFrameSize uint64
	// The target number of frames to create in this channel. If the realized
	// compression ratio is worse than approxComprRatio, additional leftover
	// frame(s) might get created.
	TargetNumFrames int
	// Approximated compression ratio to assume. Should be slightly smaller than
	// average from experiments to avoid the chances of creating a small
	// additional leftover frame.
	ApproxComprRatio float64
}

func (ChannelConfig) InputThreshold added in v0.10.12

func (c ChannelConfig) InputThreshold() uint64

InputThreshold calculates the input data threshold in bytes from the given parameters.

type ChannelFullError added in v0.10.12

type ChannelFullError struct {
	Err error
}

func (*ChannelFullError) Error added in v0.10.12

func (e *ChannelFullError) Error() string

func (*ChannelFullError) Unwrap added in v0.10.12

func (e *ChannelFullError) Unwrap() error

type Config

type Config struct {
	L1Client        *ethclient.Client
	L2Client        *ethclient.Client
	RollupNode      *sources.RollupClient
	PollInterval    time.Duration
	TxManagerConfig txmgr.Config
	From            common.Address
	SignerFnFactory opcrypto.SignerFactory

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

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

type TransactionManager

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

TransactionManager wraps the simple txmgr package to make it easy to send & wait for transactions

func NewTransactionManager

func NewTransactionManager(log log.Logger, txMgrConfg txmgr.Config, batchInboxAddress common.Address, chainID *big.Int, senderAddress common.Address, l1Client *ethclient.Client, signerFn opcrypto.SignerFn) *TransactionManager

func (*TransactionManager) CraftTx

func (t *TransactionManager) CraftTx(ctx context.Context, data []byte) (*types.Transaction, error)

CraftTx creates the signed transaction to the batchInboxAddress. It queries L1 for the current fee market conditions as well as for the nonce. NOTE: This method SHOULD NOT publish the resulting transaction.

func (*TransactionManager) SendTransaction

func (t *TransactionManager) SendTransaction(ctx context.Context, data []byte) (*types.Receipt, error)

SendTransaction creates & submits a transaction to the batch inbox address with the given `data`. It currently uses the underlying `txmgr` to handle transaction sending & price management. This is a blocking method. It should not be called concurrently. TODO: where to put concurrent transaction handling logic.

func (*TransactionManager) UpdateGasPrice

func (t *TransactionManager) UpdateGasPrice(ctx context.Context, tx *types.Transaction) (*types.Transaction, error)

UpdateGasPrice signs an otherwise identical txn to the one provided but with updated gas prices sampled from the existing network conditions.

NOTE: This method SHOULD NOT publish the resulting transaction.

Jump to

Keyboard shortcuts

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