Skip to content

Commit

Permalink
feat: metrics for infra fee, newtork fee, batch poster reards/due
Browse files Browse the repository at this point in the history
  • Loading branch information
renlulu committed Sep 13, 2024
1 parent 0903019 commit 1aef5e4
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
14 changes: 14 additions & 0 deletions arbos/l1pricing/l1PricingOldVersions.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package l1pricing

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

Expand All @@ -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,
Expand Down Expand Up @@ -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
Expand All @@ -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 {
Expand Down
14 changes: 14 additions & 0 deletions arbos/tx_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package arbos
import (
"errors"
"fmt"
"github.com/ethereum/go-ethereum/metrics"
"math/big"

"github.com/holiman/uint256"
Expand All @@ -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%
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 1aef5e4

Please sign in to comment.