Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: metrics for infra fee, newtork fee, batch poster fee, and l1 rewards #2674

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions arbos/l1pricing/l1PricingOldVersions.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ func (ps *L1PricingState) _preversion10_UpdateForBatchPosterSpending(
if err != nil {
return err
}
l1RewardsDistributionCounter.Inc(1)
l1RewardsDistribution.Inc(paymentForRewards.Int64())
availableFunds = statedb.GetBalance(L1PricerFundsPoolAddress)

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

// settle up our batch poster payments owed, as much as possible
Expand Down Expand Up @@ -333,6 +339,8 @@ func (ps *L1PricingState) _preVersion2_UpdateForBatchPosterSpending(
if err != nil {
return err
}
l1BaseFeeDueDistributionCounter.Inc(1)
l1BaseFeeDueDistribution.Inc(balanceToTransfer.Int64())
availableFunds = am.BigSub(availableFunds, balanceToTransfer)
balanceDueToPoster = am.BigSub(balanceDueToPoster, balanceToTransfer)
err = poster.SetFundsDue(balanceDueToPoster)
Expand Down
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,14 @@ var (
ErrInvalidTime = errors.New("invalid timestamp")
)

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

const (
payRewardsToOffset uint64 = iota
equilibrationUnitsOffset
Expand Down Expand Up @@ -414,6 +423,9 @@ func (ps *L1PricingState) UpdateForBatchPosterSpending(
if err != nil {
return err
}
l1RewardsDistributionCounter.Inc(1)
l1RewardsDistribution.Inc(paymentForRewards.Int64())
l1PricerFundsPoolBalance.Update(arbmath.BalancePerEther())

// settle up payments owed to the batch poster, as much as possible
balanceDueToPoster, err := posterState.FundsDue()
Expand All @@ -435,6 +447,8 @@ func (ps *L1PricingState) UpdateForBatchPosterSpending(
if err != nil {
return err
}
l1BaseFeeDueDistributionCounter.Inc(1)
l1BaseFeeDueDistribution.Inc(balanceToTransfer.Int64())
balanceDueToPoster = am.BigSub(balanceDueToPoster, balanceToTransfer)
err = posterState.SetFundsDue(balanceDueToPoster)
if err != nil {
Expand Down
12 changes: 12 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.NewRegisteredCounter("arbos/infra_fee/distribution", nil)
networkFeeDistributionCounter = metrics.NewRegisteredCounter("arbos/network_fee/counter", nil)
networkFeeDistribution = metrics.NewRegisteredCounter("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,13 @@ func (p *TxProcessor) EndTxHook(gasLeft uint64, success bool) {
infraRefund := arbmath.BigMulByUint(infraFee, gasLeft)
infraRefund = takeFunds(networkRefund, infraRefund)
refund(infraFeeAccount, infraRefund)
infraFeeDistributionCounter.Inc(1)
infraFeeDistribution.Inc(infraRefund.Int64())
}
}
refund(networkFeeAccount, networkRefund)
networkFeeDistributionCounter.Inc(1)
networkFeeDistribution.Inc(networkRefund.Int64())

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