From 1d87dd67b04fa8c89782a3f157538d44a16b60b4 Mon Sep 17 00:00:00 2001 From: Nishant Das Date: Fri, 30 Aug 2024 17:26:48 +0800 Subject: [PATCH] Add Data Column Computation Metrics (#14400) * Add Data Column Metrics * Shift it All To Peerdas Package --- beacon-chain/core/peerdas/BUILD.bazel | 3 +++ beacon-chain/core/peerdas/helpers.go | 3 ++- beacon-chain/core/peerdas/metrics.go | 14 ++++++++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 beacon-chain/core/peerdas/metrics.go diff --git a/beacon-chain/core/peerdas/BUILD.bazel b/beacon-chain/core/peerdas/BUILD.bazel index 4fabe748c499..48c20bc1e726 100644 --- a/beacon-chain/core/peerdas/BUILD.bazel +++ b/beacon-chain/core/peerdas/BUILD.bazel @@ -5,6 +5,7 @@ go_library( srcs = [ "helpers.go", "log.go", + "metrics.go", ], importpath = "github.com/prysmaticlabs/prysm/v5/beacon-chain/core/peerdas", visibility = ["//visibility:public"], @@ -22,6 +23,8 @@ go_library( "@com_github_ethereum_go_ethereum//p2p/enr:go_default_library", "@com_github_holiman_uint256//:go_default_library", "@com_github_pkg_errors//: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", "@org_golang_x_sync//errgroup:go_default_library", ], diff --git a/beacon-chain/core/peerdas/helpers.go b/beacon-chain/core/peerdas/helpers.go index 9684798492c3..40a7c8f6ad6c 100644 --- a/beacon-chain/core/peerdas/helpers.go +++ b/beacon-chain/core/peerdas/helpers.go @@ -118,6 +118,7 @@ func CustodyColumns(nodeId enode.ID, custodySubnetCount uint64) (map[uint64]bool // DataColumnSidecars computes the data column sidecars from the signed block and blobs. // https://github.com/ethereum/consensus-specs/blob/dev/specs/_features/eip7594/das-core.md#recover_matrix func DataColumnSidecars(signedBlock interfaces.ReadOnlySignedBeaconBlock, blobs []kzg.Blob) ([]*ethpb.DataColumnSidecar, error) { + startTime := time.Now() blobsCount := len(blobs) if blobsCount == 0 { return nil, nil @@ -205,7 +206,7 @@ func DataColumnSidecars(signedBlock interfaces.ReadOnlySignedBeaconBlock, blobs sidecars = append(sidecars, sidecar) } - + dataColumnComputationTime.Observe(float64(time.Since(startTime).Milliseconds())) return sidecars, nil } diff --git a/beacon-chain/core/peerdas/metrics.go b/beacon-chain/core/peerdas/metrics.go new file mode 100644 index 000000000000..668f85090d75 --- /dev/null +++ b/beacon-chain/core/peerdas/metrics.go @@ -0,0 +1,14 @@ +package peerdas + +import ( + "github.com/prometheus/client_golang/prometheus" + "github.com/prometheus/client_golang/prometheus/promauto" +) + +var dataColumnComputationTime = promauto.NewHistogram( + prometheus.HistogramOpts{ + Name: "data_column_sidecar_computation_milliseconds", + Help: "Captures the time taken to compute data column sidecars from blobs.", + Buckets: []float64{100, 250, 500, 750, 1000, 1500, 2000, 4000, 8000, 12000, 16000}, + }, +)