Skip to content

Commit

Permalink
da: reuse useblobs for multiframetxs (#452)
Browse files Browse the repository at this point in the history
  • Loading branch information
tuxcanfly authored Oct 22, 2024
1 parent 4c05eb4 commit e96c1e7
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 28 deletions.
3 changes: 0 additions & 3 deletions op-batcher/batcher/channel_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@ type ChannelConfig struct {
// A value of 0 disables a maximum.
MaxBlocksPerSpanBatch int

// MultiFrameTxs controls whether to put all frames of a channel inside a single tx.
MultiFrameTxs bool

// Target number of frames to create per channel.
// For blob transactions, this controls the number of blobs to target adding
// to each blob tx.
Expand Down
40 changes: 18 additions & 22 deletions op-batcher/batcher/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -658,31 +658,27 @@ func (l *BatchSubmitter) sendTransaction(txdata txData, queue *txmgr.Queue[txRef
return nil
}

var candidate *txmgr.TxCandidate
if txdata.asBlob {
if candidate, err = l.blobTxCandidate(txdata); err != nil {
// We could potentially fall through and try a calldata tx instead, but this would
// likely result in the chain spending more in gas fees than it is tuned for, so best
// to just fail. We do not expect this error to trigger unless there is a serious bug
// or configuration issue.
return fmt.Errorf("could not create blob tx candidate: %w", err)
}
} else {
// sanity check
if nf := len(txdata.frames); nf > l.ChannelConfig.ChannelConfig().TargetNumFrames {
l.Log.Crit("Unexpected number of frames in calldata tx", "num_frames", nf)
}
candidate, err = l.celestiaTxCandidate(txdata.CallData())
// force celestia tx candidate, multiframe is set by UseBlobs which is not affected
txdata.asBlob = false
// sanity check
if nf := len(txdata.frames); nf > l.ChannelConfig.ChannelConfig().TargetNumFrames {
l.Log.Crit("Unexpected number of frames in calldata tx", "num_frames", nf)
}
candidate, err := l.celestiaTxCandidate(txdata.CallData())
if err != nil {
l.Log.Error("celestia: blob submission failed", "err", err)
candidate, err = l.fallbackTxCandidate(txdata)
if err != nil {
l.Log.Error("celestia: blob submission failed", "err", err)
candidate, err = l.fallbackTxCandidate(txdata)
if err != nil {
l.Log.Error("celestia: fallback failed", "err", err)
l.recordFailedTx(txdata.ID(), err)
return nil
}
l.Log.Error("celestia: fallback failed", "err", err)
l.recordFailedTx(txdata.ID(), err)
return nil
}
}
// restore asBlob for cancellation in case of blobdata fallback
if len(candidate.Blobs) > 0 {
txdata.asBlob = true
}
l.Log.Info("tx candidate", "ID", txdata.ID(), "len(txdata.frames)", len(txdata.frames), "txdata.asBlob", txdata.asBlob)

l.sendTx(txdata, false, candidate, queue, receiptsCh)
return nil
Expand Down
5 changes: 2 additions & 3 deletions op-batcher/batcher/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,6 @@ func (bs *BatcherService) initChannelConfig(cfg *CLIConfig) error {
MaxChannelDuration: cfg.MaxChannelDuration,
MaxFrameSize: cfg.MaxL1TxSize - 1, // account for version byte prefix; reset for blobs
MaxBlocksPerSpanBatch: cfg.MaxBlocksPerSpanBatch,
MultiFrameTxs: cfg.MultiFrameTxs,
TargetNumFrames: cfg.TargetNumFrames,
SubSafetyMargin: cfg.SubSafetyMargin,
BatchType: cfg.BatchType,
Expand All @@ -223,7 +222,7 @@ func (bs *BatcherService) initChannelConfig(cfg *CLIConfig) error {

// enable multi-frame txs if set
if cfg.MultiFrameTxs {
cc.MultiFrameTxs = true
cc.UseBlobs = true
}

switch cfg.DataAvailabilityType {
Expand Down Expand Up @@ -262,7 +261,7 @@ func (bs *BatcherService) initChannelConfig(cfg *CLIConfig) error {
bs.Log.Info("Initialized channel-config",
"da_type", cfg.DataAvailabilityType,
"use_alt_da", bs.UseAltDA,
"multi_frame_txs", cc.MultiFrameTxs,
"use_blobs", cc.UseBlobs,
"max_frame_size", cc.MaxFrameSize,
"target_num_frames", cc.TargetNumFrames,
"compressor", cc.CompressorConfig.Kind,
Expand Down

0 comments on commit e96c1e7

Please sign in to comment.