Skip to content

Commit

Permalink
refactor: change metric type
Browse files Browse the repository at this point in the history
  • Loading branch information
renlulu committed Sep 13, 2024
1 parent 126c8d8 commit a67926c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 20 deletions.
12 changes: 4 additions & 8 deletions arbos/l1pricing/l1PricingOldVersions.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,8 @@ func (ps *L1PricingState) _preversion10_UpdateForBatchPosterSpending(
if err != nil {
return err
}
l1PricerRewards, _ := paymentForRewards.Float64()
l1RewardsDistributionCounter.Inc(1)
l1RewardsDistribution.Update(l1PricerRewards)
l1RewardsDistribution.Inc(paymentForRewards.Int64())
availableFunds = statedb.GetBalance(L1PricerFundsPoolAddress)

// settle up payments owed to the batch poster, as much as possible
Expand All @@ -148,9 +147,8 @@ func (ps *L1PricingState) _preversion10_UpdateForBatchPosterSpending(
if err != nil {
return err
}
l1PricerDue, _ := balanceToTransfer.Float64()
l1BaseFeeDueDistributionCounter.Inc(1)
l1BaseFeeDueDistribution.Update(l1PricerDue)
l1BaseFeeDueDistribution.Inc(balanceToTransfer.Int64())
balanceDueToPoster = am.BigSub(balanceDueToPoster, balanceToTransfer)
err = posterState.SetFundsDue(balanceDueToPoster)
if err != nil {
Expand Down Expand Up @@ -308,9 +306,8 @@ func (ps *L1PricingState) _preVersion2_UpdateForBatchPosterSpending(
if err != nil {
return err
}
l1PricerRewards, _ := paymentForRewards.Float64()
l1RewardsDistributionCounter.Inc(1)
l1RewardsDistribution.Update(l1PricerRewards)
l1RewardsDistribution.Inc(paymentForRewards.Int64())
availableFunds = am.BigSub(availableFunds, paymentForRewards)

// settle up our batch poster payments owed, as much as possible
Expand Down Expand Up @@ -342,9 +339,8 @@ func (ps *L1PricingState) _preVersion2_UpdateForBatchPosterSpending(
if err != nil {
return err
}
l1PricerDue, _ := balanceToTransfer.Float64()
l1BaseFeeDueDistributionCounter.Inc(1)
l1BaseFeeDueDistribution.Update(l1PricerDue)
l1BaseFeeDueDistribution.Inc(balanceToTransfer.Int64())
availableFunds = am.BigSub(availableFunds, balanceToTransfer)
balanceDueToPoster = am.BigSub(balanceDueToPoster, balanceToTransfer)
err = poster.SetFundsDue(balanceDueToPoster)
Expand Down
10 changes: 4 additions & 6 deletions arbos/l1pricing/l1pricing.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ var (

var (
l1RewardsDistributionCounter = metrics.NewRegisteredCounter("arbos/l1_rewards_recipient/rewards_counter", nil)
l1RewardsDistribution = metrics.NewRegisteredGaugeFloat64("arbos/l1_rewards_recipient/rewards_distribution", nil)
l1RewardsDistribution = metrics.NewRegisteredCounter("arbos/l1_rewards_recipient/rewards_distribution", nil)
l1BaseFeeDueDistributionCounter = metrics.NewRegisteredCounter("arbos/batchposter_fee_collector/due_counter", nil)
l1BaseFeeDueDistribution = metrics.NewRegisteredGaugeFloat64("arbos/batchposter_fee_collector/due_distribution", nil)
l1BaseFeeDueDistribution = metrics.NewRegisteredCounter("arbos/batchposter_fee_collector/due_distribution", nil)
)

const (
Expand Down Expand Up @@ -422,9 +422,8 @@ func (ps *L1PricingState) UpdateForBatchPosterSpending(
if err != nil {
return err
}
batchPosterRewards, _ := paymentForRewards.Float64()
l1RewardsDistributionCounter.Inc(1)
l1RewardsDistribution.Update(batchPosterRewards)
l1RewardsDistribution.Inc(paymentForRewards.Int64())

// settle up payments owed to the batch poster, as much as possible
balanceDueToPoster, err := posterState.FundsDue()
Expand All @@ -446,9 +445,8 @@ func (ps *L1PricingState) UpdateForBatchPosterSpending(
if err != nil {
return err
}
batchPosterRefunds, _ := balanceToTransfer.Float64()
l1BaseFeeDueDistributionCounter.Inc(1)
l1BaseFeeDueDistribution.Update(batchPosterRefunds)
l1BaseFeeDueDistribution.Inc(balanceToTransfer.Int64())
balanceDueToPoster = am.BigSub(balanceDueToPoster, balanceToTransfer)
err = posterState.SetFundsDue(balanceDueToPoster)
if err != nil {
Expand Down
10 changes: 4 additions & 6 deletions arbos/tx_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ import (

var (
infraFeeDistributionCounter = metrics.NewRegisteredCounter("arbos/infra_fee/counter", nil)
infraFeeDistribution = metrics.NewRegisteredGaugeFloat64("arbos/infra_fee/distribution", nil)
infraFeeDistribution = metrics.NewRegisteredCounter("arbos/infra_fee/distribution", nil)
networkFeeDistributionCounter = metrics.NewRegisteredCounter("arbos/network_fee/counter", nil)
networkFeeDistribution = metrics.NewRegisteredGaugeFloat64("arbos/network_fee/distribution", nil)
networkFeeDistribution = metrics.NewRegisteredCounter("arbos/network_fee/distribution", nil)
)

var arbosAddress = types.ArbosAddress
Expand Down Expand Up @@ -580,14 +580,12 @@ func (p *TxProcessor) EndTxHook(gasLeft uint64, success bool) {
infraRefund = takeFunds(networkRefund, infraRefund)
refund(infraFeeAccount, infraRefund)
infraFeeDistributionCounter.Inc(1)
infraFeeDistributed, _ := infraRefund.Float64()
infraFeeDistribution.Update(infraFeeDistributed)
infraFeeDistribution.Inc(infraRefund.Int64())
}
}
refund(networkFeeAccount, networkRefund)
networkFeeDistributed, _ := networkRefund.Float64()
networkFeeDistributionCounter.Inc(1)
networkFeeDistribution.Update(networkFeeDistributed)
networkFeeDistribution.Inc(networkRefund.Int64())

if success {
// we don't want to charge for this
Expand Down

0 comments on commit a67926c

Please sign in to comment.