Skip to content

Commit b01a2d3

Browse files
fix: accumulated aggregator cost panels (#1669)
Co-authored-by: Marcos Nicolau <[email protected]>
1 parent a23f003 commit b01a2d3

File tree

3 files changed

+252
-38
lines changed

3 files changed

+252
-38
lines changed

Makefile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,13 @@ generate_groth16_ineq_proof: ## Run the gnark_plonk_bn254_script
557557
@go run scripts/test_files/gnark_groth16_bn254_infinite_script/cmd/main.go 1
558558

559559
__METRICS__:
560-
# Prometheus and graphana
560+
# Prometheus and Grafana
561+
metrics_remove_containers:
562+
@docker stop prometheus grafana
563+
@docker rm prometheus grafana
564+
metrics_clean_db: metrics_remove_containers
565+
@docker volume rm aligned_layer_grafana_data aligned_layer_prometheus_data
566+
561567
run_metrics: ## Run metrics using metrics-docker-compose.yaml
562568
@echo "Running metrics..."
563569
@docker compose -f metrics-docker-compose.yaml up

core/chainio/avs_writer.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ func (w *AvsWriter) SendAggregatedResponse(batchIdentifierHash [32]byte, batchMe
150150
if receipt == nil {
151151
receipt, _ = w.ClientFallback.TransactionReceipt(context.Background(), tx.Hash())
152152
if receipt != nil {
153-
w.updateAggregatorGasCostMetrics(tx, batchIdentifierHash)
153+
w.updateAggregatorGasCostMetrics(receipt, batchIdentifierHash)
154154
return receipt, nil
155155
}
156156
}
@@ -185,7 +185,7 @@ func (w *AvsWriter) SendAggregatedResponse(batchIdentifierHash [32]byte, batchMe
185185
w.logger.Infof("Transaction sent, waiting for receipt", "merkle root", batchMerkleRootHashString)
186186
receipt, err := utils.WaitForTransactionReceiptRetryable(w.Client, w.ClientFallback, realTx.Hash(), retry.WaitForTxRetryParams(timeToWaitBeforeBump))
187187
if receipt != nil {
188-
w.updateAggregatorGasCostMetrics(realTx, batchIdentifierHash)
188+
w.updateAggregatorGasCostMetrics(receipt, batchIdentifierHash)
189189
return receipt, nil
190190
}
191191

@@ -209,15 +209,14 @@ func (w *AvsWriter) SendAggregatedResponse(batchIdentifierHash [32]byte, batchMe
209209
// Calculates the transaction cost from the receipt and updates the total amount paid by the aggregator metric
210210
// Then, it compares that tx cost with the batcher respondToTaskFeeLimit.
211211
// If the tx cost was higher, it means the aggregator has paid the difference for the batcher (txCost - respondToTaskFeeLimit) and so metrics are updated accordingly.
212-
func (w *AvsWriter) updateAggregatorGasCostMetrics(tx *types.Transaction, batchIdentifierHash [32]byte) {
212+
func (w *AvsWriter) updateAggregatorGasCostMetrics(receipt *types.Receipt, batchIdentifierHash [32]byte) {
213213
batchState, err := w.BatchesStateRetryable(&bind.CallOpts{}, batchIdentifierHash, retry.NetworkRetryParams())
214214
if err != nil {
215215
return
216216
}
217217
respondToTaskFeeLimit := batchState.RespondToTaskFeeLimit
218218

219-
// NOTE we are not using tx.Cost() because tx.Cost() includes tx.Value()
220-
txCost := new(big.Int).Mul(big.NewInt(int64(tx.Gas())), tx.GasPrice())
219+
txCost := new(big.Int).Mul(big.NewInt(int64(receipt.GasUsed)), receipt.EffectiveGasPrice)
221220

222221
txCostInEth := utils.WeiToEth(txCost)
223222
w.metrics.AddAggregatorGasCostPaidTotal(txCostInEth)

0 commit comments

Comments
 (0)