Skip to content

Commit b7a2010

Browse files
committed
Decouple DAGroup and TEE-authenticated group (#258)
1 parent 83b676e commit b7a2010

File tree

2 files changed

+18
-10
lines changed

2 files changed

+18
-10
lines changed

op-batcher/batcher/driver.go

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,9 @@ type BatchSubmitter struct {
137137
prevCurrentL1 eth.L1BlockRef // cached CurrentL1 from the last syncStatus
138138

139139
espressoSubmitter *espressoTransactionSubmitter
140+
// Group to limit number of concurrent batches waiting for approval
141+
// from BatchAuthenticator contract, only relevant when running with Espresso enabled
142+
teeAuthGroup errgroup.Group
140143
}
141144

142145
// NewBatchSubmitter initializes the BatchSubmitter driver from a preconfigured DriverSetup
@@ -212,6 +215,8 @@ func (l *BatchSubmitter) StartBatchSubmitting() error {
212215
l.espressoSubmitter.SpawnWorkers(4, 4)
213216
l.espressoSubmitter.Start()
214217

218+
l.teeAuthGroup.SetLimit(128)
219+
215220
l.wg.Add(4)
216221
go l.receiptsLoop(l.wg, receiptsCh) // ranges over receiptsCh channel
217222
go l.espressoBatchQueueingLoop(l.shutdownCtx, l.wg)
@@ -525,6 +530,14 @@ func (l *BatchSubmitter) publishingLoop(ctx context.Context, wg *sync.WaitGroup,
525530
}
526531
}
527532

533+
// Wait for all transactions requiring TEE authentication to complete to prevent new
534+
// transactions being quieued
535+
if err := l.teeAuthGroup.Wait(); err != nil {
536+
if !errors.Is(err, context.Canceled) {
537+
l.Log.Error("error waiting for transaction authentication requests to complete", "err", err)
538+
}
539+
}
540+
528541
// We _must_ wait for all senders on receiptsCh to finish before we can close it.
529542
if err := txQueue.Wait(); err != nil {
530543
if !errors.Is(err, context.Canceled) {
@@ -910,7 +923,7 @@ func (l *BatchSubmitter) cancelBlockingTx(queue *txmgr.Queue[txRef], receiptsCh
910923
panic(err) // this error should not happen
911924
}
912925
l.Log.Warn("sending a cancellation transaction to unblock txpool", "blocked_blob", isBlockedBlob)
913-
l.sendTx(txData{}, true, candidate, queue, receiptsCh, nil)
926+
l.sendTx(txData{}, true, candidate, queue, receiptsCh)
914927
}
915928

916929
// publishToAltDAAndStoreCommitment posts the txdata to the DA Provider and stores the returned commitment
@@ -994,7 +1007,7 @@ func (l *BatchSubmitter) sendTransaction(txdata txData, queue *txmgr.Queue[txRef
9941007
if candidate == nil {
9951008
l.Log.Crit("txcandidate should have been set by one of the three branches above.")
9961009
}
997-
l.sendTx(txdata, false, candidate, queue, receiptsCh, daGroup)
1010+
l.sendTx(txdata, false, candidate, queue, receiptsCh)
9981011
return nil
9991012
}
10001013

@@ -1004,18 +1017,14 @@ type TxSender[T any] interface {
10041017

10051018
// sendTx uses the txmgr queue to send the given transaction candidate after setting its
10061019
// gaslimit. It will block if the txmgr queue has reached its MaxPendingTransactions limit.
1007-
func (l *BatchSubmitter) sendTx(txdata txData, isCancel bool, candidate *txmgr.TxCandidate, queue TxSender[txRef], receiptsCh chan txmgr.TxReceipt[txRef], daGroup *errgroup.Group) {
1020+
func (l *BatchSubmitter) sendTx(txdata txData, isCancel bool, candidate *txmgr.TxCandidate, queue TxSender[txRef], receiptsCh chan txmgr.TxReceipt[txRef]) {
10081021
if l.Config.UseEspresso && !isCancel {
1009-
goroutineSpawned := daGroup.TryGo(
1022+
l.teeAuthGroup.Go(
10101023
func() error {
10111024
l.sendEspressoTx(txdata, isCancel, candidate, queue, receiptsCh)
10121025
return nil
10131026
},
10141027
)
1015-
if !goroutineSpawned {
1016-
log.Trace("failed to spawn Espresso tx goroutine")
1017-
l.recordFailedDARequest(txdata.ID(), nil)
1018-
}
10191028
return
10201029
}
10211030
floorDataGas, err := core.FloorDataGas(candidate.TxData)

op-batcher/batcher/driver_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,7 @@ func TestBatchSubmitter_sendTx_FloorDataGas(t *testing.T) {
168168
false,
169169
&candidate,
170170
q,
171-
make(chan txmgr.TxReceipt[txRef]),
172-
nil)
171+
make(chan txmgr.TxReceipt[txRef]))
173172

174173
candidateOut := q.Load(txData.ID().String())
175174

0 commit comments

Comments
 (0)