Skip to content

Commit 96f2ace

Browse files
committed
feat: metrics for bumped gas price
1 parent 6f85dda commit 96f2ace

File tree

3 files changed

+23
-6
lines changed

3 files changed

+23
-6
lines changed

aggregator/internal/pkg/aggregator.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,8 @@ func (agg *Aggregator) sendAggregatedResponse(batchIdentifierHash [32]byte, batc
301301
"senderAddress", hex.EncodeToString(senderAddress[:]),
302302
"batchIdentifierHash", hex.EncodeToString(batchIdentifierHash[:]))
303303

304-
receipt, err := agg.avsWriter.SendAggregatedResponse(batchIdentifierHash, batchMerkleRoot, senderAddress, nonSignerStakesAndSignature)
304+
onRetry := func() { agg.metrics.IncBumpedGasPriceForAggregatedResponse() }
305+
receipt, err := agg.avsWriter.SendAggregatedResponse(batchIdentifierHash, batchMerkleRoot, senderAddress, nonSignerStakesAndSignature, onRetry)
305306
if err != nil {
306307
agg.walletMutex.Unlock()
307308
agg.logger.Infof("- Unlocked Wallet Resources: Error sending aggregated response for batch %s. Error: %s", hex.EncodeToString(batchIdentifierHash[:]), err)

core/chainio/avs_writer.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,13 @@ func (w *AvsWriter) SendAggregatedResponse(batchIdentifierHash [32]byte, batchMe
103103
txOpts.Nonce = txNonce
104104

105105
lastTxGasPrice := tx.GasPrice()
106+
i := 0
106107
sendTransaction := func() (*types.Receipt, error) {
108+
if i > 0 {
109+
onRetry()
110+
}
111+
i++
112+
107113
bumpedGasPrice := utils.CalculateGasPriceBump(lastTxGasPrice, gasBumpPercentage)
108114
lastTxGasPrice = bumpedGasPrice
109115
txOpts.GasPrice = bumpedGasPrice

metrics/metrics.go

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,12 @@ import (
1212
)
1313

1414
type Metrics struct {
15-
ipPortAddress string
16-
logger logging.Logger
17-
numAggregatedResponses prometheus.Counter
18-
numAggregatorReceivedTasks prometheus.Counter
19-
numOperatorTaskResponses prometheus.Counter
15+
ipPortAddress string
16+
logger logging.Logger
17+
numAggregatedResponses prometheus.Counter
18+
numAggregatorReceivedTasks prometheus.Counter
19+
numOperatorTaskResponses prometheus.Counter
20+
numBumpedGasPriceForAggregatedResponse prometheus.Counter
2021
}
2122

2223
const alignedNamespace = "aligned"
@@ -40,6 +41,11 @@ func NewMetrics(ipPortAddress string, reg prometheus.Registerer, logger logging.
4041
Name: "aggregator_received_tasks",
4142
Help: "Number of tasks received by the Service Manager",
4243
}),
44+
numBumpedGasPriceForAggregatedResponse: promauto.With(reg).NewCounter(prometheus.CounterOpts{
45+
Namespace: alignedNamespace,
46+
Name: "respond_to_task_gas_price_bumped",
47+
Help: "Number of times gas price was bumped while sending aggregated response",
48+
}),
4349
}
4450
}
4551

@@ -74,3 +80,7 @@ func (m *Metrics) IncAggregatedResponses() {
7480
func (m *Metrics) IncOperatorTaskResponses() {
7581
m.numOperatorTaskResponses.Inc()
7682
}
83+
84+
func (m *Metrics) IncBumpedGasPriceForAggregatedResponse() {
85+
m.numBumpedGasPriceForAggregatedResponse.Inc()
86+
}

0 commit comments

Comments
 (0)