Add bls pool metric (#12133)

* Add metric gauge for bls to exec pool count

* Fix

* Fix

* Gazelle
This commit is contained in:
terencechain 2023-03-15 07:12:21 -07:00 committed by GitHub
parent ce32453c7b
commit 2669c93375
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 0 deletions

View File

@ -17,6 +17,8 @@ go_library(
"//consensus-types/primitives:go_default_library",
"//container/doubly-linked-list:go_default_library",
"//proto/prysm/v1alpha1:go_default_library",
"@com_github_prometheus_client_golang//prometheus:go_default_library",
"@com_github_prometheus_client_golang//prometheus/promauto:go_default_library",
"@com_github_sirupsen_logrus//:go_default_library",
],
)

View File

@ -4,6 +4,8 @@ import (
"math"
"sync"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
"github.com/prysmaticlabs/prysm/v3/beacon-chain/core/blocks"
"github.com/prysmaticlabs/prysm/v3/beacon-chain/state"
"github.com/prysmaticlabs/prysm/v3/config/params"
@ -18,6 +20,13 @@ import (
// we only do it when the map is smaller than this upper bound.
const blsChangesPoolThreshold = 2000
var (
blsToExecMessageInPoolTotal = promauto.NewGauge(prometheus.GaugeOpts{
Name: "bls_to_exec_message_pool_total",
Help: "The number of saved bls to exec message in the operation cool.",
})
)
// PoolManager maintains pending and seen BLS-to-execution-change objects.
// This pool is used by proposers to insert BLS-to-execution-change objects into new blocks.
type PoolManager interface {
@ -116,6 +125,9 @@ func (p *Pool) InsertBLSToExecChange(change *ethpb.SignedBLSToExecutionChange) {
p.pending.Append(doublylinkedlist.NewNode(change))
p.m[change.Message.ValidatorIndex] = p.pending.Last()
blsToExecMessageInPoolTotal.Inc()
}
// MarkIncluded is used when an object has been included in a beacon block. Every block seen by this
@ -134,6 +146,8 @@ func (p *Pool) MarkIncluded(change *ethpb.SignedBLSToExecutionChange) {
if p.numPending() == blsChangesPoolThreshold {
p.cycleMap()
}
blsToExecMessageInPoolTotal.Dec()
}
// ValidatorExists checks if the bls to execution change object exists