Skip to content

Commit

Permalink
refactor: unify l1pricing and l1pricing old version
Browse files Browse the repository at this point in the history
  • Loading branch information
renlulu committed Sep 13, 2024
1 parent cc335e6 commit 126c8d8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 20 deletions.
16 changes: 4 additions & 12 deletions arbos/l1pricing/l1PricingOldVersions.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
package l1pricing

import (
"github.com/ethereum/go-ethereum/metrics"
"math"
"math/big"

Expand All @@ -14,13 +13,6 @@ import (
am "github.com/offchainlabs/nitro/util/arbmath"
)

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

func (ps *L1PricingState) _preversion10_UpdateForBatchPosterSpending(
statedb vm.StateDB,
evm *vm.EVM,
Expand Down Expand Up @@ -132,7 +124,7 @@ func (ps *L1PricingState) _preversion10_UpdateForBatchPosterSpending(
return err
}
l1PricerRewards, _ := paymentForRewards.Float64()
l1RewardsCounter.Inc(1)
l1RewardsDistributionCounter.Inc(1)
l1RewardsDistribution.Update(l1PricerRewards)
availableFunds = statedb.GetBalance(L1PricerFundsPoolAddress)

Expand All @@ -157,7 +149,7 @@ func (ps *L1PricingState) _preversion10_UpdateForBatchPosterSpending(
return err
}
l1PricerDue, _ := balanceToTransfer.Float64()
l1BaseFeeDueCounter.Inc(1)
l1BaseFeeDueDistributionCounter.Inc(1)
l1BaseFeeDueDistribution.Update(l1PricerDue)
balanceDueToPoster = am.BigSub(balanceDueToPoster, balanceToTransfer)
err = posterState.SetFundsDue(balanceDueToPoster)
Expand Down Expand Up @@ -317,7 +309,7 @@ func (ps *L1PricingState) _preVersion2_UpdateForBatchPosterSpending(
return err
}
l1PricerRewards, _ := paymentForRewards.Float64()
l1RewardsCounter.Inc(1)
l1RewardsDistributionCounter.Inc(1)
l1RewardsDistribution.Update(l1PricerRewards)
availableFunds = am.BigSub(availableFunds, paymentForRewards)

Expand Down Expand Up @@ -351,7 +343,7 @@ func (ps *L1PricingState) _preVersion2_UpdateForBatchPosterSpending(
return err
}
l1PricerDue, _ := balanceToTransfer.Float64()
l1BaseFeeDueCounter.Inc(1)
l1BaseFeeDueDistributionCounter.Inc(1)
l1BaseFeeDueDistribution.Update(l1PricerDue)
availableFunds = am.BigSub(availableFunds, balanceToTransfer)
balanceDueToPoster = am.BigSub(balanceDueToPoster, balanceToTransfer)
Expand Down
16 changes: 8 additions & 8 deletions arbos/l1pricing/l1pricing.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ var (
)

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)
l1RewardsDistributionCounter = metrics.NewRegisteredCounter("arbos/l1_rewards_recipient/rewards_counter", nil)
l1RewardsDistribution = metrics.NewRegisteredGaugeFloat64("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)
)

const (
Expand Down Expand Up @@ -423,8 +423,8 @@ func (ps *L1PricingState) UpdateForBatchPosterSpending(
return err
}
batchPosterRewards, _ := paymentForRewards.Float64()
batchPosterRewardsCounter.Inc(1)
batchPosterRewardsDistribution.Update(batchPosterRewards)
l1RewardsDistributionCounter.Inc(1)
l1RewardsDistribution.Update(batchPosterRewards)

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

0 comments on commit 126c8d8

Please sign in to comment.