Skip to content

Commit

Permalink
feat: enable multi frame txs and frame size setting for calldata txs
Browse files Browse the repository at this point in the history
  • Loading branch information
emilianobonassi authored and tuxcanfly committed Jun 5, 2024
1 parent 294a0c0 commit 712a19b
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 3 deletions.
12 changes: 10 additions & 2 deletions op-batcher/batcher/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion op-batcher/batcher/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
10 changes: 10 additions & 0 deletions op-batcher/batcher/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
14 changes: 14 additions & 0 deletions op-batcher/flags/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down Expand Up @@ -169,6 +181,8 @@ var optionalFlags = []cli.Flag{
MaxPendingTransactionsFlag,
MaxChannelDurationFlag,
MaxL1TxSizeBytesFlag,
MaxFrameSizeFlag,
MultiFrameTxsFlag,
TargetNumFramesFlag,
ApproxComprRatioFlag,
CompressorFlag,
Expand Down

0 comments on commit 712a19b

Please sign in to comment.