Skip to content

Commit

Permalink
feat: metrics for batch poster rewards and refund
Browse files Browse the repository at this point in the history
  • Loading branch information
renlulu committed Sep 13, 2024
1 parent e7b5308 commit d229f1a
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions arbos/l1pricing/l1pricing.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"encoding/binary"
"errors"
"fmt"
"github.com/ethereum/go-ethereum/metrics"
"math/big"
"sync/atomic"

Expand Down Expand Up @@ -56,6 +57,13 @@ var (
ErrInvalidTime = errors.New("invalid timestamp")
)

var (
batchPosterRewardsCounter = metrics.NewRegisteredCounter("arbos/batch_poster/rewards_counter", nil)
batchPosterRewardsDistribution = metrics.NewRegisteredGaugeFloat64("arbos/batch_poster/rewards_distribution", nil)
batchPosterRefundCounter = metrics.NewRegisteredCounter("arbos/batch_poster/refund_counter", nil)
batchPosterRefundDistribution = metrics.NewRegisteredGaugeFloat64("arbos/batch_poster/refund_distribution", nil)
)

const (
payRewardsToOffset uint64 = iota
equilibrationUnitsOffset
Expand Down Expand Up @@ -414,6 +422,9 @@ func (ps *L1PricingState) UpdateForBatchPosterSpending(
if err != nil {
return err
}
batchPosterRewards, _ := paymentForRewards.Float64()
batchPosterRewardsCounter.Inc(1)
batchPosterRewardsDistribution.Update(batchPosterRewards)

// settle up payments owed to the batch poster, as much as possible
balanceDueToPoster, err := posterState.FundsDue()
Expand All @@ -435,6 +446,9 @@ func (ps *L1PricingState) UpdateForBatchPosterSpending(
if err != nil {
return err
}
batchPosterRefunds, _ := balanceToTransfer.Float64()
batchPosterRefundCounter.Inc(1)
batchPosterRefundDistribution.Update(batchPosterRefunds)
balanceDueToPoster = am.BigSub(balanceDueToPoster, balanceToTransfer)
err = posterState.SetFundsDue(balanceDueToPoster)
if err != nil {
Expand Down

0 comments on commit d229f1a

Please sign in to comment.