Skip to content

Commit fe9726d

Browse files
palangoclaude
andcommitted
op-batcher: extract newTxRef helper
The txRef literal (id/isCancel/isBlob/daType/size from a txData) was duplicated across sendTx, the fallback-auth gate error path, and the fallback-auth submission. Extract newTxRef(txdata, isCancel) so the three sites stay in sync. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 7c834e7 commit fe9726d

3 files changed

Lines changed: 15 additions & 3 deletions

File tree

op-batcher/batcher/driver.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,18 @@ type txRef struct {
5151
size int
5252
}
5353

54+
// newTxRef builds the txRef that identifies a batch submission across the txmgr
55+
// queue and receipt handling.
56+
func newTxRef(txdata txData, isCancel bool) txRef {
57+
return txRef{
58+
id: txdata.ID(),
59+
isCancel: isCancel,
60+
isBlob: txdata.daType == DaTypeBlob,
61+
daType: txdata.daType,
62+
size: txdata.Len(),
63+
}
64+
}
65+
5466
func (r txRef) String() string {
5567
return r.string(func(id txID) string { return id.String() })
5668
}
@@ -1057,7 +1069,7 @@ func (l *BatchSubmitter) sendTx(txdata txData, isCancel bool, candidate *txmgr.T
10571069
return
10581070
}
10591071

1060-
queue.Send(txRef{id: txdata.ID(), isCancel: isCancel, isBlob: txdata.daType == DaTypeBlob, daType: txdata.daType, size: txdata.Len()}, *candidate, receiptsCh)
1072+
queue.Send(newTxRef(txdata, isCancel), *candidate, receiptsCh)
10611073
}
10621074

10631075
func (l *BatchSubmitter) blobTxCandidate(data txData) (*txmgr.TxCandidate, error) {

op-batcher/batcher/espresso_driver.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ func (l *BatchSubmitter) dispatchAuthenticatedSendTx(txdata txData, isCancel boo
3535
fallbackAuthRequired, err := l.isFallbackAuthRequired(l.killCtx)
3636
if err != nil {
3737
receiptsCh <- txmgr.TxReceipt[txRef]{
38-
ID: txRef{id: txdata.ID(), isCancel: isCancel, isBlob: txdata.daType == DaTypeBlob, daType: txdata.daType, size: txdata.Len()},
38+
ID: newTxRef(txdata, isCancel),
3939
Err: fmt.Errorf("failed to evaluate fallback-auth gate: %w", err),
4040
}
4141
return true

op-batcher/batcher/fallback_auth.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func computeCommitment(candidate *txmgr.TxCandidate) ([32]byte, error) {
4242
// The contract's fallback path checks msg.sender against systemConfig.batcherHash(), so no
4343
// separate signature is needed — the L1 transaction is already signed by the TxManager's key.
4444
func (l *BatchSubmitter) sendTxWithFallbackAuth(txdata txData, isCancel bool, candidate *txmgr.TxCandidate, queue TxSender[txRef], receiptsCh chan txmgr.TxReceipt[txRef]) {
45-
transactionReference := txRef{id: txdata.ID(), isCancel: isCancel, isBlob: txdata.daType == DaTypeBlob, daType: txdata.daType, size: txdata.Len()}
45+
transactionReference := newTxRef(txdata, isCancel)
4646
l.Log.Debug("Sending fallback-authenticated L1 transaction", "txRef", transactionReference)
4747

4848
commitment, err := computeCommitment(candidate)

0 commit comments

Comments
 (0)