Skip to content

Add peerDAS kzg batch verification metric #9415

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

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.hyperledger.besu.plugin.services.MetricsSystem;
import tech.pegasys.teku.infrastructure.async.SafeFuture;
import tech.pegasys.teku.infrastructure.metrics.MetricsHistogram;
import tech.pegasys.teku.infrastructure.metrics.TekuMetricCategory;
import tech.pegasys.teku.infrastructure.time.TimeProvider;
import tech.pegasys.teku.infrastructure.unsigned.UInt64;
import tech.pegasys.teku.kzg.KZG;
Expand All @@ -41,6 +42,7 @@ public class DataColumnSidecarsByRangeListenerValidatingProxy

private final Set<UInt64> columns;
private final MetricsHistogram dataColumnSidecarInclusionProofVerificationTimeSeconds;
private final MetricsHistogram dataColumnSidecarKzgBatchVerificationTimeSeconds;

public DataColumnSidecarsByRangeListenerValidatingProxy(
final Spec spec,
Expand All @@ -60,6 +62,16 @@ public DataColumnSidecarsByRangeListenerValidatingProxy(
this.dataColumnSidecarInclusionProofVerificationTimeSeconds =
DATA_COLUMN_SIDECAR_INCLUSION_PROOF_VERIFICATION_HISTOGRAM.apply(
metricsSystem, timeProvider);
this.dataColumnSidecarKzgBatchVerificationTimeSeconds =
new MetricsHistogram(
metricsSystem,
timeProvider,
TekuMetricCategory.BEACON,
"kzg_verification_data_column_batch_seconds",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you need one metric in several places, please define it only once and reuse, see

public static final BiFunction<MetricsSystem, TimeProvider, MetricsHistogram>

"Runtime of batched data column kzg verification",
new double[] {
0.005, 0.01, 0.025, 0.05, 0.075, 0.1, 0.25, 0.5, 0.75, 1.0, 1.25, 1.5, 1.75, 2.0
});
}

@Override
Expand All @@ -86,7 +98,15 @@ public SafeFuture<?> onResponse(final DataColumnSidecar dataColumnSidecar) {
DataColumnSidecarsResponseInvalidResponseException.InvalidResponseType
.DATA_COLUMN_SIDECAR_INCLUSION_PROOF_VERIFICATION_FAILED);
}
verifyKzgProof(dataColumnSidecar);
try (MetricsHistogram.Timer ignored =
dataColumnSidecarKzgBatchVerificationTimeSeconds.startTimer()) {
verifyKzgProof(dataColumnSidecar);
} catch (final IOException ioException) {
throw new DataColumnSidecarsResponseInvalidResponseException(
peer,
DataColumnSidecarsResponseInvalidResponseException.InvalidResponseType
.DATA_COLUMN_SIDECAR_KZG_VERIFICATION_FAILED);
}

return dataColumnSidecarResponseListener.onResponse(dataColumnSidecar);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.util.concurrent.ConcurrentHashMap;
import org.hyperledger.besu.plugin.services.MetricsSystem;
import tech.pegasys.teku.infrastructure.metrics.MetricsHistogram;
import tech.pegasys.teku.infrastructure.metrics.TekuMetricCategory;
import tech.pegasys.teku.infrastructure.time.TimeProvider;
import tech.pegasys.teku.kzg.KZG;
import tech.pegasys.teku.networking.p2p.peer.Peer;
Expand All @@ -32,6 +33,7 @@
public class DataColumnSidecarsByRootValidator extends AbstractDataColumnSidecarValidator {
private final Set<DataColumnIdentifier> expectedDataColumnIdentifiers;
private final MetricsHistogram dataColumnSidecarInclusionProofVerificationTimeSeconds;
private final MetricsHistogram dataColumnSidecarKzgBatchVerificationTimeSeconds;

public DataColumnSidecarsByRootValidator(
final Peer peer,
Expand All @@ -46,6 +48,16 @@ public DataColumnSidecarsByRootValidator(
this.dataColumnSidecarInclusionProofVerificationTimeSeconds =
DATA_COLUMN_SIDECAR_INCLUSION_PROOF_VERIFICATION_HISTOGRAM.apply(
metricsSystem, timeProvider);
this.dataColumnSidecarKzgBatchVerificationTimeSeconds =
new MetricsHistogram(
metricsSystem,
timeProvider,
TekuMetricCategory.BEACON,
"kzg_verification_data_column_batch_seconds",
"Runtime of batched data column kzg verification",
new double[] {
0.005, 0.01, 0.025, 0.05, 0.075, 0.1, 0.25, 0.5, 0.75, 1.0, 1.25, 1.5, 1.75, 2.0
});
}

public void validate(final DataColumnSidecar dataColumnSidecar) {
Expand All @@ -63,6 +75,12 @@ public void validate(final DataColumnSidecar dataColumnSidecar) {
throw new DataColumnSidecarsResponseInvalidResponseException(
peer, InvalidResponseType.DATA_COLUMN_SIDECAR_INCLUSION_PROOF_VERIFICATION_FAILED);
}
verifyKzgProof(dataColumnSidecar);
try (MetricsHistogram.Timer ignored =
dataColumnSidecarKzgBatchVerificationTimeSeconds.startTimer()) {
verifyKzgProof(dataColumnSidecar);
} catch (final IOException ioException) {
throw new DataColumnSidecarsResponseInvalidResponseException(
peer, InvalidResponseType.DATA_COLUMN_SIDECAR_KZG_VERIFICATION_FAILED);
}
}
}