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

attestations in pool count metrics #4930

Merged
merged 4 commits into from Feb 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions beacon-chain/operations/attestations/BUILD.bazel
Expand Up @@ -5,6 +5,7 @@ go_library(
srcs = [
"aggregate.go",
"log.go",
"metrics.go",
"pool.go",
"prepare_forkchoice.go",
"service.go",
Expand All @@ -18,6 +19,8 @@ go_library(
"//shared/hashutil:go_default_library",
"//shared/params:go_default_library",
"@com_github_dgraph_io_ristretto//:go_default_library",
"@com_github_prometheus_client_golang//prometheus:go_default_library",
"@com_github_prometheus_client_golang//prometheus/promauto:go_default_library",
"@com_github_prysmaticlabs_ethereumapis//eth/v1alpha1:go_default_library",
"@com_github_prysmaticlabs_go_bitfield//:go_default_library",
"@com_github_prysmaticlabs_go_ssz//:go_default_library",
Expand Down
3 changes: 3 additions & 0 deletions beacon-chain/operations/attestations/aggregate.go
Expand Up @@ -28,6 +28,9 @@ func (s *Service) aggregateRoutine() {
if err := s.aggregateAttestations(ctx, attsToBeAggregated); err != nil {
log.WithError(err).Error("Could not aggregate attestation")
}

// Update metrics for aggregated and unaggregated attestations count.
s.updateMetrics()
}
}
}
Expand Down
5 changes: 5 additions & 0 deletions beacon-chain/operations/attestations/kv/aggregated.go
Expand Up @@ -145,3 +145,8 @@ func (p *AttCaches) HasAggregatedAttestation(att *ethpb.Attestation) (bool, erro

return false, nil
}

// AggregatedAttestationCount returns the number of aggregated attestations key in the pool.
func (p *AttCaches) AggregatedAttestationCount() int {
return p.aggregatedAtt.ItemCount()
}
5 changes: 5 additions & 0 deletions beacon-chain/operations/attestations/kv/unaggregated.go
Expand Up @@ -70,3 +70,8 @@ func (p *AttCaches) DeleteUnaggregatedAttestation(att *ethpb.Attestation) error

return nil
}

// UnaggregatedAttestationCount returns the number of unaggregated attestations key in the pool.
func (p *AttCaches) UnaggregatedAttestationCount() int {
return p.unAggregatedAtt.ItemCount()
}
26 changes: 26 additions & 0 deletions beacon-chain/operations/attestations/metrics.go
@@ -0,0 +1,26 @@
package attestations

import (
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
)

var (
aggregatedAttsCount = promauto.NewGauge(
prometheus.GaugeOpts{
Name: "aggregated_attestations_in_pool_count",
Help: "The number of aggregated attestations in the pool.",
},
)
unaggregatedAttsCount = promauto.NewGauge(
prometheus.GaugeOpts{
Name: "unaggregated_attestations_in_pool_count",
Help: "The number of unaggregated attestations in the pool.",
},
)
)

func (s *Service) updateMetrics() {
aggregatedAttsCount.Set(float64(s.pool.AggregatedAttestationCount()))
unaggregatedAttsCount.Set(float64(s.pool.UnaggregatedAttestationCount()))
}
2 changes: 2 additions & 0 deletions beacon-chain/operations/attestations/pool.go
Expand Up @@ -17,11 +17,13 @@ type Pool interface {
AggregatedAttestationsBySlotIndex(slot uint64, committeeIndex uint64) []*ethpb.Attestation
DeleteAggregatedAttestation(att *ethpb.Attestation) error
HasAggregatedAttestation(att *ethpb.Attestation) (bool, error)
AggregatedAttestationCount() int
// For unaggregated attestations.
SaveUnaggregatedAttestation(att *ethpb.Attestation) error
SaveUnaggregatedAttestations(atts []*ethpb.Attestation) error
UnaggregatedAttestations() []*ethpb.Attestation
DeleteUnaggregatedAttestation(att *ethpb.Attestation) error
UnaggregatedAttestationCount() int
// For attestations that were included in the block.
SaveBlockAttestation(att *ethpb.Attestation) error
SaveBlockAttestations(atts []*ethpb.Attestation) error
Expand Down
2 changes: 1 addition & 1 deletion shared/featureconfig/flags.go
Expand Up @@ -95,7 +95,7 @@ var (
Usage: "Disable update fork choice head on per attestation. See PR 4802 for details.",
}
enableByteMempool = cli.BoolFlag{
Name: "enable-byte-mempool",
Name: "enable-byte-mempool",
Usage: "Enable use of sync.Pool for certain byte arrays in the beacon state",
}
)
Expand Down
2 changes: 1 addition & 1 deletion slasher/beaconclient/historical_data_retrieval.go
Expand Up @@ -5,8 +5,8 @@ import (

"github.com/pkg/errors"
ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
"go.opencensus.io/trace"
"github.com/prysmaticlabs/prysm/shared/params"
"go.opencensus.io/trace"
)

// RequestHistoricalAttestations requests all indexed attestations for a
Expand Down
2 changes: 1 addition & 1 deletion validator/client/service.go
Expand Up @@ -4,9 +4,9 @@ import (
"context"

middleware "github.com/grpc-ecosystem/go-grpc-middleware"
grpc_retry "github.com/grpc-ecosystem/go-grpc-middleware/retry"
grpc_opentracing "github.com/grpc-ecosystem/go-grpc-middleware/tracing/opentracing"
grpc_prometheus "github.com/grpc-ecosystem/go-grpc-prometheus"
grpc_retry "github.com/grpc-ecosystem/go-grpc-middleware/retry"
"github.com/pkg/errors"
ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
pb "github.com/prysmaticlabs/prysm/proto/beacon/rpc/v1"
Expand Down