Skip to content

Commit

Permalink
feat: metrics for bumped gas price
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcosNicolau committed Oct 22, 2024
1 parent 6f85dda commit 96f2ace
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
3 changes: 2 additions & 1 deletion aggregator/internal/pkg/aggregator.go
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,8 @@ func (agg *Aggregator) sendAggregatedResponse(batchIdentifierHash [32]byte, batc
"senderAddress", hex.EncodeToString(senderAddress[:]),
"batchIdentifierHash", hex.EncodeToString(batchIdentifierHash[:]))

receipt, err := agg.avsWriter.SendAggregatedResponse(batchIdentifierHash, batchMerkleRoot, senderAddress, nonSignerStakesAndSignature)
onRetry := func() { agg.metrics.IncBumpedGasPriceForAggregatedResponse() }
receipt, err := agg.avsWriter.SendAggregatedResponse(batchIdentifierHash, batchMerkleRoot, senderAddress, nonSignerStakesAndSignature, onRetry)
if err != nil {
agg.walletMutex.Unlock()
agg.logger.Infof("- Unlocked Wallet Resources: Error sending aggregated response for batch %s. Error: %s", hex.EncodeToString(batchIdentifierHash[:]), err)
Expand Down
6 changes: 6 additions & 0 deletions core/chainio/avs_writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,13 @@ func (w *AvsWriter) SendAggregatedResponse(batchIdentifierHash [32]byte, batchMe
txOpts.Nonce = txNonce

lastTxGasPrice := tx.GasPrice()
i := 0
sendTransaction := func() (*types.Receipt, error) {
if i > 0 {
onRetry()
}
i++

bumpedGasPrice := utils.CalculateGasPriceBump(lastTxGasPrice, gasBumpPercentage)
lastTxGasPrice = bumpedGasPrice
txOpts.GasPrice = bumpedGasPrice
Expand Down
20 changes: 15 additions & 5 deletions metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@ import (
)

type Metrics struct {
ipPortAddress string
logger logging.Logger
numAggregatedResponses prometheus.Counter
numAggregatorReceivedTasks prometheus.Counter
numOperatorTaskResponses prometheus.Counter
ipPortAddress string
logger logging.Logger
numAggregatedResponses prometheus.Counter
numAggregatorReceivedTasks prometheus.Counter
numOperatorTaskResponses prometheus.Counter
numBumpedGasPriceForAggregatedResponse prometheus.Counter
}

const alignedNamespace = "aligned"
Expand All @@ -40,6 +41,11 @@ func NewMetrics(ipPortAddress string, reg prometheus.Registerer, logger logging.
Name: "aggregator_received_tasks",
Help: "Number of tasks received by the Service Manager",
}),
numBumpedGasPriceForAggregatedResponse: promauto.With(reg).NewCounter(prometheus.CounterOpts{
Namespace: alignedNamespace,
Name: "respond_to_task_gas_price_bumped",
Help: "Number of times gas price was bumped while sending aggregated response",
}),
}
}

Expand Down Expand Up @@ -74,3 +80,7 @@ func (m *Metrics) IncAggregatedResponses() {
func (m *Metrics) IncOperatorTaskResponses() {
m.numOperatorTaskResponses.Inc()
}

func (m *Metrics) IncBumpedGasPriceForAggregatedResponse() {
m.numBumpedGasPriceForAggregatedResponse.Inc()
}

0 comments on commit 96f2ace

Please sign in to comment.