Skip to content

Commit 7e4efcb

Browse files
committed
feat: metrics for respond to task fee limit
1 parent 9102ad3 commit 7e4efcb

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

core/chainio/avs_writer.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
"github.com/ethereum/go-ethereum/core/types"
1717
servicemanager "github.com/yetanotherco/aligned_layer/contracts/bindings/AlignedLayerServiceManager"
1818
"github.com/yetanotherco/aligned_layer/core/config"
19+
"github.com/yetanotherco/aligned_layer/metrics"
1920
)
2021

2122
type AvsWriter struct {
@@ -25,6 +26,7 @@ type AvsWriter struct {
2526
Signer signer.Signer
2627
Client eth.InstrumentedClient
2728
ClientFallback eth.InstrumentedClient
29+
metrics *metrics.Metrics
2830
}
2931

3032
func NewAvsWriterFromConfig(baseConfig *config.BaseConfig, ecdsaConfig *config.EcdsaConfig) (*AvsWriter, error) {
@@ -75,6 +77,7 @@ func (w *AvsWriter) SendAggregatedResponse(batchIdentifierHash [32]byte, batchMe
7577
txOpts.NoSend = true // simulate the transaction
7678
tx, err := w.AvsContractBindings.ServiceManager.RespondToTaskV2(&txOpts, batchMerkleRoot, senderAddress, nonSignerStakesAndSignature)
7779
if err != nil {
80+
w.metrics.IncAggregatedResponses()
7881
// Retry with fallback
7982
tx, err = w.AvsContractBindings.ServiceManagerFallback.RespondToTaskV2(&txOpts, batchMerkleRoot, senderAddress, nonSignerStakesAndSignature)
8083
if err != nil {
@@ -128,7 +131,10 @@ func (w *AvsWriter) checkRespondToTaskFeeLimit(tx *types.Transaction, txOpts bin
128131
w.logger.Info("Batch RespondToTaskFeeLimit", "RespondToTaskFeeLimit", respondToTaskFeeLimit)
129132

130133
if respondToTaskFeeLimit.Cmp(simulatedCost) < 0 {
131-
return fmt.Errorf("cost of transaction is higher than Batch.RespondToTaskFeeLimit")
134+
a, _ := respondToTaskFeeLimit.Sub(big.NewInt(0), simulatedCost).Float64()
135+
w.metrics.AddAccumulatedGasPayedAggregator(a)
136+
w.metrics.IncAggregatorAccumResponse()
137+
w.logger.Warn("cost of transaction is higher than Batch.RespondToTaskFeeLimit, aggregator will pay the for the difference")
132138
}
133139

134140
return w.compareBalances(respondToTaskFeeLimit, aggregatorAddress, senderAddress)

0 commit comments

Comments
 (0)