Skip to content

Commit 8330494

Browse files
committed
chore: nits in avs writer
1 parent b36763a commit 8330494

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

core/chainio/avs_writer.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ func (w *AvsWriter) SendAggregatedResponse(batchIdentifierHash [32]byte, batchMe
112112
onGasPriceBumped(txOpts.GasPrice)
113113
}
114114

115+
// We compare both Aggregator funds and Batcher balance in Aligned against respondToTaskFeeLimit
116+
// Both are required to have some balance, more details inside the function
115117
err = w.checkAggAndBatcherHaveEnoughBalance(tx, txOpts, batchIdentifierHash, senderAddress)
116118
if err != nil {
117119
return nil, retry.PermanentError{Inner: err}
@@ -154,17 +156,15 @@ func (w *AvsWriter) checkIfAggregatorHadToPaidForBatcher(tx *types.Transaction,
154156
}
155157
respondToTaskFeeLimit := batchState.RespondToTaskFeeLimit
156158

159+
// NOTE we are not using tx.Cost() because tx.Cost() includes tx.Value()
157160
txCost := new(big.Int).Mul(big.NewInt(int64(tx.Gas())), tx.GasPrice())
158-
// todo: 70_000 should come from the config or at least be a constant
159-
txCost = txCost.Add(txCost, big.NewInt(70_0000))
160161

161162
if respondToTaskFeeLimit.Cmp(txCost) < 0 {
162163
aggregatorDifferencePaid := new(big.Int).Sub(txCost, respondToTaskFeeLimit)
163164
aggregatorDifferencePaidInEth := utils.WeiToEth(aggregatorDifferencePaid)
164165
w.metrics.AddAggregatorGasPaidForBatcher(aggregatorDifferencePaidInEth)
165166
w.metrics.IncAggregatorPaidForBatcher()
166167
w.logger.Warnf("cost of transaction was higher than Batch.RespondToTaskFeeLimit, aggregator has paid the for the difference, aprox: %vethers", aggregatorDifferencePaidInEth)
167-
return
168168
}
169169
}
170170

@@ -182,6 +182,9 @@ func (w *AvsWriter) checkAggAndBatcherHaveEnoughBalance(tx *types.Transaction, t
182182
}
183183
respondToTaskFeeLimit := batchState.RespondToTaskFeeLimit
184184
w.logger.Info("Checking balance against Batch RespondToTaskFeeLimit", "RespondToTaskFeeLimit", respondToTaskFeeLimit)
185+
// Note: we compare both Aggregator funds and Batcher balance in Aligned against respondToTaskFeeLimit
186+
// Batcher will pay up to respondToTaskFeeLimit, for this he needs that amount of funds in Aligned
187+
// Aggregator will pay any extra cost, for this he needs at least respondToTaskFeeLimit in his balance
185188
return w.compareBalances(respondToTaskFeeLimit, aggregatorAddress, senderAddress)
186189
}
187190

0 commit comments

Comments
 (0)