Skip to content

Commit

Permalink
Merge pull request OffchainLabs#2204 from OffchainLabs/l2-gaspricing-…
Browse files Browse the repository at this point in the history
…metrics

Add metrics for L2 gas pricing [NIT-2361]
  • Loading branch information
PlasmaPower authored Mar 26, 2024
2 parents 622abd6 + 39f5cdc commit 6a1c1a7
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions execution/gethexec/executionengine.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,26 @@ import (
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/metrics"
"github.com/ethereum/go-ethereum/params"
"github.com/offchainlabs/nitro/arbos"
"github.com/offchainlabs/nitro/arbos/arbosState"
"github.com/offchainlabs/nitro/arbos/arbostypes"
"github.com/offchainlabs/nitro/arbos/l1pricing"
"github.com/offchainlabs/nitro/arbutil"
"github.com/offchainlabs/nitro/execution"
"github.com/offchainlabs/nitro/util/arbmath"
"github.com/offchainlabs/nitro/util/sharedmetrics"
"github.com/offchainlabs/nitro/util/stopwaiter"
)

var (
baseFeeGauge = metrics.NewRegisteredGauge("arb/block/basefee", nil)
blockGasUsedHistogram = metrics.NewRegisteredHistogram("arb/block/gasused", nil, metrics.NewBoundedHistogramSample())
txCountHistogram = metrics.NewRegisteredHistogram("arb/block/transactions/count", nil, metrics.NewBoundedHistogramSample())
txGasUsedHistogram = metrics.NewRegisteredHistogram("arb/block/transactions/gasused", nil, metrics.NewBoundedHistogramSample())
)

type ExecutionEngine struct {
stopwaiter.StopWaiter

Expand Down Expand Up @@ -487,6 +496,15 @@ func (s *ExecutionEngine) appendBlock(block *types.Block, statedb *state.StateDB
if status == core.SideStatTy {
return errors.New("geth rejected block as non-canonical")
}
baseFeeGauge.Update(block.BaseFee().Int64())
txCountHistogram.Update(int64(len(block.Transactions()) - 1))
var blockGasused uint64
for i := 1; i < len(receipts); i++ {
val := arbmath.SaturatingUSub(receipts[i].GasUsed, receipts[i].GasUsedForL1)
txGasUsedHistogram.Update(int64(val))
blockGasused += val
}
blockGasUsedHistogram.Update(int64(blockGasused))
return nil
}

Expand Down

0 comments on commit 6a1c1a7

Please sign in to comment.