From 7a1a4e89ddcfb97a8c348442adae4dbac757d912 Mon Sep 17 00:00:00 2001 From: Emiliano Bonassi Date: Fri, 10 May 2024 10:04:04 +0200 Subject: [PATCH] feat: enable multi frame txs and frame size setting for calldata txs --- op-batcher/batcher/config.go | 12 ++++++++++-- op-batcher/batcher/driver.go | 2 +- op-batcher/batcher/service.go | 10 ++++++++++ op-batcher/flags/flags.go | 14 ++++++++++++++ 4 files changed, 35 insertions(+), 3 deletions(-) diff --git a/op-batcher/batcher/config.go b/op-batcher/batcher/config.go index d927a420ec099..456000625450f 100644 --- a/op-batcher/batcher/config.go +++ b/op-batcher/batcher/config.go @@ -57,6 +57,12 @@ type CLIConfig struct { // If using blobs, this setting is ignored and the max blob size is used. MaxL1TxSize uint64 + // MaxFrameSize is the maximum size of a frame in a batch tx. + MaxFrameSize uint64 + + // MultiFrameTxs controls whether to put all frames of a channel inside a single tx. + MultiFrameTxs bool + // The target number of frames to create per channel. Controls number of blobs // per blob tx, if using Blob DA. TargetNumFrames int @@ -101,8 +107,8 @@ type CLIConfig struct { MetricsConfig opmetrics.CLIConfig PprofConfig oppprof.CLIConfig RPC oprpc.CLIConfig - PlasmaDA plasma.CLIConfig - DaConfig celestia.CLIConfig + PlasmaDA plasma.CLIConfig + DaConfig celestia.CLIConfig } func (c *CLIConfig) Check() error { @@ -177,6 +183,8 @@ func NewConfig(ctx *cli.Context) *CLIConfig { MaxPendingTransactions: ctx.Uint64(flags.MaxPendingTransactionsFlag.Name), MaxChannelDuration: ctx.Uint64(flags.MaxChannelDurationFlag.Name), MaxL1TxSize: ctx.Uint64(flags.MaxL1TxSizeBytesFlag.Name), + MaxFrameSize: ctx.Uint64(flags.MaxFrameSizeFlag.Name), + MultiFrameTxs: ctx.Bool(flags.MultiFrameTxsFlag.Name), TargetNumFrames: ctx.Int(flags.TargetNumFramesFlag.Name), ApproxComprRatio: ctx.Float64(flags.ApproxComprRatioFlag.Name), Compressor: ctx.String(flags.CompressorFlag.Name), diff --git a/op-batcher/batcher/driver.go b/op-batcher/batcher/driver.go index 85fabcaa0feb5..7c546352ce748 100644 --- a/op-batcher/batcher/driver.go +++ b/op-batcher/batcher/driver.go @@ -499,7 +499,7 @@ func (l *BatchSubmitter) sendTransaction(ctx context.Context, txdata txData, que } } else { // sanity check - if nf := len(txdata.frames); nf != 1 { + if nf := len(txdata.frames); nf > l.ChannelConfig.TargetNumFrames { l.Log.Crit("unexpected number of frames in calldata tx", "num_frames", nf) } data := txdata.CallData() diff --git a/op-batcher/batcher/service.go b/op-batcher/batcher/service.go index 8ba8ab3423e67..19b409a726a3f 100644 --- a/op-batcher/batcher/service.go +++ b/op-batcher/batcher/service.go @@ -206,6 +206,16 @@ func (bs *BatcherService) initChannelConfig(cfg *CLIConfig) error { BatchType: cfg.BatchType, } + // override max frame size if set + if cfg.MaxFrameSize > 0 { + cc.MaxFrameSize = cfg.MaxFrameSize + } + + // enable multi-frame txs if set + if cfg.MultiFrameTxs { + cc.MultiFrameTxs = true + } + switch cfg.DataAvailabilityType { case flags.BlobsType: if !cfg.TestUseMaxTxSizeForBlobs { diff --git a/op-batcher/flags/flags.go b/op-batcher/flags/flags.go index 67390a0f20071..43b39db2f634a 100644 --- a/op-batcher/flags/flags.go +++ b/op-batcher/flags/flags.go @@ -76,6 +76,18 @@ var ( Value: 120_000, // will be overwritten to max for blob da-type EnvVars: prefixEnvVars("MAX_L1_TX_SIZE_BYTES"), } + MaxFrameSizeFlag = &cli.Uint64Flag{ + Name: "max-frame-size-bytes", + Usage: "The maximum size of a frame. 0 to use default value (120k-1)", + Value: 0, + EnvVars: prefixEnvVars("MAX_FRAME_SIZE_BYTES"), + } + MultiFrameTxsFlag = &cli.BoolFlag{ + Name: "multi-frame-txs", + Usage: "Whether to put all frames of a channel inside a single tx. Ignored for blobs, where true will be used.", + Value: false, + EnvVars: prefixEnvVars("MULTI_FRAME_TXS"), + } TargetNumFramesFlag = &cli.IntFlag{ Name: "target-num-frames", Usage: "The target number of frames to create per channel. Controls number of blobs per blob tx, if using Blob DA.", @@ -169,6 +181,8 @@ var optionalFlags = []cli.Flag{ MaxPendingTransactionsFlag, MaxChannelDurationFlag, MaxL1TxSizeBytesFlag, + MaxFrameSizeFlag, + MultiFrameTxsFlag, TargetNumFramesFlag, ApproxComprRatioFlag, CompressorFlag,