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

Add PeerDAS reconstruction metrics #14807

Open
wants to merge 8 commits into
base: peerDAS
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
17 changes: 17 additions & 0 deletions beacon-chain/sync/data_columns_reconstruct.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/pkg/errors"
"github.com/sirupsen/logrus"

"github.com/prysmaticlabs/prysm/v5/beacon-chain/blockchain/kzg"
"github.com/prysmaticlabs/prysm/v5/beacon-chain/core/peerdas"
fieldparams "github.com/prysmaticlabs/prysm/v5/config/fieldparams"
"github.com/prysmaticlabs/prysm/v5/config/params"
Expand All @@ -21,6 +22,8 @@ import (
const broadCastMissingDataColumnsTimeIntoSlot = 3 * time.Second

func (s *Service) reconstructDataColumns(ctx context.Context, verifiedRODataColumn blocks.VerifiedRODataColumn) error {
startTime := time.Now()

// Get the block root.
blockRoot := verifiedRODataColumn.BlockRoot()

Expand Down Expand Up @@ -121,6 +124,10 @@ func (s *Service) reconstructDataColumns(ctx context.Context, verifiedRODataColu
}
}

// Update reconstruction metrics
dataColumnReconstructionHistogram.Observe(float64(time.Since(startTime).Milliseconds()))
dataColumnReconstructionCounter.Add(float64(cellsCount(recoveredCellsAndProofs)))

log.WithField("root", fmt.Sprintf("%x", blockRoot)).Debug("Data columns reconstructed and saved successfully")

// Schedule the broadcast.
Expand Down Expand Up @@ -369,3 +376,13 @@ func columnsArrayToMap(columnsArray [fieldparams.NumberOfColumns]bool) map[uint6

return columnsMap
}

// cellsCount counts the number of cells in the cells and proofs array
func cellsCount(cellsAndProofs []kzg.CellsAndProofs) int {
cellsCount := 0
for i := range cellsAndProofs {
cellsCount += len(cellsAndProofs[i].Cells)
}

return cellsCount
}
13 changes: 13 additions & 0 deletions beacon-chain/sync/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,19 @@ var (
Buckets: []float64{100, 250, 500, 750, 1000, 1500, 2000, 4000, 8000, 12000, 16000},
},
)

dataColumnReconstructionCounter = promauto.NewCounter(prometheus.CounterOpts{
Name: "beacon_data_availability_reconstructed_columns_total",
Help: "Count the number of reconstructed data columns.",
})

dataColumnReconstructionHistogram = promauto.NewHistogram(
prometheus.HistogramOpts{
Name: "beacon_data_availability_reconstruction_time_milliseconds",
Help: "Captures the time taken to reconstruct data columns.",
Buckets: []float64{100, 250, 500, 750, 1000, 1500, 2000, 4000, 8000, 12000, 16000},
},
)
)

func (s *Service) updateMetrics() {
Expand Down
2 changes: 1 addition & 1 deletion beacon-chain/sync/validate_data_column.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (

// https://github.com/ethereum/consensus-specs/blob/dev/specs/fulu/p2p-interface.md#the-gossip-domain-gossipsub
func (s *Service) validateDataColumn(ctx context.Context, pid peer.ID, msg *pubsub.Message) (pubsub.ValidationResult, error) {
dataColumnSidecarVerificationRequestsCounter.Inc();
dataColumnSidecarVerificationRequestsCounter.Inc()
receivedTime := prysmTime.Now()

// Always accept messages our own messages.
Expand Down
Loading