From 1aef5e40628386384ec9db93d0507b64bb1fb479 Mon Sep 17 00:00:00 2001 From: xiaohuo Date: Fri, 13 Sep 2024 15:04:50 +0800 Subject: [PATCH] feat: metrics for infra fee, newtork fee, batch poster reards/due --- arbos/l1pricing/l1PricingOldVersions.go | 14 ++++++++++++++ arbos/tx_processor.go | 14 ++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/arbos/l1pricing/l1PricingOldVersions.go b/arbos/l1pricing/l1PricingOldVersions.go index 821d743e7d..19ae91e2d5 100644 --- a/arbos/l1pricing/l1PricingOldVersions.go +++ b/arbos/l1pricing/l1PricingOldVersions.go @@ -4,6 +4,7 @@ package l1pricing import ( + "github.com/ethereum/go-ethereum/metrics" "math" "math/big" @@ -13,6 +14,13 @@ import ( am "github.com/offchainlabs/nitro/util/arbmath" ) +var ( + l1PricerFundsPoolRewardsCounter = metrics.NewRegisteredCounter("arbos/l1price_funds/rewards_counter", nil) + l1PricerFundsPoolRewardsDistribution = metrics.NewRegisteredGaugeFloat64("arbos/l1price_funds/rewards_distribution", nil) + l1PricerFundsPoolDueCounter = metrics.NewRegisteredCounter("arbos/l1price_funds/due_counter", nil) + l1PricerFundsPoolDueDistribution = metrics.NewRegisteredGaugeFloat64("arbos/l1price_funds/due_distribution", nil) +) + func (ps *L1PricingState) _preversion10_UpdateForBatchPosterSpending( statedb vm.StateDB, evm *vm.EVM, @@ -123,6 +131,9 @@ func (ps *L1PricingState) _preversion10_UpdateForBatchPosterSpending( if err != nil { return err } + l1PricerRewards, _ := paymentForRewards.Float64() + l1PricerFundsPoolRewardsCounter.Inc(1) + l1PricerFundsPoolRewardsDistribution.Update(l1PricerRewards) availableFunds = statedb.GetBalance(L1PricerFundsPoolAddress) // settle up payments owed to the batch poster, as much as possible @@ -145,6 +156,9 @@ func (ps *L1PricingState) _preversion10_UpdateForBatchPosterSpending( if err != nil { return err } + l1PricerDue, _ := balanceToTransfer.Float64() + l1PricerFundsPoolDueCounter.Inc(1) + l1PricerFundsPoolDueDistribution.Update(l1PricerDue) balanceDueToPoster = am.BigSub(balanceDueToPoster, balanceToTransfer) err = posterState.SetFundsDue(balanceDueToPoster) if err != nil { diff --git a/arbos/tx_processor.go b/arbos/tx_processor.go index b08c7c5d30..c495103a64 100644 --- a/arbos/tx_processor.go +++ b/arbos/tx_processor.go @@ -6,6 +6,7 @@ package arbos import ( "errors" "fmt" + "github.com/ethereum/go-ethereum/metrics" "math/big" "github.com/holiman/uint256" @@ -27,6 +28,13 @@ import ( glog "github.com/ethereum/go-ethereum/log" ) +var ( + infraFeeDistributionCounter = metrics.NewRegisteredCounter("arbos/infra_fee/counter", nil) + infraFeeDistribution = metrics.NewRegisteredGaugeFloat64("arbos/infra_fee/distribution", nil) + networkFeeDistributionCounter = metrics.NewRegisteredCounter("arbos/network_fee/counter", nil) + networkFeeDistribution = metrics.NewRegisteredGaugeFloat64("arbos/network_fee/distribution", nil) +) + var arbosAddress = types.ArbosAddress const GasEstimationL1PricePadding arbmath.Bips = 11000 // pad estimates by 10% @@ -571,9 +579,15 @@ func (p *TxProcessor) EndTxHook(gasLeft uint64, success bool) { infraRefund := arbmath.BigMulByUint(infraFee, gasLeft) infraRefund = takeFunds(networkRefund, infraRefund) refund(infraFeeAccount, infraRefund) + infraFeeDistributionCounter.Inc(1) + infraFeeDistributed, _ := infraRefund.Float64() + infraFeeDistribution.Update(infraFeeDistributed) } } refund(networkFeeAccount, networkRefund) + networkFeeDistributed, _ := networkRefund.Float64() + networkFeeDistributionCounter.Inc(1) + networkFeeDistribution.Update(networkFeeDistributed) if success { // we don't want to charge for this