Skip to content

Commit e96c1e7

Browse files
authored
da: reuse useblobs for multiframetxs (#452)
1 parent 4c05eb4 commit e96c1e7

File tree

3 files changed

+20
-28
lines changed

3 files changed

+20
-28
lines changed

op-batcher/batcher/channel_config.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,6 @@ type ChannelConfig struct {
3333
// A value of 0 disables a maximum.
3434
MaxBlocksPerSpanBatch int
3535

36-
// MultiFrameTxs controls whether to put all frames of a channel inside a single tx.
37-
MultiFrameTxs bool
38-
3936
// Target number of frames to create per channel.
4037
// For blob transactions, this controls the number of blobs to target adding
4138
// to each blob tx.

op-batcher/batcher/driver.go

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -658,31 +658,27 @@ func (l *BatchSubmitter) sendTransaction(txdata txData, queue *txmgr.Queue[txRef
658658
return nil
659659
}
660660

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

687683
l.sendTx(txdata, false, candidate, queue, receiptsCh)
688684
return nil

op-batcher/batcher/service.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,6 @@ func (bs *BatcherService) initChannelConfig(cfg *CLIConfig) error {
210210
MaxChannelDuration: cfg.MaxChannelDuration,
211211
MaxFrameSize: cfg.MaxL1TxSize - 1, // account for version byte prefix; reset for blobs
212212
MaxBlocksPerSpanBatch: cfg.MaxBlocksPerSpanBatch,
213-
MultiFrameTxs: cfg.MultiFrameTxs,
214213
TargetNumFrames: cfg.TargetNumFrames,
215214
SubSafetyMargin: cfg.SubSafetyMargin,
216215
BatchType: cfg.BatchType,
@@ -223,7 +222,7 @@ func (bs *BatcherService) initChannelConfig(cfg *CLIConfig) error {
223222

224223
// enable multi-frame txs if set
225224
if cfg.MultiFrameTxs {
226-
cc.MultiFrameTxs = true
225+
cc.UseBlobs = true
227226
}
228227

229228
switch cfg.DataAvailabilityType {
@@ -262,7 +261,7 @@ func (bs *BatcherService) initChannelConfig(cfg *CLIConfig) error {
262261
bs.Log.Info("Initialized channel-config",
263262
"da_type", cfg.DataAvailabilityType,
264263
"use_alt_da", bs.UseAltDA,
265-
"multi_frame_txs", cc.MultiFrameTxs,
264+
"use_blobs", cc.UseBlobs,
266265
"max_frame_size", cc.MaxFrameSize,
267266
"target_num_frames", cc.TargetNumFrames,
268267
"compressor", cc.CompressorConfig.Kind,

0 commit comments

Comments
 (0)